diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/ImageTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/ImageTransfer.java index b80c8518842..4acd5730978 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/ImageTransfer.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/ImageTransfer.java @@ -184,7 +184,7 @@ public Object nativeToJava(TransferData transferData) { pSourceBits -= scanline; } } - Image image = Image.win32_new(null, SWT.BITMAP, memDib); + Image image = Image.win32_new(null, SWT.BITMAP, memDib, DPIUtil.getNativeDeviceZoom()); ImageData data = image.getImageData (DPIUtil.getDeviceZoom ()); OS.DeleteObject(memDib); image.dispose(); diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java index 9cd86e1f607..46419173a90 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java @@ -1210,6 +1210,7 @@ public class OS extends C { public static final int SHADEBLENDCAPS = 120; public static final int SHGFI_ICON = 0x000000100; public static final int SHGFI_SMALLICON= 0x1; + public static final int SHGFI_LARGEICON= 0x0; public static final int SHGFI_USEFILEATTRIBUTES = 0x000000010; public static final int SIGDN_FILESYSPATH = 0x80058000; public static final int SIF_ALL = 0x17; diff --git a/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java b/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java index a5d483c30fb..1ea329e996a 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java @@ -19,7 +19,6 @@ import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; -import org.eclipse.swt.internal.*; import org.eclipse.swt.internal.win32.*; import org.eclipse.swt.widgets.*; @@ -382,16 +381,21 @@ public ImageData getImageData () { public ImageData getImageData (int zoom) { // Windows API returns image data according to primary monitor zoom factor // rather than at original scaling - int nativeZoomFactor = 100 * Display.getCurrent().getPrimaryMonitor().getZoom() / DPIUtil.getDeviceZoom(); - int imageZoomFactor = 100 * zoom / nativeZoomFactor; + int initialNativeZoom = Display.getCurrent().getPrimaryMonitor().getZoom(); if (extension != null) { SHFILEINFO shfi = new SHFILEINFO (); - int flags = OS.SHGFI_ICON | OS.SHGFI_SMALLICON | OS.SHGFI_USEFILEATTRIBUTES; + int flags = OS.SHGFI_ICON | OS.SHGFI_USEFILEATTRIBUTES; + if(zoom > initialNativeZoom) { + flags |= OS.SHGFI_LARGEICON; + initialNativeZoom *= 2; + } else { + flags |= OS.SHGFI_SMALLICON; + } TCHAR pszPath = new TCHAR (0, extension, true); OS.SHGetFileInfo (pszPath.chars, OS.FILE_ATTRIBUTE_NORMAL, shfi, SHFILEINFO.sizeof, flags); if (shfi.hIcon != 0) { - Image image = Image.win32_new (null, SWT.ICON, shfi.hIcon); - ImageData imageData = image.getImageData (imageZoomFactor); + Image image = Image.win32_new (null, SWT.ICON, shfi.hIcon, initialNativeZoom); + ImageData imageData = image.getImageData (zoom); image.dispose (); return imageData; } @@ -416,8 +420,8 @@ public ImageData getImageData (int zoom) { long [] phiconSmall = new long[1], phiconLarge = null; OS.ExtractIconEx (lpszFile, nIconIndex, phiconLarge, phiconSmall, 1); if (phiconSmall [0] == 0) return null; - Image image = Image.win32_new (null, SWT.ICON, phiconSmall [0]); - ImageData imageData = image.getImageData (imageZoomFactor); + Image image = Image.win32_new (null, SWT.ICON, phiconSmall [0], initialNativeZoom); + ImageData imageData = image.getImageData (zoom); image.dispose (); return imageData; } 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 dfc5c0ee001..61409bdff38 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 @@ -127,8 +127,12 @@ public final class Image extends Resource implements Drawable { * Prevents uninitialized instances from being created outside the package. */ Image (Device device) { + this(device, DPIUtil.getNativeDeviceZoom()); +} + +private Image (Device device, int nativeZoom) { super(device); - initialNativeZoom = DPIUtil.getNativeDeviceZoom(); + initialNativeZoom = nativeZoom; this.device.registerResourceWithZoomSupport(this); } @@ -2030,10 +2034,10 @@ public String toString () { * * @noreference This method is not intended to be referenced by clients. */ -public static Image win32_new(Device device, int type, long handle) { - Image image = new Image(device); +public static Image win32_new(Device device, int type, long handle, int nativeZoom) { + Image image = new Image(device, nativeZoom); image.type = type; - image.new ImageHandle(handle, image.getZoom()); + image.new ImageHandle(handle, nativeZoom); return image; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java index 100b47e6daf..843312047af 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java @@ -1203,7 +1203,7 @@ static Image createIcon (Image image, int zoom) { if (hIcon == 0) SWT.error(SWT.ERROR_NO_HANDLES); OS.DeleteObject (hBitmap); OS.DeleteObject (hMask); - return Image.win32_new (device, SWT.ICON, hIcon); + return Image.win32_new (device, SWT.ICON, hIcon, zoom); } long getTextSearchIcon(int size) { @@ -2542,27 +2542,28 @@ Font getSystemFont (int zoom) { */ public Image getSystemImage (int id) { checkDevice (); + int primaryMonitorNativeZoom = getPrimaryMonitor().getZoom(); switch (id) { case SWT.ICON_ERROR: { if (errorImage != null) return errorImage; long hIcon = OS.LoadImage (0, OS.OIC_HAND, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED); - return errorImage = Image.win32_new (this, SWT.ICON, hIcon); + return errorImage = Image.win32_new (this, SWT.ICON, hIcon, primaryMonitorNativeZoom); } case SWT.ICON_WORKING: case SWT.ICON_INFORMATION: { if (infoImage != null) return infoImage; long hIcon = OS.LoadImage (0, OS.OIC_INFORMATION, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED); - return infoImage = Image.win32_new (this, SWT.ICON, hIcon); + return infoImage = Image.win32_new (this, SWT.ICON, hIcon, primaryMonitorNativeZoom); } case SWT.ICON_QUESTION: { if (questionImage != null) return questionImage; long hIcon = OS.LoadImage (0, OS.OIC_QUES, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED); - return questionImage = Image.win32_new (this, SWT.ICON, hIcon); + return questionImage = Image.win32_new (this, SWT.ICON, hIcon, primaryMonitorNativeZoom); } case SWT.ICON_WARNING: { if (warningIcon != null) return warningIcon; long hIcon = OS.LoadImage (0, OS.OIC_BANG, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED); - return warningIcon = Image.win32_new (this, SWT.ICON, hIcon); + return warningIcon = Image.win32_new (this, SWT.ICON, hIcon, primaryMonitorNativeZoom); } } return null; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskBar.java index 3d2d1443628..0e7084da9a0 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskBar.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskBar.java @@ -166,7 +166,7 @@ IShellLink createShellLink (MenuItem item) { ImageData data; if (item.hBitmap != 0) { long handle = OS.CopyImage(item.hBitmap, SWT.BITMAP, 0, 0, 0); - Image image2 = Image.win32_new (display, SWT.BITMAP, handle); + Image image2 = Image.win32_new (display, SWT.BITMAP, handle, nativeZoom); data = image2.getImageData (DPIUtil.getDeviceZoom ()); image2.dispose(); } else {