Repository navigation
[Win] Images in MenuItems are scaled incorrectly when autoscaling is disabled #2537
Copy link
Copy link
Closed
Labels
WindowsHappens on Windows OSHappens on Windows OSregressionSomething that used to workSomething that used to work
Description
Describe the bug
With the release of SWT R4_37 the Windows zoom level causes (bitmap) images to be upscaled though swt.autoScale had been set to false.
To Reproduce
- run this snippet on a Windows with a monitor scaling set to >100% (modify the path to a small image):
import java.io.*;
import java.nio.file.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;
public class MenuItemImageTest {
public static void main(String[] args) throws IOException {
System.setProperty("swt.autoScale", "false");
final Display display = new Display();
try {
final ImageData imageData;
try (InputStream inputStream = Files.newInputStream(Paths.get("src/main/resources/images/smartgit/open-submodule-2.png"))) {
imageData = new ImageData(inputStream);
}
final Image image = new Image(display, imageData);
final Shell shell = new Shell(display);
final Menu menu = new Menu(shell, SWT.POP_UP);
shell.setMenu(menu);
createMenuItem(SWT.PUSH, "Push", image, menu);
createMenuItem(SWT.CHECK, "Unselected Check", image, menu);
createMenuItem(SWT.CHECK, "Slected Check", image, menu).setSelection(true);
shell.addListener(SWT.Paint, event -> event.gc.drawImage(image, 0, 0));
shell.setSize(500, 400);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
finally {
display.dispose();
}
}
private static MenuItem createMenuItem(int style, String text, Image image, Menu menu) {
final MenuItem menuItem = new MenuItem(menu, style);
menuItem.setText(text);
menuItem.setImage(image);
return menuItem;
}
}- right-click to open a context menu
=> Results:
- the painted image is not scaled (correct)
- the image of the SWT.PUSH MenuItem is scaled incorrectly
- the image of the unchecked SWT.CHECK MenuItem is scaled incorrectly
- the image of the selected SWT.CHECK MenuItem is not scaled
- a checkmark is drawn onto the image of the SWT.CHECK MenuItem (incorrect)
2)-5) are regressions
Expected behavior
- if
swt.autoScaleis set totrue, scaling must not happen at all - no checkmark must be drawn onto an image (we solve it in our applications by using different images)
Screenshots
Windows 11 with 150% zoom.

Environment:
- Select the platform(s) on which the behavior is seen:
-
- All OS
-
- Windows
-
- Linux
-
- macOS
-
Additional OS info (e.g. OS version, Linux Desktop, etc)
-
JRE/JDK version
Version since
R4_37, still reproducible with the latest master build.
Workaround (or) Additional context
Workaround: Use SWT R4_36.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
WindowsHappens on Windows OSHappens on Windows OSregressionSomething that used to workSomething that used to work
Activity
HeikoKlare commentedon Sep 24, 2025
Thank you for the report.
Seems like this was introduced with:
We will have a look.
Why is that incorrect? https://eclipse.dev/eclipse/markdown/?f=news/4.37/platform.md#toggle-indicator-in-windows-11-menus
Note that another workaround is of course to use auto-scaling.
[-][Win] Images in MenuItems are scaled incorrectly (regression in R4_37)[/-][+][Win] Images in MenuItems are scaled incorrectly when autoscaling is disabled[/+]tmssngr commentedon Sep 24, 2025
I consider it a regression because it changes the default behavior. However, setting the system property is a viable option for me.
Disabling the autoscaling on Windows is our workaround to fix asymmetric drawing - see #1596. The asymmetric drawing results would not be accepted by our customers.
HeikoKlare commentedon Sep 25, 2025
Well, the regresison was that Windows 11 did not show any selection indicators anymore and that was the fix for it. If you call a fix for a bug a regression w.r.t. the broken state before then, yes, this is a regression. But I don't think that fits to the common definition it 🙂
Yes, I just wanted to mention that for everyone else who does actually not require disabled auto-scaling.
We currently finalize the work an making controls non auto-scaled on-demand (we already use it for GEF diagrams). This is especially useful for pixel-perfect rendering where you don't want to have auto-scalingin place in general. That will then be the much better fit for you to only disable auto-scaling for the control(s) where you do custom painting and have everything else auto-scaled. It will render the
swt.autoScale=falseoption quite obsolete as you could instead simply disable auto-scaling of the shell if you do not want to anything auto-scaled at all.tmssngr commentedon Sep 25, 2025
That sounds really interesting. I did not dare to ask for that, but I'm happy that other users have this demand, too.
tmssngr commentedon Sep 30, 2025
@amartya4256 Could you please fix this regression (scaling though
System.setProperty("swt.autoScale", "false")has been set)?Maybe adding this first line to
MenuItemwould fix it?HeikoKlare commentedon Sep 30, 2025
We have an item in our backlog for this, but other items currently have higher priority. It will be fixed for the next release, but in particular for M1 there is more urgent stuff to do.
[Win] Images in MenuItems are scaled incorrectly when autoscaling is …
[Win32] Only scale menu item images on monitor-specific scaling eclip…
HeikoKlare commentedon Oct 17, 2025
Note that the changed behavior also effects other auto-scale settings than just the disablement via
false. E.g., just using default behavior (conforming toswt.autoScale=integer200) also changed behavior because menu items were, other than before, scaled according to the menu size instead of the autoscaled zoom value (i.e., either 100% or 200%). In consequence, when disablingmonitor-specific UI scalingin Eclipse products, menu item images were differently scaled then before. This will be fixed with #2648.[Win32] Only scale menu item images on monitor-specific scaling eclip…
[Win32] Only scale menu item images on monitor-specific scaling eclip…