[Win32] Don't Create a mask image when there is no mask #2657
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.
The initImage() logic used newImageData(new ZoomContext(100)) which created a new handle and retrieved ImageData without the original mask information. For MaskedImageData, this caused the mask to be discarded and made affected images (e.g., shell icons) turn fully invisible.
But why it fails even if we create a fully opaque mask?
That's because of this PR: #1138. Here it is mentioned:
Under certain conditions, program icons loaded on Windows via GDI+ have empty mask data, even though the original icon has proper mask data. As a result, these icons are printed with a black instead of a transparent background. Still these icons can contain valid alpha data in their usual 32-bit data.
But in our case we have a valid image (png) that has no transparency mask and no valid alpha data. As a result it is drawn completely transparent. For our case, I think it's sufficient to think that we don't need to create a mask image at all if there is no transparent (also sounds efficient) and fixes this issue.
Although I would like to open a dialogue on the implementation of PR: #1138 as to understand how can we better handle all the cases in hand.
Fixes: #2638
How to Test
Expected Result
The shell icon should be visible for all zoom level. (With or without monitor-specific scaling).