Skip to content

Commit 0cb4c14

Browse files
Issue #301 - [win32]: device dependent bitmaps (DDBs) are always opaque
DDBs can have a 32 bit depth but the returned alpha channel data is always 0 which means fully transparent. Since we want to avoid a costly blit operation from 32 to 24 bits, stripping the alpha channel data, we set the alpha channel data to 255 for better compatibility. Note that alpha channel data in ImageData.data should always be ignored anyway and be read from ImageData.alphaData instead.
1 parent e9b2d84 commit 0cb4c14

File tree

1 file changed

+2
-2
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,10 +1616,10 @@ public ImageData getImageDataAtCurrentZoom() {
16161616
/* Construct and return the ImageData */
16171617
ImageData imageData = new ImageData(width, height, depth, palette, 4, data);
16181618
imageData.transparentPixel = this.transparentPixel;
1619-
if (isDib && depth == 32) {
1619+
if (depth == 32) {
16201620
byte straightData[] = new byte[imageSize];
16211621
byte alphaData[] = new byte[width * height];
1622-
boolean validAlpha = true;
1622+
boolean validAlpha = isDib;
16231623
for (int ap = 0, dp = 0; validAlpha && ap < alphaData.length; ap++, dp += 4) {
16241624
int b = data[dp ] & 0xFF;
16251625
int g = data[dp + 1] & 0xFF;

0 commit comments

Comments
 (0)