Skip to content

Commit 5378162

Browse files
HeikoKlareclaude
andcommitted
[Cocoa] Fix copyArea(Image,int,int) ignoring scale factor in Y translation
Bug: When copying an area from a GC backed by a source image into a destination image of different height on a HiDPI display (zoom > 100%), the wrong portion of the source image is copied into the destination. Root cause: The NSAffineTransform translation used to position the drawing within the bitmap context created from the destination image representation was computed in logical point units, while the bitmap context's coordinate space operates in physical pixel units. The destination rect dimensions (destRect.width, destRect.height) were already correctly scaled by scaleFactor, but the translation was not. The fix applies the same scaleFactor to the translation, making it consistent with the rest of the pixel-space coordinate calculations. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 108533e commit 5378162

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

  • bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics

bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ public void copyArea(Image image, int x, int y) {
539539
NSGraphicsContext.setCurrentContext(context);
540540
NSAffineTransform transform = NSAffineTransform.transform();
541541
NSSize size = image.handle.size();
542-
transform.translateXBy(0, size.height-(destHeight + 2 * destY));
542+
transform.translateXBy(0, (size.height - (destHeight + 2 * destY)) * scaleFactor);
543543
transform.concat();
544544
NSRect srcRect = new NSRect();
545545
srcRect.x = srcX;

0 commit comments

Comments
 (0)