[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools] GC.drawImage() and transparent images

Not sure how to report bugs, so I'll post this here.

My situation is that I create a com.ibm.swt.graphics.ImageData of a
certain width/height. I then set the bits in this ImageData and set the
transparent field to the value of a pixel in the background color. I then
create a com.ibm.swt.graphics.Image from this data.

When I draw this image into a window with GC.drawImage(), I don't get a
transparent image. Actually, I get an OutOfBounds exception. I traced
through GC.drawImage() source and found that my image was classified as a
DIB (I'm running on Windows) which then sends GC.drawBitmapTransparent()
down a path where the transparent pixel is looked up in a color table. The
problem is, my DIB has a color depth of 32, so there is no color table.

To temporarily work around this problem, I created my own drawImage which
checks the color depth for DIB images. Instead of using a color table, I
used the following to map to the transparent color when the color depth is
32:

transBlue  = (pixel >> 8) & 0xFF;
transGreen = (pixel >> 16) & 0xFF;
transRed   = (pixel >> 24) & 0xFF;

I originally discovered this problem while using Tech Preview 3 (sorry,
don't know what build number that is) but I verified that this problem
still exists with the .043 build. I think a similar problem would also
exist for transparent DIB's with color depths of 16, though I don't have a
test case which proves that.

Don Boulia