summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2020-01-18 17:09:10 +0100
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2020-01-18 17:09:10 +0100
commitea09ea1009f4de52ecd0f6df9a8597e62ae1ca5a (patch)
treedfd3cfb09d487af6be9b817bae6979531c1a0995 /src
parented0c443253bf33152f8a54a0d60d3a9bf6788ae8 (diff)
Use visible size information when copying macOS image from clipboard.
Diffstat (limited to 'src')
-rw-r--r--src/Fl_cocoa.mm8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm
index 8b392cdba..3a66b5933 100644
--- a/src/Fl_cocoa.mm
+++ b/src/Fl_cocoa.mm
@@ -3576,12 +3576,12 @@ static Fl_RGB_Image* get_image_from_clipboard(Fl_Widget *receiver)
if (!bitmap) return NULL;
int bytesPerPixel([bitmap bitsPerPixel]/8);
int bpr([bitmap bytesPerRow]);
- int bpp([bitmap bytesPerPlane]);
- int hh(bpp/bpr);
- int ww(bpr/bytesPerPixel);
+ int hh([bitmap pixelsHigh]);
+ int ww([bitmap pixelsWide]);
uchar *imagedata = new uchar[bpr * hh];
memcpy(imagedata, [bitmap bitmapData], bpr * hh);
- Fl_RGB_Image *image = new Fl_RGB_Image(imagedata, ww, hh, bytesPerPixel);
+ Fl_RGB_Image *image = new Fl_RGB_Image(imagedata, ww, hh, bytesPerPixel, (bpr == ww * bytesPerPixel ? 0 : bpr) );
+ image->scale([bitmap size].width, [bitmap size].height);
image->alloc_array = 1;
[bitmap release];
Fl::e_clipboard_type = Fl::clipboard_image;