Supported Pixel Formats

One of the most useful capabilities of Microsoft® DirectX® Transform is that it enables you to import and export graphics data in a number of standard pixel formats. Each format uses a different number of bits to represent the color and opacity of each sample. A sample is divided into amounts of red, green, blue, and alpha. Transforms define three basic data types that are used to represent image samples.

The alpha component describes the opacity of a sample, with zero representing a clear sample and 255 representing a fully opaque sample. Pixel formats, which use several bits for alpha, are said to be translucent. This allows images to be rendered on top of other images, with some of the underlying image showing through. Formats that use only 1 bit for alpha are said to be transparent. Transparency is used frequently in Web page graphics, allowing images to show cleanly on background patterns. A common way to use transparency is through a color key; this is indicated by the "_CK" suffix on the pixel format data type. Any non-alpha based pixel format can have a color key attached. If a format with the "_CK" suffix is used during creation of a surface, a color key is automatically attached.

Alpha-based pixel formats have several advantages over color-keyed pixel formats. For example, alpha-based surfaces can support shapes with soft or anti-aliased edges, while color-keyed surfaces cannot. Alpha-based samples store transparency information in a separate component, so it does not get potentially confused with the color information of the picture, like color-keyed surfaces can.

Source images should usually be loaded in their native format. Images that contain translucency and that will be repeatedly composited should use the DDPF_PMARGB32 format for performance, if possible.

DirectX Transform supports the following pixel formats.

32-Bit Pixel Formats

DDPF_ARGB32
Eight bits each of alpha, red, green, and blue. The bits are stored in that order, with the alpha stored in the higher-order bits and the blue in the lower-order bits. This is one of the two preferred pixel formats used by DirectX Transform.
DDPF_PMARGB32
Eight bits each of alpha, red, green, and blue. This is essentially the same format as DDPF_ARGB32, except that each of the colors have been alpha-premultiplied. Using this format makes the compositing of images more efficient because this removes several mathematical operations in the compositing process. This is the second of the two preferred pixel formats used by DirectX Transform.
DDPF_RGB32
Eight bits each of red, green, and blue. Alpha is undefined.
DDPF_RGB32_CK
The same format as DDPF_RGB32, with one color treated as transparent.

24-Bit Pixel Formats

DDPF_RGB24
Eight bits each of red, green, and blue. This format is more compact in memory than the 32-bit formats; however, access is slow because the samples are not aligned on 32-bit boundaries in memory.
DDPF_RGB24_CK
The same format as DDPF_RGB24, with one color treated as transparent.

16-Bit Pixel Formats

DDPF_ARGB4444
Four bits each of alpha, red, green, and blue. You should note that Graphics Device Interface (GDI) does not display this format properly on Microsoft Windows® 95 or Windows 98.
DDPF_RGB565
This format uses 5 bits for red, 6 bits for green, and 5 bits for blue. The higher-order bits are used for red, while the lower order bits are used for blue.
DDPF_RGB555
Five bits each for red, green, and blue. The high-order bit is undefined.
DDPF_RGB565_CK
The same format as DDPF_RGB565, with one color treated as transparent.
DDPF_RGB555_CK
The same format as DDPF_RGB555, with one color treated as transparent.

8-Bit Pixel Formats

DDPF_RGB8
This format uses an 8-bit number to index into a predefined palette of 256 colors. The default palette is the Microsoft Windows halftone palette.
DDPF_RGB8_CK
This is the same format as DDPF_RGB8, with one of the indices treated as transparent.

Top of Page Top of Page
© 2000 Microsoft and/or its suppliers. All rights reserved. Terms of Use.