Skip to content

[Tree/Table Image] The item image is wrongly scaled with Eclipse 4.36 #3050

Closed

Description

@wolfgang-ch

When switching from Eclipse 4.35 to 4.36 then the tree and table images are wrongly scaled when creating an image with org.eclipse.swt.graphics.Image.Image(Device, ImageDataProvider) which was suggested in eclipse-platform/eclipse.platform.swt#1411 (comment)

In this example, the app is running with -Dswt.autoScale=200 which works with Eclipse 4.35 but with Eclipse 4.36 the image bounds is doubled

Image

After debugging I found the code where the scaling returns the wrong values

Image

Activity

  1. HeikoKlare commented on Jun 18, 2025

    @HeikoKlare
    Contributor

    That definitely looks incorrect. Still, could you try running without -Dswt.autoScale=200 or with disabled monitor-specific scaling (https://eclipse.dev/eclipse/markdown/?f=news/4.36/platform.md#monitor-specific-ui-scaling-as-default-windows-only)? I guess it's a problematic interaction of those two options.

  2. wolfgang-ch commented on Jun 19, 2025

    @wolfgang-ch
    ContributorAuthor

    It looks like that Eclipse 4.36 is doing some scaling even when -Dswt.autoScale is turned off.

    Because this app is an RCP app, there is no option to disable monitor scaling like in https://eclipse.dev/eclipse/markdown/?f=news/4.36/platform.md#monitor-specific-ui-scaling-as-default-windows-only

    Image Image Image
  3. HeikoKlare commented on Jun 19, 2025

    @HeikoKlare
    Contributor

    Thank you for the additional information! May I first ask why you want to use -Dswt.autoScale=200 instead of using ordinary auto-scaling of Eclipse/SWT at all?

    Some more remarks on this:

    Auto-Scaling

    It looks like that Eclipse 4.36 is doing some scaling even when -Dswt.autoScale is turned off.

    That depends on what you mean by "-Dswt.autoScale is turned off". If you mean that you do not specify that property then, yes, Eclipse does autoscaling without such property. But that has been the case for many years already. Auto-scaling enabled is default for Eclipse for many years. If you want to disable it, you need to define -Dswt.autoScale=false. Actually, the specification of -Dswt.autoScale=200 is a bit weird because it actually does not do any auto-scaling but does not non-auto scaling, as it fixes the scaling to a specific value (so it's not "auto").

    Because this app is an RCP app, there is no option to disable monitor scaling like in https://eclipse.dev/eclipse/markdown/?f=news/4.36/platform.md#monitor-specific-ui-scaling-as-default-windows-only

    Have you disabled the accoring preference page? Otherwise it should still show up there. And you can still disable the option, either by specifying the prefence programatically (see here how the preference is evaluated) or, even more simple, you can add -Dswt.autoScale.updateOnRuntime=false.

    ImageDataProvider

    Finally, having taken another look at your screenshots, I see that you are using some NoAutoScalingImageDataProvider. I am not aware of such a class in the SDK, so it's probably a class that you have implemented on your own? That one seems to contain a single image data object and, based on the observed behavior and the debugger values, I guess it will return that image data for every zoom. That is actually wrong. There is the assumption at several places in the code that the image data provided by an image for different zoom values is linearly scaled according to the zoom. In this case, the image will probably yield data of the same size for, e.g., both 100% and 200% zoom. So you probably have some 200% image data in there (indicated by the size of 32x32 pixels), which you also return as the 100% image data.
    The 100% data is the basis for calculating getBounds(). As a consequence, getBounds() returns (32, 32), which is then scaled up to (64, 64). It seems like this accidentially worked by now, but stopped working because of the Image class having been heavily revised in the previous release, which also included a revision of how getBounds() works.

    So I my assumptions are right, the concrete advise here would be to revise the NoAutoScalingImageDataProvider. If there is only image data for 200% available, you may only return it for that exact zoom level and null for the others (but then it's obviously no NoAutoScalingImageDataProvider anymore, so you should probably rename it). Unfortunately, there is currently the requirement for always returning image data for zoom level 100 (even if you only need the data at 200), so you could provide some dummy data of proper size (maybe just _imageData.scaledTo(_imageData.width / 2, _imageData.height / 2), in case you don't have proper 100% data available.

  4. wolfgang-ch commented on Jun 19, 2025

    @wolfgang-ch
    ContributorAuthor

    May I first ask why you want to use -Dswt.autoScale=200 instead of using ordinary auto-scaling of Eclipse/SWT at all?

    Since I have a 4k monitor, Eclipse and my RCP app were tooooo tiny, so I'm scaling these apps with this parameter, until now I worked with Eclipse 4.31 but will move now to 4.36

    That depends on what you mean by "-Dswt.autoScale is turned off".

    I just have "disabled" it with xxx to -Dxxxswt.autoScale=200 in my launch config

    Have you disabled the accoring preference page? Otherwise it should still show up there.

    Maybe, I started this app 20 years ago and may have disabled this page sometimes but I cannot remember

    So I my assumptions are right, the concrete advise here would be to revise the NoAutoScalingImageDataProvider.

    I will try to fix my NoAutoScalingImageDataProvider which bugs you have correctly identified 👍 😄

    Many thanks for your very helpful advise

  5. HeikoKlare commented on Jun 19, 2025

    @HeikoKlare
    Contributor

    You're welcome 🙂 Happy to hear back if you could solve the issue by adapting the image data provider or if there is still something that can / needs to be done in Eclipse/SWT.

  6. wolfgang-ch commented on Jun 19, 2025

    @wolfgang-ch
    ContributorAuthor

    You're welcome 🙂 Happy to hear back if you could solve the issue by adapting the image data provider or if there is still something that can / needs to be done in Eclipse/SWT.

    I'll do so

    It may had helped me when your above advise would also be documented in the javadoc of the imageDataProvider parameter in org.eclipse.swt.graphics.Image.Image(Device, ImageDataProvider)

    I forgot a link to my ImageDataProvider which is currently very simple https://github.com/mytourbook/mytourbook/blob/main/bundles/net.tourbook.common/src/net/tourbook/common/util/NoAutoScalingImageDataProvider.java

  7. HeikoKlare commented on Jun 19, 2025

    @HeikoKlare
    Contributor

    It may had helped me when your above advise would also be documented in the javadoc of the imageDataProvider parameter in org.eclipse.swt.graphics.Image.Image(Device, ImageDataProvider)

    Yes, valid point. We will check that. It may also be part of the documentation of ImageDataProvider itself.
    We currently have some follow-up work on issues with images whose image data is not linearly scaled according to zoom anyway, such as:

    This was all less problematic "back then" when there was only a single zoom throughout application lifecycle, but now becomes an issue with the monitor-specific scaling feature as the zoom changes depending on the monitor your controls are currently placed on.

  8. wolfgang-ch commented on Jun 20, 2025

    @wolfgang-ch
    ContributorAuthor

    I did a quick fix with your advise in https://github.com/mytourbook/mytourbook/blob/6d5e6929f178f0069d096793a2c911ea2b3ba506/bundles/net.tourbook.common/src/net/tourbook/common/util/NoAutoScalingImageDataProvider.java#L61 , now these images will be displayed like it was before Eclipse 4.36 😄

    I found further image issues in my app with Eclipse 4.36 but first I have to understand these complex image issues before I can blame Eclipse or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions