Skip to content

Commit 283a67c

Browse files
committed
[win32] Foward native zoom to draw bitmap in GC
This commit adapts the logic when a bitmap or icon is drawn with the GC in the windows implementation. As of now, the autoscale zoom was used to identify the image handle to use. If the image is itself drawn with a ImageGCDrawer, information about the original native zoom was lost, which led to inconsistencies in fonts depending on the auto scale mode. This commit fowards the native zoom in this case to enable the Image to initialize the GC accordingly. fixes #2385
1 parent 4d34234 commit 283a67c

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,7 @@ private void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int src
12531253
}
12541254
return;
12551255
}
1256-
long imageHandle = Image.win32_getHandle(srcImage, imageZoom);
1256+
long imageHandle = srcImage.getHandle(imageZoom, data.nativeZoom);
12571257
switch (srcImage.type) {
12581258
case SWT.BITMAP:
12591259
drawBitmap(srcImage, imageHandle, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple);

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,13 @@ public static long win32_getHandle (Image image, int zoom) {
835835
return image.getImageMetadata(new ZoomContext(zoom)).handle;
836836
}
837837

838+
long getHandle (int targetZoom, int nativeZoom) {
839+
if (isDisposed()) {
840+
return 0L;
841+
}
842+
return getImageMetadata(new ZoomContext(targetZoom, nativeZoom)).handle;
843+
}
844+
838845
/**
839846
* <b>IMPORTANT:</b> This method is not part of the public
840847
* API for Image. It is marked public only so that it
@@ -2312,7 +2319,7 @@ protected ImageHandle newImageHandle(ZoomContext zoomContext) {
23122319

23132320
private ImageHandle initializeHandleFromSource(int zoom) {
23142321
ElementAtZoom<ImageData> imageDataAtZoom = loadImageData(zoom);
2315-
ImageData imageData = DPIUtil.scaleImageData (device,imageDataAtZoom.element(), zoom, imageDataAtZoom.zoom());
2322+
ImageData imageData = DPIUtil.scaleImageData (device, imageDataAtZoom.element(), zoom, imageDataAtZoom.zoom());
23162323
imageData = adaptImageDataIfDisabledOrGray(imageData);
23172324
return init(imageData, zoom);
23182325
}

0 commit comments

Comments
 (0)