diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2021-11-30 20:54:37 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2021-11-30 20:54:37 (GMT) |
commit | 682e78d50eff346d5f0d3914c3913c6cb0c92c5a (patch) | |
tree | 0d6fa67a20f44bbbcd9b3aa41c603ed38b6e1654 /macosx/tkMacOSXImage.c | |
parent | 3f351dd65a460eed8c85334493d901b90275ffc5 (diff) | |
parent | 4138204f761f61153be0a1bab6a1fe917029eaf9 (diff) | |
download | tk-682e78d50eff346d5f0d3914c3913c6cb0c92c5a.zip tk-682e78d50eff346d5f0d3914c3913c6cb0c92c5a.tar.gz tk-682e78d50eff346d5f0d3914c3913c6cb0c92c5a.tar.bz2 |
Merge 8.7
Diffstat (limited to 'macosx/tkMacOSXImage.c')
-rw-r--r-- | macosx/tkMacOSXImage.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/macosx/tkMacOSXImage.c b/macosx/tkMacOSXImage.c index 41d513e..ad317b1 100644 --- a/macosx/tkMacOSXImage.c +++ b/macosx/tkMacOSXImage.c @@ -70,7 +70,7 @@ typedef struct RGBA32pixel_t { /* * ARGB32 0xAARRGGBB (Byte order is ARGB on big-endian systems.) * This is used by Aqua Tk for XImages and by NSBitmapImageReps whose - * bitmapFormat property is NSBitmapFormatAlphaFirst. + * bitmapFormat property is NSAlphaFirstBitmapFormat. */ typedef struct ARGB32pixel_t { @@ -633,14 +633,9 @@ CreateCGImageFromDrawableRect( { MacDrawable *mac_drawable = (MacDrawable *)drawable; CGContextRef cg_context = NULL; - CGRect image_rect = CGRectMake(x, y, width, height); CGImageRef cg_image = NULL, result = NULL; - unsigned char *imageData = NULL; if (mac_drawable->flags & TK_IS_PIXMAP) { cg_context = TkMacOSXGetCGContextForDrawable(drawable); - if (cg_context) { - cg_image = CGBitmapContextCreateImage((CGContextRef) cg_context); - } } else { NSView *view = TkMacOSXGetNSViewForDrawable(mac_drawable); if (view == nil) { @@ -652,9 +647,8 @@ CreateCGImageFromDrawableRect( NSUInteger bytesPerPixel = 4, bytesPerRow = bytesPerPixel * view_width, bitsPerComponent = 8; - imageData = ckalloc(view_height * bytesPerRow); CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); - cg_context = CGBitmapContextCreate(imageData, view_width, view_height, + cg_context = CGBitmapContextCreate(NULL, view_width, view_height, bitsPerComponent, bytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big); @@ -666,10 +660,11 @@ CreateCGImageFromDrawableRect( CGContextRelease(cg_context); } if (cg_image) { - result = CGImageCreateWithImageInRect(cg_image, image_rect); + CGRect rect = CGRectMake(x + mac_drawable->xOff, y + mac_drawable->yOff, + width, height); + result = CGImageCreateWithImageInRect(cg_image, rect); CGImageRelease(cg_image); } - ckfree(imageData); return result; } @@ -762,7 +757,7 @@ XGetImage( size = [bitmapRep bytesPerPlane]; bytes_per_row = [bitmapRep bytesPerRow]; bitmap = (char *)ckalloc(size); - if ((bitmap_fmt != 0 && bitmap_fmt != NSBitmapFormatAlphaFirst) + if ((bitmap_fmt != 0 && bitmap_fmt != NSAlphaFirstBitmapFormat) || [bitmapRep samplesPerPixel] != 4 || [bitmapRep isPlanar] != 0 || bytes_per_row < 4 * width @@ -789,7 +784,7 @@ XGetImage( flipped.rgba.blue = pixel.argb.blue; flipped.rgba.alpha = pixel.argb.alpha; *((pixel32 *)(bitmap + m)) = flipped; - } else { // bitmap_fmt = NSBitmapFormatAlphaFirst + } else { // bitmap_fmt = NSAlphaFirstBitmapFormat *((pixel32 *)(bitmap + m)) = pixel; } } |