diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java index 1e48a77a51d..e2d8c831cc1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java @@ -1253,7 +1253,7 @@ private void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int src } return; } - long imageHandle = Image.win32_getHandle(srcImage, imageZoom); + long imageHandle = srcImage.getHandle(imageZoom, data.nativeZoom); switch (srcImage.type) { case SWT.BITMAP: drawBitmap(srcImage, imageHandle, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple); @@ -4384,7 +4384,7 @@ private void init(Drawable drawable, GCData data, long hDC) { } Image image = data.image; if (image != null) { - data.hNullBitmap = OS.SelectObject(hDC, Image.win32_getHandle(image, data.nativeZoom)); + data.hNullBitmap = OS.SelectObject(hDC, image.getHandle(data.imageZoom, data.nativeZoom)); image.memGC = this; } int layout = data.layout; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GCData.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GCData.java index 0f313b30559..9e22aab2a42 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GCData.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GCData.java @@ -48,6 +48,7 @@ public final class GCData { public float lineMiterLimit = 10; public int alpha = 0xFF; public int nativeZoom; + int imageZoom; public Image image; public PAINTSTRUCT ps; @@ -67,6 +68,7 @@ void copyTo(GCData originalData) { originalData.font = font; originalData.nativeZoom = nativeZoom; originalData.image = image; + originalData.imageZoom = imageZoom; originalData.ps = ps; originalData.layout = layout; originalData.hwnd = hwnd; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java index ccec341525b..34cbb56f840 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java @@ -809,10 +809,15 @@ private ImageHandle getImageMetadata(ZoomContext zoomContext) { * @noreference This method is not intended to be referenced by clients. */ public static long win32_getHandle (Image image, int zoom) { - if (image.isDisposed()) { + return image.getHandle(zoom, zoom); +} + +long getHandle (int targetZoom, int nativeZoom) { + if (isDisposed()) { return 0L; } - return image.getImageMetadata(new ZoomContext(zoom)).handle; + ZoomContext zoomContext = imageProvider.getFittingZoomContext(targetZoom, nativeZoom); + return getImageMetadata(zoomContext).handle; } /** @@ -1752,6 +1757,7 @@ private long configureGC(GCData data, ZoomContext zoomContext) { } data.device = device; data.nativeZoom = zoomContext.nativeZoom(); + data.imageZoom = zoomContext.targetZoom(); data.image = this; data.font = SWTFontProvider.getSystemFont(device, zoomContext.nativeZoom()); } @@ -1913,6 +1919,10 @@ private abstract class AbstractImageProviderWrapper { protected abstract Rectangle getBounds(int zoom); + protected ZoomContext getFittingZoomContext(int targetZoom, int nativeZoom) { + return new ZoomContext(targetZoom); + } + protected long configureGCData(GCData data) { return configureGC(data, new ZoomContext(100)); } @@ -2138,6 +2148,14 @@ private class PlainImageProviderWrapper extends AbstractImageProviderWrapper { type = SWT.BITMAP; } + @Override + protected ZoomContext getFittingZoomContext(int targetZoom, int nativeZoom) { + if (memGC != null) { + return new ZoomContext(targetZoom, nativeZoom); + } + return super.getFittingZoomContext(targetZoom, nativeZoom); + } + @Override public Collection getPreservedZoomLevels() { return Collections.singleton(baseZoom); @@ -2145,7 +2163,7 @@ public Collection getPreservedZoomLevels() { @Override protected long configureGCData(GCData data) { - return configureGC(data, new ZoomContext(DPIUtil.getDeviceZoom())); + return configureGC(data, new ZoomContext(DPIUtil.getDeviceZoom(), DPIUtil.getNativeDeviceZoom())); } @Override @@ -2577,6 +2595,11 @@ private class ImageGcDrawerWrapper extends DynamicImageProviderWrapper { this.height = height; } + @Override + protected ZoomContext getFittingZoomContext(int targetZoom, int nativeZoom) { + return new ZoomContext(targetZoom, nativeZoom); + } + @Override protected Rectangle getBounds(int zoom) { Rectangle rectangle = new Rectangle(0, 0, width, height);