Skip to content

"Smooth" scaling produces blurry images after calling image.getImageData().clone() #2052

Closed
@tobiasmelcher

Description

@tobiasmelcher

Steps to reproduce

From a fresh installation and clean workspace:

  • download the attached sample plugin, extract it, import into workspace and run target platform
    simple.zip
  • open the "Sample view" provided by the simple plugin in the target platform
  • icons in the tree viewer are blurry and not sharp
    Image

Images are no longer blurry after disabling the setting "Use monitor-specific UI scaling" (https://eclipse.dev/eclipse/news/4.36/platform.html#rescaleOnRuntimePreference)

The image is created via following code:

if (cachedElement == null) {
  String imageKey = ISharedImages.IMG_OBJ_ELEMENT;
  cachedElement = workbench.getSharedImages().getImage(imageKey);
}
ImageData imageData = (ImageData) cachedElement.getImageData().clone();
cachedElement = new Image(Display.getCurrent(), imageData);

It looks like that data is lost when calling new Image(Display.getCurrent(), image.getImageData().clone()); when "Use monitor-specific UI scaling" is enabled.

Could you please help in fixing this issue?

Thanks a lot,
Tobias

Tested under this environment:

  • OS & version: Windows 11 - DPIUtil#deviceZoom has value 200

Workarounds

  1. Use the nearest algorithm to scale images by setting this JVM flag: -Dswt.autoScale.method=nearest. The results are not optimal but they are not blurry.
  1. Use the constructor that takes a source Image instead of the one that takes the ImageData.
...
cachedFolder = new Image(cachedFolder.getDevice(), cachedFolder, SWT.IMAGE_COPY);
return cachedFolder;

Community

  • I understand reporting an issue to this OSS project does not mandate anyone to fix it. Other contributors may consider the issue, or not, at their own convenience. The most efficient way to get it fixed is that I fix it myself and contribute it back as a good quality patch to the project.

Metadata

Metadata

Assignees

Labels

HiDPIIssues related to High resolution monitorsWindowsHappens on Windows OSbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions