Common Graphics : Device-independent images

Device-independent images
Conceptually, an image is a two-dimensional array of colors. For storage efficiency, colors in an image are usually encoded as discrete pixel values with a fixed number of bits for each pixel value. There are two common ways in which colors are encoded as pixel values. In the first kind of encoding, the image is restricted to a small set of colors (256 or less). This set is ordered and the pixel values are treated as indices into the list of colors. This encoding requires 8 bits or fewer per pixel. In the second kind of encoding, colors are encoded directly in the pixel values. For example, the red, green, and blue intensities of a color can be encoded as values in the range 0 to 255, requiring 8 bits for each primary and therefore 24 bits for the whole pixel value. For both encodings a palette is required to define the pixel-value-to-color mapping.
Common Graphics provides a class, CgDeviceIndependentImage, that defines a device-independent representation of uncompressed bitmap images with 1, 4, 8, or 24 bits per pixel. The image data format is made public, allowing it to be efficiently manipulated by applications. The same data format is used on all platforms. The data format is as follows:
Device-independent images are created in one of two ways:
The following section describes how to create an image using application-defined data. Image file formats are described in a later section.