SAMPLE: 16 and 32 Bits-Per-Pel Bitmap FormatsLast reviewed: September 6, 1996Article ID: Q94326 |
The information in this article applies to:
SUMMARYWindows NT supports the same bitmap formats as Microsoft Windows version 3.1, but includes two new formats: 16 and 32 bits-per-pel. SEEDIB.EXE is a file in the Microsoft Software Library that contains the source code to an application that demonstrates how to load, display, and save 1, 4, 8, 16, 24, and 32-bits-per-pixel DIB formats. In addition, it demonstrates a simple method of creating an optimized palette for displaying DIBSs with more than 8-bits-per-pixel on 8-bits-per-pixel devices. NOTE: In order to minimize color loss, SeeDIB uses CreateDIBSection() to do conversions between uncompressed DIBs which have more than 8-bits-per- pixel. This function is not available on Windows NT 3.1. You can download SEEDIB.EXE from the Microsoft Software Library (MSL) on the following services:
MORE INFORMATIONFor DIBs (device independent bitmaps), the 16 and 32-bit formats contain three DWORD masks in the bmiColors member of the BITMAPINFO structure. These masks specify which bits in the pel correspond to which color. The three masks must have contiguous bits, and their order is assumed to be R, G, B (high bits to low bits). The order of the three masks in the color table must also be first red, then green, then blue (RGB). In this manner, the programmer can specify a mask indicating how many shades of each RGB color will be available for bitmaps created with CreateDIBitmap(). For 16-bits-per-pixel DIBs, CreateDIBitmap() defaults to the RGB555 format. For 32-bits-per-pixel DIBs, CreateDIBitmap() defaults to an RGB888 format. NOTE: The DIB engine in Windows 95 supports only RGB555 and RGB565 for 16-bit DIBs and only RGB888 for 32-bit DIBs.
ExampleThe RGB555 format masks would look like:
0x00007C00 red (0000 0000 0000 0000 0111 1100 0000 0000) 0x000003E0 green (0000 0000 0000 0000 0000 0011 1110 0000) 0x0000001F blue (0000 0000 0000 0000 0000 0000 0001 1111)NOTE: For 16 bits-per-pel, the upper half of the DWORDs are always zeroed. The RGB888 format masks would look like:
0x00FF0000 red (0000 0000 1111 1111 0000 0000 0000 0000) 0x0000FF00 green (0000 0000 0000 0000 1111 1111 0000 0000) 0x000000FF blue (0000 0000 0000 0000 0000 0000 1111 1111) UsageWhen using 16 and 32-bit formats, there are also certain fields of the BITMAPINFOHEADER structure that must be set to the correct values:
Windows 95In Windows 95, if the BI_BITFIELDS flag is set, then a color mask must be specified and it must be one of the following: Resolution Bits per color Color Mask 16bpp 5,5,5 0x00007c00 0x000003e0 0x0000001f 16bpp 5,6,5 0x0000f800 0x000007e0 0x0000001f 32bpp 8,8,8 0x00ff0000 0x0000ff00 0x000000ffUser-defined color masks are not available in Windows 95.
|
Additional reference words: 3.10 3.50 4.00 bpp bmp
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |