Skip to content

Suppress warnings for getImageDataAtCurrentZoom() #1938

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

elsazac
Copy link
Member

@elsazac elsazac commented Mar 24, 2025

This PR adds suppression for deprecation warnings related to getImageDataAtCurrentZoom() in the ClipboardExample code.

Copy link
Contributor

github-actions bot commented Mar 24, 2025

Test Results

   539 files  ±0     539 suites  ±0   27m 53s ⏱️ - 4m 47s
 4 330 tests ±0   4 320 ✅ ±0    9 💤 ±0  1 ❌ ±0 
16 579 runs  ±0  16 477 ✅ ±0  101 💤 ±0  1 ❌ ±0 

For more details on these failures, see this check.

Results for commit 4f8a6ac. ± Comparison against base commit fbdacfb.

♻️ This comment has been updated with latest results.

@elsazac
Copy link
Member Author

elsazac commented Mar 28, 2025

I’d like to proceed with merging this if there are no objections

Copy link
Contributor

@HeikoKlare HeikoKlare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am bit hestitant with respect to this change, as this is example code which is supposed to show how to use something, but using a deprecated method is obviously nothing one should do. On the other hand, I do currently not have a better solution (except passing DPIUtil.getDeviceZoom() to the ordinary getImageData()).

This seems to be one the last usage of the getImageAtCurrentZoom() method (except for a test method), so in my opinion we should rather try to get rid of it.
@akoch-yatta do you have an idea how to properly get rid of the getImageDataAtCurrentZoom() here?

@sratz
Copy link
Member

sratz commented Mar 28, 2025

I do currently not have a better solution (except passing DPIUtil.getDeviceZoom() to the ordinary getImageData()).

Isn't that the perfect solution for such an example?

  • It avoids deprecated API
  • It shows the complexity of high DPI handling
  • It explains how to get the the current device's zoom using proper API

@HeikoKlare
Copy link
Contributor

There are two problems with that approach:

  • DPIUtil is internal and not supposed to be used outside SWT. The whole auto-scaling concept is supposed to be SWT-internal.
  • DPIUtil.getDeviceZoom() does not have a proper meaning once monitor-specific scaling is used (as now provided for Windows). You then have to consider the context-dependent zoom.

In this case, it's about retrieving image data in some zoom that did not apply any auto-scaling as via clipboard you cannot pass a proper image with according metadata but only the image data for some specific zoom, so they should have the best available quality. But you may have images that can provide image data in any zoom of best quality (like those rendered from SVGs). Since you don't know where data from a clipboard will be used, you can only use some data in a best-effort manner.

Maybe, in the case where you really want to paste some image data into the clipboard, the best would even be to avoid any auto-scaling and just use the data at 100%, so calling getImageData(100) or just getImageData().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants