[4851] in java-interest
Re: Transparent GIF (small question)
daemon@ATHENA.MIT.EDU (Jim Graham)
Tue Jan 16 18:42:33 1996
Date: Tue, 16 Jan 1996 14:05:03 -0800
From: flar@bendenweyr.Eng.Sun.COM (Jim Graham)
To: java-interest@java.Eng.Sun.COM, vitaly@diogen.asc.rssi.ru
> If I have transparent GIF image wehn I do GrabPixels on this
> image how I can understand that pixels[i][j] grabbed from this
> image is Transparent?
The Constructor for this class points you to the ColorModel.getRGBdefault()
method for a description of the standard default ColorModel used to
describe pixels. It is basically a 32-bit pixel with 8 bits each for
alpha, red, green and blue (listed from high to low order bytes). You
can decompose the pixel using:
int alpha = (pixel >> 24) & 0xff;
int red = (pixel >> 16) & 0xff;
int green = (pixel >> 8) & 0xff;
int blue = (pixel ) & 0xff;
If you don't mind being GIF-specific and don't mind doing some more
work, you can modify the PixelGrabber code to read the GIF's pixels
directly without converting them into the standard 32-bit ColorModel.
GIF's are restricted to 8-bit data so the raw data takes 1/4 the room
than if you convert it to the standard ColorModel. Also, checking for
the transparent GIF pixel is a simple comparison (see getTransparentPixel
in the IndexColorModel class). This exercise is left for the reader... ;-)
...jim
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com