summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2021-11-30 08:19:43 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2021-11-30 08:19:43 (GMT)
commite2d33d799ac4538eee8c43dded363e77d2eb425d (patch)
treef58dbe096d44b8ed2718a63fee743b2579bd9ec9 /macosx
parent117d954bfb9d12add9c7c6a56b654737a22b24ad (diff)
parent94be183ea4cb36a60a1fca62b86069742a9878e3 (diff)
downloadtk-e2d33d799ac4538eee8c43dded363e77d2eb425d.zip
tk-e2d33d799ac4538eee8c43dded363e77d2eb425d.tar.gz
tk-e2d33d799ac4538eee8c43dded363e77d2eb425d.tar.bz2
Merge 8.6
Diffstat (limited to 'macosx')
-rw-r--r--macosx/tkMacOSXImage.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/macosx/tkMacOSXImage.c b/macosx/tkMacOSXImage.c
index f3d0467..28c73df 100644
--- a/macosx/tkMacOSXImage.c
+++ b/macosx/tkMacOSXImage.c
@@ -632,14 +632,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) {
@@ -651,9 +646,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);
@@ -665,10 +659,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;
}