From 27d013b4c79464088daa320db07da5cac1566e08 Mon Sep 17 00:00:00 2001 From: Shahzaib Ibrahim Date: Tue, 20 Jan 2026 11:46:42 +0100 Subject: [PATCH] Ignore undefined all-zero alpha data for 32-bit icons without mask On Windows, GetDIBits() may return undefined alpha bytes for 32-bit BI_RGB bitmaps, commonly resulting in all-zero alpha even for fully opaque images. When icon mask data is missing, this caused opaque icons to be incorrectly treated as fully transparent. Reject all-zero alpha data and only replace empty mask data when the alpha channel contains meaningful (non-opaque, non-zero) values. --- .../Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java index bd6373392ab..7abf910b88e 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java @@ -3142,12 +3142,14 @@ public ImageData getImageData() { if (!hasMaskData && depth == 32) { alphaData = new byte[width * height]; boolean hasAlphaData = false; + boolean isAllZeroAlpha = true; for (int pixelIndex = 0; pixelIndex < alphaData.length; pixelIndex++) { alphaData[pixelIndex] = data[pixelIndex * 4 + 3]; hasAlphaData |= alphaData[pixelIndex] != -1; + isAllZeroAlpha &= alphaData[pixelIndex] == 0; } // In case there is alpha data, replace the empty mask data with proper alpha data - if (hasAlphaData) { + if (hasAlphaData && !isAllZeroAlpha) { maskData = null; } else { alphaData = null;