Skip to content

Commit 60ef7e9

Browse files
committed
[MacOS] Fix width/height of Images created via ImageGcDrawer
The current implementation of the Image constructor accepting an ImageGcDrawer does initialize the image with the given width and height but extracts them from the image data being initialized with the ImageGcDrawer. This does not take the current device zoom into account properly, leading to images unexpectedly being rendered for 100% scaling while they are supposed to be used at 200% scaling. With this change, images are properly initialized with the given width and height and using the according device zoom for the image data generation, leading to a sharp initialization also on 200% monitors. Serves as a fix for the MacOS part of issue eclipse-platform/eclipse.platform.ui#2740
1 parent ffa1084 commit 60ef7e9

File tree

1 file changed

+3
-1
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,9 @@ public Image(Device device, ImageGcDrawer imageGcDrawer, int width, int height)
872872
super(device);
873873
if (imageGcDrawer == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
874874
this.imageGcDrawer = imageGcDrawer;
875-
ImageData data = drawWithImageGcDrawer(imageGcDrawer, width, height, 100);
875+
this.width = width;
876+
this.height = height;
877+
ImageData data = drawWithImageGcDrawer(imageGcDrawer, width, height, DPIUtil.getDeviceZoom());
876878
if (data == null) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
877879
NSAutoreleasePool pool = null;
878880
if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();

0 commit comments

Comments
 (0)