Pixel Formats

Hi,

I am mighty confused with the different formats used for storing pixels ??? RGBA format is true color and must therefore hold at least 24 bits per pixel but, in the “Jumping into JOGL” java.net example (link http://today.java.net/pub/a/today/2003/09/11/jogl2d.html) I notice the GL_RGBA format is used along with a GL_UNSIGNED_BYTE type.

gl.glDrawPixels (dukeWidth, dukeHeight,
                 gl.GL_RGBA, gl.GL_UNSIGNED_BYTE,
                 dukeRGBA);

As an unsigned byte would be 8 bits, what is the point of using RGBA when only 8 bits are being drawn per pixel? I am only interested as the images I use never have more than 2 colors per image. Is there some more efficient method of storing my pixel data before drawing them rather than using GL_RGBA format as in the “Jumping into JOGL” example.

Any explanations, links, advise or code highly appreciated.

Thanks,

Sally

I believe that means it is one byte per color component not one byte for all color components to share.

Thanks for your reply but now I’m even more confused. What is a color component? I was under the impression that each individual pixel was stored as 24 bits (ie one of 224 = 16777216 different colors). Please explain what you mean by color component in this context? And where does the 8 bit unsigned byte come into it?

Regards,

Sally

The colour components are the RGBA, its one byte for the red channel, one for the green etc. etc. for a total of 32bits per pixel.

Thank you. Yes, I’ve got that now. I obviously wasn’t thinking clearly :-[

Does anybody know how to drawpixels from an image using a 16 bit format (or even 8 bit) because if a program needed to draw pixels at an extremely fast rate am I correct in saying that a 16 bit format would double the speed of writing to the screen and hence improve performance? I ask this because my images (.png images) physically only have 2 distinct colours each and hence I could, in theory, not use the full 32 bits of RGBA format.

Regards,

Sally

Look at the writeup of glDrawPixels in Chapter 8 of the OpenGL Programming Guide.

http://www.opengl.org/documentation/red_book_1.0/