Planes, pixels, etc. (was: JPEG Source Code for C++ Builder and Borland C++)

Joel Dudgeon wrote:

> Hmm do you have anything on converting PCX files or TGA, TIFF files to
> something Windows can handle through APIs?  I have been able to write
> decoder but I am having a problem understanding certain
> planes...I understand a plane is a surface which extends indefinitely
in all
> directions but how does that apply to a PCX file?  Is it like layers?

What you are referring to is a method used to store pixel color data.
Historically there seem to be 2 types of graphics hardware
implemenations for storing the pixel data :-

    Planar        - Imagine that the current display screen (the one
you're reading this off) split into four screens of the same size.
                        (note: I am assuming 8 bits per pixel or a byte
per pixel for easy reading)

                        the first screen contains all of the data for
the RED parts of the pixels
                        the second screen contains all of the data for
the GREEN parts of the pixels
                        the third screen contains all of the data for
the BLUE parts of the pixels
                        the fourth screen contains all of the data for
the INTENSITY parts of the pixels.

                        For the display card to generate a single color,
it gets the appropriate color part from the appropriate plane
                        (eg. the red component for pixel[0,0] is stored
in the red plane at [0,0]) and mixes it with the color data
                        from the other planes to get a resulting 32-bit
color as :-

                                Plane1    Plane2    Plane3    Plane4
                                (red)       (green)    (blue)
                                0xFF        0xFF     0xFF
0x00                        makes 0xFFFFFF00 or white

                        This kind of graphics mode was powerful in the
olden days due to the fact that it was sortof faster,
                        however 32-bit color rules nowadays.

    Packed     - This is when the pixel data is stored continuously...
There is only one data area (one plane as such)
                        which stores the actual color value for
individual pixels.

                        For example, in 8-bit (256) color mode the color
is made up of 64 shades of red, 64 shades of blue
                        and 64 shades of green stored as contiguous
8-bit Bytes. (for 640x480 it takes 300K to store the entire screen)

                                Red    Green     Blue
                                0x3F  0x3F       0x3F        makes 0xFF
or white

                        In 32-bit color mode, the color is simply stored
as contiguous 32-bit bytes (0xIIRRGGBB i believe)
                        in a large array (for 640x480 it takes 300K * 4
== 1.2MB to store the entire screen)

                                Byte1    Byte2    Byte3    Byte4
                                (red)    (green)    (blue)
                                0xFF    0xFF    0xFF
0x00               makes 0xFFFFFF00 or white

- Cheers,
- darren dwyer.

to contact me, please send email to the following addresses.. (Borland C++ Builder & TDirectDrawForm) (personal messages) (junk email)