Skip to content

Commit 6576cab

Browse files
ShahzaibIbrahimHeikoKlare
authored andcommitted
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.
1 parent 7f413b7 commit 6576cab

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

  • bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3142,12 +3142,14 @@ public ImageData getImageData() {
31423142
if (!hasMaskData && depth == 32) {
31433143
alphaData = new byte[width * height];
31443144
boolean hasAlphaData = false;
3145+
boolean isAllZeroAlpha = true;
31453146
for (int pixelIndex = 0; pixelIndex < alphaData.length; pixelIndex++) {
31463147
alphaData[pixelIndex] = data[pixelIndex * 4 + 3];
31473148
hasAlphaData |= alphaData[pixelIndex] != -1;
3149+
isAllZeroAlpha &= alphaData[pixelIndex] == 0;
31483150
}
31493151
// In case there is alpha data, replace the empty mask data with proper alpha data
3150-
if (hasAlphaData) {
3152+
if (hasAlphaData && !isAllZeroAlpha) {
31513153
maskData = null;
31523154
} else {
31533155
alphaData = null;

0 commit comments

Comments
 (0)