You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"Smooth" scaling produces blurry images after calling image.getImageData().clone() #2052
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
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.
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.
I am testing this and I can reproduce it in Windows 10 too. These details are missing in the bug description:
The images are blurry only if they are first instantiated in a big monitor (e.g. 200%). If the workbench is started in a 100% monitor the images are not blurry
Once the images are blurry, moving them to another monitor doesn't fix the issue.
I am testing with 2 monitors, one at 100% and one at 200%.
I was able to pinpoint the issue: it's the anti-alias that makes the images blurry. I still don't know why is this causing a problem in this particular use-case but commenting out this line in org.eclipse.swt.internal.DPIUtil.autoScaleImageData(Device, ImageData, float) makes the issue go away:
Since we've been doing light-weight M* it's generally the build on Friday that is the build that's contributed. And, given all the infrastructure problems, e.g.,
changed the title [-]Images are getting blurry after calling image.getImageData().clone()[/-][+]"Smooth" scaling produces blurry images.[/+]on Apr 23, 2025
Since we've been doing light-weight M* it's generally the build on Friday that is the build that's contributed. And, given all the infrastructure problems, e.g.,
I just found out that the issue does not come from cloning the ImageData but from using the constructor with the ImageDatai.e. even if you use the original data, images will be blurry.
Said in code:
privateImagegetImage(Objectobj) {
if (objinstanceofTreeParent) {
if (cachedFolder == null) {
StringimageKey = ISharedImages.IMG_OBJ_FOLDER;
cachedFolder = workbench.getSharedImages().getImage(imageKey);
}
// Don't use the constructor with ImageData, use the one with a source Image to copy fromcachedFolder = newImage(cachedFolder.getDevice(), cachedFolder, SWT.IMAGE_COPY);
returncachedFolder;
}
if (cachedElement == null) {
StringimageKey = ISharedImages.IMG_OBJ_ELEMENT;
cachedElement = workbench.getSharedImages().getImage(imageKey);
}
ImageDatasameImageData = (ImageData) cachedElement.getImageData()/*.clone()*/;
// This constructor still produces a blurry image.cachedElement = newImage(Display.getCurrent(), sameImageData);
returncachedElement;
}
After analyzing the provided sample code more in detail, the issue is that the cachedElement and cachedFolder images are generated over and over and this leads to the scaling algorithm being applied several times.
There is probably something that could be done to support these kind of use cases but in the meantime, can you please tell us where does the snippet of code come from @tobiasmelcher ? Is it adapted from code in Platform or is it in your product?
In any case, the code should generated the "original" images only once and, if necessary, produce the "clone" images always based on the original image.
After analyzing the provided sample code more in detail, the issue is that the cachedElement and cachedFolder images are generated over and over and this leads to the scaling algorithm being applied several times.
There is probably something that could be done to support these kind of use cases but in the meantime, can you please tell us where does the snippet of code come from @tobiasmelcher ? Is it adapted from code in Platform or is it in your product?
In any case, the code should generated the "original" images only once and, if necessary, produce the "clone" images always based on the original image.
The code was used in our product ABAP Development Tools in Eclipse. I think we did clone the images by mistake. It was working fine before introduction of the "Monitor-specific UI scaling" feature. I already adapted our code so that the problem does no longer occur. Anyhow, I think that the eclipse behavior changed here in an incompatible way. new Image(Display.getCurrent(), imageData) behaves now different than before.
The code was used in our product ABAP Development Tools in Eclipse.
Thank you for the info, @tobiasmelcher . Good to know that it's not code in Platform, this means that there is no need to adapt any more code.
Anyhow, I think that the eclipse behavior changed here in an incompatible way. new Image(Display.getCurrent(), imageData) behaves now different than before.
Agreed, the behavior changed. Thank you for reporting it!
Activity
HeikoKlare commentedon Apr 14, 2025
Thank you for the report! We will have a look at this.
fedejeanne commentedon Apr 22, 2025
I am testing this and I can reproduce it in Windows 10 too. These details are missing in the bug description:
I am testing with 2 monitors, one at 100% and one at 200%.
fedejeanne commentedon Apr 22, 2025
I was able to pinpoint the issue: it's the anti-alias that makes the images blurry. I still don't know why is this causing a problem in this particular use-case but commenting out this line in
org.eclipse.swt.internal.DPIUtil.autoScaleImageData(Device, ImageData, float)makes the issue go away:eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/DPIUtil.java
Line 303 in 00c6aef
Alternatively, one can use the
nearestalgorithm to scale images by setting this JVM flag:-Dswt.autoScale.method=nearest.I'll add it as a workaround in the description and I will continue to dig deeper tomorrow.
Use auto-scale "nearest" by default in Windows and Mac eclipse-platfo…
Use auto-scale "nearest" by default in Windows eclipse-platform#2910
fedejeanne commentedon Apr 23, 2025
Since today should be the build for M2, I have a workaround in store just in case there is no proper fix in time: #2051
merks commentedon Apr 23, 2025
@akurtakov FYI
Since we've been doing light-weight M* it's generally the build on Friday that is the build that's contributed. And, given all the infrastructure problems, e.g.,
https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/issues/5892
we might well slip into the weekend and contribute a build from Sunday...
[-]Images are getting blurry after calling image.getImageData().clone()[/-][+]"Smooth" scaling produces blurry images.[/+]fedejeanne commentedon Apr 23, 2025
... the silver lining :-D
Thanks Ed!
[-]"Smooth" scaling produces blurry images.[/-][+]"Smooth" scaling produces blurry images after calling image.getImageData().clone()[/+]fedejeanne commentedon Apr 23, 2025
I just found out that the issue does not come from cloning the
ImageDatabut from using the constructor with theImageDatai.e. even if you use the original data, images will be blurry.Said in code:
And it looks like this:
fedejeanne commentedon Apr 23, 2025
After analyzing the provided sample code more in detail, the issue is that the
cachedElementandcachedFolderimages are generated over and over and this leads to the scaling algorithm being applied several times.There is probably something that could be done to support these kind of use cases but in the meantime, can you please tell us where does the snippet of code come from @tobiasmelcher ? Is it adapted from code in Platform or is it in your product?
In any case, the code should generated the "original" images only once and, if necessary, produce the "clone" images always based on the original image.
akoch-yatta commentedon Apr 23, 2025
Btw. after understanding the root cause I tested this issue with #1996 and improves this behavior a lot.
tobiasmelcher commentedon Apr 23, 2025
The code was used in our product ABAP Development Tools in Eclipse. I think we did clone the images by mistake. It was working fine before introduction of the "Monitor-specific UI scaling" feature. I already adapted our code so that the problem does no longer occur. Anyhow, I think that the eclipse behavior changed here in an incompatible way.
new Image(Display.getCurrent(), imageData)behaves now different than before.fedejeanne commentedon Apr 24, 2025
Thank you for the info, @tobiasmelcher . Good to know that it's not code in Platform, this means that there is no need to adapt any more code.
Agreed, the behavior changed. Thank you for reporting it!
[Win32] Ensure consistent image data returned for data-based images
[Win32] Ensure consistent image data returned for data-based images
[Win32] Ensure consistent image data returned for data-based images
[Win32] Ensure consistent image data returned for data-based images
[Win32] Ensure consistent image data returned for data-based images