diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/DPIUtil.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/DPIUtil.java index 0f08710d468..ba8e721d5fb 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/DPIUtil.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/DPIUtil.java @@ -631,7 +631,19 @@ public static boolean useCairoAutoScale() { return useCairoAutoScale; } +public static int getZoomForMenuItemImage(int nativeDeviceZoom) { + String autoScaleValueForMenuItemImage = DPIUtil.autoScaleValue; + if(autoScaleValueForMenuItemImage.equals("quarter") || autoScaleValueForMenuItemImage.equals("exact")) { + autoScaleValueForMenuItemImage = "half"; + } + return getZoomForAutoscaleProperty(nativeDeviceZoom, autoScaleValueForMenuItemImage); +} + public static int getZoomForAutoscaleProperty (int nativeDeviceZoom) { + return getZoomForAutoscaleProperty(nativeDeviceZoom, autoScaleValue); +} + +private static int getZoomForAutoscaleProperty (int nativeDeviceZoom, String autoScaleValue) { int zoom = 0; if (autoScaleValue != null) { if ("false".equalsIgnoreCase (autoScaleValue)) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java index 1729a2a9a43..543419b6311 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java @@ -782,7 +782,15 @@ public void setImage (Image image) { } else { if (OS.IsAppThemed ()) { if (hBitmap != 0) OS.DeleteObject (hBitmap); - info.hbmpItem = hBitmap = image != null ? Display.create32bitDIB (image, getZoom()) : 0; + int desiredSize = getSystemMetrics(72); + int zoom = (int) (((double) desiredSize / image.getBounds().height) * 100); + int currentSize = image.getImageData(zoom).height; + while(currentSize == desiredSize) { + zoom--; + currentSize = image.getImageData(zoom).height; + } + zoom++; + info.hbmpItem = hBitmap = image != null ? Display.create32bitDIB (image, zoom) : 0; } else { info.hbmpItem = image != null ? OS.HBMMENU_CALLBACK : 0; }