Skip to content

Conversation

@ShahzaibIbrahim
Copy link
Contributor

@ShahzaibIbrahim ShahzaibIbrahim commented Oct 22, 2025

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

  • Run the following snippet after adding the following image in the same package as snippet. (This image has no transparency)
png-image
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;

public class ImageWithNoTransparencyMaskOnShell {
    public static void main(String[] args) {
    	System.setProperty("swt.autoScale.updateOnRuntime", "true");
    	System.setProperty("swt.autoScale", "quarter");
        Display display = new Display();
        Shell shell = new Shell(display);
        shell.setText("Image With No Transparency Mask on Shell");
        shell.setSize(600, 600);
		Image image = new Image(display, ButtonWithGifImage.class.getResourceAsStream("png-image.png"));
		shell.setImage(image);

        shell.open();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch())
                display.sleep();
        }

        image.dispose();
        display.dispose();
    }
}

Expected Result

The shell icon should be visible for all zoom level. (With or without monitor-specific scaling).

image

@ShahzaibIbrahim ShahzaibIbrahim changed the title Use loadImageData to initImage in ImageFromImageDataProviderWrapper [Win] Use loadImageData to initImage in ImageFromImageDataProviderWrapper Oct 22, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Oct 22, 2025

Test Results

  108 files   -  7    108 suites   - 7   13m 46s ⏱️ + 2m 46s
4 506 tests  - 56  4 474 ✅  - 72  13 💤  - 3  6 ❌ +6  13 🔥 +13 
  255 runs   - 56    255 ✅  - 53   0 💤  - 3  0 ❌ ±0 

For more details on these failures and errors, see this check.

Results for commit 6a5fef1. ± Comparison against base commit 6779ddc.

This pull request removes 56 tests.
AllWin32Tests ImageWin32Tests ‑ testDisposeDrawnImageBeforeRequestingTargetForOtherZoom
AllWin32Tests ImageWin32Tests ‑ testDrawImageAtDifferentZooms(boolean)[1] true
AllWin32Tests ImageWin32Tests ‑ testDrawImageAtDifferentZooms(boolean)[2] false
AllWin32Tests ImageWin32Tests ‑ testImageDataForDifferentFractionalZoomsShouldBeDifferent
AllWin32Tests ImageWin32Tests ‑ testImageShouldHaveDimesionAsPerZoomLevel
AllWin32Tests ImageWin32Tests ‑ testRetrieveImageDataAtDifferentZooms(boolean)[1] true
AllWin32Tests ImageWin32Tests ‑ testRetrieveImageDataAtDifferentZooms(boolean)[2] false
AllWin32Tests ImageWin32Tests ‑ test_getImageData_fromCopiedImage
AllWin32Tests ImageWin32Tests ‑ test_getImageData_fromImageForImageDataFromImage
AllWin32Tests TestTreeColumn ‑ test_ColumnOrder
…

♻️ This comment has been updated with latest results.

@ShahzaibIbrahim ShahzaibIbrahim force-pushed the master-483 branch 4 times, most recently from eec4c83 to 4f96cbd Compare October 23, 2025 12:31
@ShahzaibIbrahim ShahzaibIbrahim changed the title [Win] Use loadImageData to initImage in ImageFromImageDataProviderWrapper [Win32] Don't Create a mask image when there is no mask Oct 23, 2025
Copy link
Contributor

@akoch-yatta akoch-yatta left a comment

Choose a reason for hiding this comment

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

The logic change only affects the case where the transparency type is SWT.NONE. In this case using the other implementation makes sense to me, as it will behave as a fully opaque image which is expected. This fixes the behavior as described and I did not find any regression while having a look at other icons create with this method.

When setting an image for a shell, we try to convert the bitmap image
into icon to set the image on the top left of the shell. However we can
have icons which has no transparency. In this case we dont need to
create a transparency mask at all.

fixes eclipse-platform#2638
@akoch-yatta akoch-yatta merged commit 199a644 into eclipse-platform:master Oct 23, 2025
21 of 22 checks passed
@akoch-yatta akoch-yatta deleted the master-483 branch October 23, 2025 13:45
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.

Broken transparency handling for shell icons Application icon doesn't render after upgrading

2 participants