eclipse.platform.swt icon indicating copy to clipboard operation
eclipse.platform.swt copied to clipboard

Suppress warnings for getImageDataAtCurrentZoom()

Open elsazac opened this issue 9 months ago • 4 comments

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

elsazac avatar Mar 24 '25 18:03 elsazac

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 4f8a6acb. ± Comparison against base commit fbdacfbb.

:recycle: This comment has been updated with latest results.

github-actions[bot] avatar Mar 24 '25 18:03 github-actions[bot]

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

elsazac avatar Mar 28 '25 06:03 elsazac

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

sratz avatar Mar 28 '25 10:03 sratz

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().

HeikoKlare avatar Mar 28 '25 11:03 HeikoKlare

This became obsolete as the usage of getImageDataAtCurrentZoom() has been replaced with:

  • https://github.com/eclipse-platform/eclipse.platform.swt/pull/2158

HeikoKlare avatar Jul 24 '25 10:07 HeikoKlare