Skip to content

Commit

Permalink
Merge bug-b7d813f008-retina to fix rescaling code in Aqua XGetImage.
Browse files Browse the repository at this point in the history
  • Loading branch information
culler committed Aug 10, 2024
2 parents c990368 + b6eecdc commit 66930bd
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions macosx/tkMacOSXImage.c
Original file line number Diff line number Diff line change
Expand Up @@ -674,8 +674,6 @@ CreateCGImageFromDrawableRect(
CGRect rect = CGRectMake(x + mac_drawable->xOff, y + mac_drawable->yOff,
width, height);
rect = CGRectApplyAffineTransform(rect, CGAffineTransformMakeScale(scaleFactor, scaleFactor));
result = CGImageCreateWithImageInRect(cg_image, rect);
CGImageRelease(cg_image);
if (force_1x_scale && (scaleFactor != 1.0)) {
// See https://web.archive.org/web/20200219030756/http://blog.foundry376.com/2008/07/scaling-a-cgimage/#comment-200
// create context, keeping original image properties
Expand All @@ -688,15 +686,21 @@ CreateCGImageFromDrawableRect(
CGImageGetAlphaInfo(cg_image));
CGColorSpaceRelease(colorspace);
if (cg_context) {
// draw image to context (resizing it)
// Extract the subimage in the specified rectangle.
CGImageRef subimage = CGImageCreateWithImageInRect(cg_image, rect);
// Draw the subimage in our context (resizing it to fit).
CGContextDrawImage(cg_context, CGRectMake(0, 0, width, height),
cg_image);
// extract resulting image from context
subimage);
// We will return the image we just drew.
result = CGBitmapContextCreateImage(cg_context);
CGContextRelease(cg_context);
CGImageRelease(subimage);
}
CGImageRelease(cg_image);
} else {
// No resizing is needed. Just return the subimage
result = CGImageCreateWithImageInRect(cg_image, rect);
}
CGImageRelease(cg_image);
}
return result;
}
Expand Down

0 comments on commit 66930bd

Please sign in to comment.