Skip to content

Commit f59f98a

Browse files
ShahzaibIbrahimHeikoKlare
authored andcommitted
Win32: Use native monitor zoom for menu item image scaling
On Win32, the OS paints MenuItem images using sizes defined by SM_CXMENUCHECK / SM_CYMENUCHECK. If images are not provided at these metrics-specific sizes, Windows rescales them, causing unexpected sizes and alpha channel issues. In getMenuItemIconSelectedBitmapHandle, adaptZoomForMenuItem was called which returns a fixed scaled value from getZoom() when fix autoScale value is provided e.g. 250 instead of the current monitor's native zoom (150). This caused the OS to perform additional scaling. Updated code to call adaptZoomForMenuItem(nativeZoom, image) so that the image is prepared for the actual monitor zoom, avoiding unnecessary OS scaling and preserving alpha channel integrity.
1 parent 8838c9d commit f59f98a

File tree

1 file changed

+2
-2
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets

1 file changed

+2
-2
lines changed

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ private long getMenuItemIconBitmapHandle(Image image) {
896896
return 0;
897897
}
898898
if (hBitmap != 0) OS.DeleteObject (hBitmap);
899-
int zoom = adaptZoomForMenuItem(getZoom(), image);
899+
int zoom = adaptZoomForMenuItem(nativeZoom, image);
900900
return Display.create32bitDIB (image, zoom);
901901
}
902902

@@ -906,7 +906,7 @@ private long getMenuItemIconSelectedBitmapHandle() {
906906
return 0;
907907
}
908908
if (hBitmapSelected != 0) OS.DeleteObject (hBitmapSelected);
909-
int zoom = adaptZoomForMenuItem(getZoom(), image);
909+
int zoom = adaptZoomForMenuItem(nativeZoom, image);
910910
return hBitmapSelected = Display.create32bitDIB (image, zoom);
911911
}
912912

0 commit comments

Comments
 (0)