-
Notifications
You must be signed in to change notification settings - Fork 184
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.autoScale
is 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.
Metadata
Metadata
Assignees
Labels
WindowsHappens on Windows OSHappens on Windows OSregressionSomething that used to workSomething that used to work