Fixing transparency on scaled variant of cursor with source and mask #2562
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When creating a custom cursor using source and mask ImageData, the transparency mask does not scale correctly when applying DPIUtil.autoScaleImageData() in a multi-monitor setup with different DPI settings. With this change we use scaleTo method to scale the data.
How to test
Run the
Snippet386
with following VM argumentsOn 100% monitor zoom, choose the
Cursor(Device, ImageData, ImageData, int, int)
option from the dropdownYou will see the dotted square (a transparent pixel after each solid pixel)
Move the shell to another monitor with different zoom e.g. 150%
Previously you would lose the transparency completely when it was scaled with
DPIUtil.scaleImageData
Comparison of mask data before and after scaling with and without this PR
Before
After:
P.S: With this change we will not get smooth scaling for the cursor created with source and mask data. That's why we will deprecate the Cursor(Device, ImageData, ImageData, int, int) constructor in another PR, see vi-eclipse/Eclipse-Platform#462. Instead, we will recommend using: Cursor(Device device, ImageDataProvider imageDataProvider, int hotspotX, int hotspotY) as this provides better results with multi-monitor DPI scaling.