Palette Types

DirectDraw supports 1-bit (2 entry), 2-bit (4 entry), 4-bit (16 entry), and 8-bit (256 entry) palettes. A palette can be attached only to a surface with a matching pixel format. For example, a 2-entry palette created with the DDPCAPS_1BIT flag can be attached only to a 1-bit surface created with the DDPF_PALETTEINDEXED1 flag.

It is also possible to create indexed palettes. An indexed palette is one whose entries do not hold RGB colors, but rather integer indices into the array of PALETTEENTRY structures of some target palette. An indexed palette's color table is an array of 2, 4, 16, or 256 bytes, where each byte is an index into some unspecified destination palette.

To create an indexed palette, specify the DDPCAPS_8BITENTRIES flag when calling the IDirectDraw2::CreatePalette method. For example, to create a 4-bit indexed palette, specify DDPCAPS_4BIT |DDPCAPS_8BITENTRIES. When you create an indexed palette, pass a pointer to an array of bytes rather than a pointer to an array of PALETTEENTRY structures. You must cast the pointer to the array of bytes to an LPPALETTEENTRY type when you use the IDirectDraw2::CreatePalette method.