1 Graphics File Formats
\r
3 This topic describes the graphics-file formats used by the Microsoft Windows
\r
4 operating system. Graphics files include bitmap files, icon-resource files,
\r
5 and cursor-resource files.
\r
9 Windows bitmap files are stored in a device-independent bitmap (DIB) format
\r
10 that allows Windows to display the bitmap on any type of display device. The
\r
11 term "device independent" means that the bitmap specifies pixel color in a
\r
12 form independent of the method used by a display to represent color. The
\r
13 default filename extension of a Windows DIB file is .BMP.
\r
15 Bitmap-File Structures
\r
17 Each bitmap file contains a bitmap-file header, a bitmap-information header,
\r
18 a color table, and an array of bytes that defines the bitmap bits. The file
\r
19 has the following form:
\r
21 BITMAPFILEHEADER bmfh;
\r
22 BITMAPINFOHEADER bmih;
\r
26 The bitmap-file header contains information about the type, size, and layout
\r
27 of a device-independent bitmap file. The header is defined as a
\r
28 BITMAPFILEHEADER structure.
\r
30 The bitmap-information header, defined as a BITMAPINFOHEADER structure,
\r
31 specifies the dimensions, compression type, and color format for the bitmap.
\r
33 The color table, defined as an array of RGBQUAD structures, contains as many
\r
34 elements as there are colors in the bitmap. The color table is not present
\r
35 for bitmaps with 24 color bits because each pixel is represented by 24-bit
\r
36 red-green-blue (RGB) values in the actual bitmap data area. The colors in the
\r
37 table should appear in order of importance. This helps a display driver
\r
38 render a bitmap on a device that cannot display as many colors as there are
\r
39 in the bitmap. If the DIB is in Windows version 3.0 or later format, the
\r
40 driver can use the biClrImportant member of the BITMAPINFOHEADER structure to
\r
41 determine which colors are important.
\r
43 The BITMAPINFO structure can be used to represent a combined
\r
44 bitmap-information header and color table. The bitmap bits, immediately
\r
45 following the color table, consist of an array of BYTE values representing
\r
46 consecutive rows, or "scan lines," of the bitmap. Each scan line consists of
\r
47 consecutive bytes representing the pixels in the scan line, in left-to-right
\r
48 order. The number of bytes representing a scan line depends on the color
\r
49 format and the width, in pixels, of the bitmap. If necessary, a scan line
\r
50 must be zero-padded to end on a 32-bit boundary. However, segment boundaries
\r
51 can appear anywhere in the bitmap. The scan lines in the bitmap are stored
\r
52 from bottom up. This means that the first byte in the array represents the
\r
53 pixels in the lower-left corner of the bitmap and the last byte represents
\r
54 the pixels in the upper-right corner.
\r
56 The biBitCount member of the BITMAPINFOHEADER structure determines the number
\r
57 of bits that define each pixel and the maximum number of colors in the
\r
58 bitmap. These members can have any of the following values:
\r
62 1 Bitmap is monochrome and the color table contains two entries. Each
\r
63 bit in the bitmap array represents a pixel. If the bit is clear, the pixel is
\r
64 displayed with the color of the first entry in the color table. If the bit is
\r
65 set, the pixel has the color of the second entry in the table.
\r
67 4 Bitmap has a maximum of 16 colors. Each pixel in the bitmap is
\r
68 represented by a 4-bit index into the color table. For example, if the first
\r
69 byte in the bitmap is 0x1F, the byte represents two pixels. The first pixel
\r
70 contains the color in the second table entry, and the second pixel contains
\r
71 the color in the sixteenth table entry.
\r
73 8 Bitmap has a maximum of 256 colors. Each pixel in the bitmap is
\r
74 represented by a 1-byte index into the color table. For example, if the first
\r
75 byte in the bitmap is 0x1F, the first pixel has the color of the
\r
76 thirty-second table entry.
\r
78 24 Bitmap has a maximum of 2^24 colors. The bmiColors (or bmciColors)
\r
79 member is NULL, and each 3-byte sequence in the bitmap array represents the
\r
80 relative intensities of red, green, and blue, respectively, for a pixel.
\r
82 The biClrUsed member of the BITMAPINFOHEADER structure specifies the number
\r
83 of color indexes in the color table actually used by the bitmap. If the
\r
84 biClrUsed member is set to zero, the bitmap uses the maximum number of colors
\r
85 corresponding to the value of the biBitCount member. An alternative form of
\r
86 bitmap file uses the BITMAPCOREINFO, BITMAPCOREHEADER, and RGBTRIPLE
\r
91 Windows versions 3.0 and later support run-length encoded (RLE) formats for
\r
92 compressing bitmaps that use 4 bits per pixel and 8 bits per pixel.
\r
93 Compression reduces the disk and memory storage required for a bitmap.
\r
95 Compression of 8-Bits-per-Pixel Bitmaps
\r
97 When the biCompression member of the BITMAPINFOHEADER structure is set to
\r
98 BI_RLE8, the DIB is compressed using a run-length encoded format for a
\r
99 256-color bitmap. This format uses two modes: encoded mode and absolute mode.
\r
100 Both modes can occur anywhere throughout a single bitmap.
\r
104 A unit of information in encoded mode consists of two bytes. The first byte
\r
105 specifies the number of consecutive pixels to be drawn using the color index
\r
106 contained in the second byte. The first byte of the pair can be set to zero
\r
107 to indicate an escape that denotes the end of a line, the end of the bitmap,
\r
108 or a delta. The interpretation of the escape depends on the value of the
\r
109 second byte of the pair, which must be in the range 0x00 through 0x02.
\r
110 Following are the meanings of the escape values that can be used in the
\r
113 Second byte Meaning
\r
117 2 Delta. The two bytes following the escape contain unsigned values
\r
118 indicating the horizontal and vertical offsets of the next pixel from the
\r
123 Absolute mode is signaled by the first byte in the pair being set to zero and
\r
124 the second byte to a value between 0x03 and 0xFF. The second byte represents
\r
125 the number of bytes that follow, each of which contains the color index of a
\r
126 single pixel. Each run must be aligned on a word boundary. Following is an
\r
127 example of an 8-bit RLE bitmap (the two-digit hexadecimal values in the
\r
128 second column represent a color index for a single pixel):
\r
130 Compressed data Expanded data
\r
133 05 06 06 06 06 06 06
\r
134 00 03 45 56 67 00 45 56 67
\r
136 00 02 05 01 Move 5 right and 1 down
\r
139 09 1E 1E 1E 1E 1E 1E 1E 1E 1E 1E
\r
140 00 01 End of RLE bitmap
\r
142 Compression of 4-Bits-per-Pixel Bitmaps
\r
144 When the biCompression member of the BITMAPINFOHEADER structure is set to
\r
145 BI_RLE4, the DIB is compressed using a run-length encoded format for a
\r
146 16-color bitmap. This format uses two modes: encoded mode and absolute mode.
\r
150 A unit of information in encoded mode consists of two bytes. The first byte
\r
151 of the pair contains the number of pixels to be drawn using the color indexes
\r
152 in the second byte.
\r
154 The second byte contains two color indexes, one in its high-order nibble
\r
155 (that is, its low-order 4 bits) and one in its low-order nibble.
\r
157 The first pixel is drawn using the color specified by the high-order nibble,
\r
158 the second is drawn using the color in the low-order nibble, the third is
\r
159 drawn with the color in the high-order nibble, and so on, until all the
\r
160 pixels specified by the first byte have been drawn.
\r
162 The first byte of the pair can be set to zero to indicate an escape that
\r
163 denotes the end of a line, the end of the bitmap, or a delta. The
\r
164 interpretation of the escape depends on the value of the second byte of the
\r
165 pair. In encoded mode, the second byte has a value in the range 0x00 through
\r
166 0x02. The meaning of these values is the same as for a DIB with 8 bits per
\r
171 In absolute mode, the first byte contains zero, the second byte contains the
\r
172 number of color indexes that follow, and subsequent bytes contain color
\r
173 indexes in their high- and low-order nibbles, one color index for each pixel.
\r
174 Each run must be aligned on a word boundary.
\r
176 Following is an example of a 4-bit RLE bitmap (the one-digit hexadecimal
\r
177 values in the second column represent a color index for a single pixel):
\r
179 Compressed data Expanded data
\r
183 00 06 45 56 67 00 4 5 5 6 6 7
\r
185 00 02 05 01 Move 5 right and 1 down
\r
188 09 1E 1 E 1 E 1 E 1 E 1
\r
189 00 01 End of RLE bitmap
\r
193 The following example is a text dump of a 16-color bitmap (4 bits per pixel):
\r
216 Blue Green Red Unused
\r
217 [00000000] 84 252 84 0
\r
218 [00000001] 252 252 84 0
\r
219 [00000002] 84 84 252 0
\r
220 [00000003] 252 84 252 0
\r
221 [00000004] 84 252 252 0
\r
222 [00000005] 252 252 252 0
\r
224 [00000007] 168 0 0 0
\r
225 [00000008] 0 168 0 0
\r
226 [00000009] 168 168 0 0
\r
227 [0000000A] 0 0 168 0
\r
228 [0000000B] 168 0 168 0
\r
229 [0000000C] 0 168 168 0
\r
230 [0000000D] 168 168 168 0
\r
231 [0000000E] 84 84 84 0
\r
232 [0000000F] 252 84 84 0
\r
238 Icon-Resource File Format
\r
240 An icon-resource file contains image data for icons used by Windows
\r
241 applications. The file consists of an icon directory identifying the number
\r
242 and types of icon images in the file, plus one or more icon images. The
\r
243 default filename extension for an icon-resource file is .ICO.
\r
247 Each icon-resource file starts with an icon directory. The icon directory,
\r
248 defined as an ICONDIR structure, specifies the number of icons in the
\r
249 resource and the dimensions and color format of each icon image. The ICONDIR
\r
250 structure has the following form:
\r
254 typedef struct ICONDIR {
\r
258 ICONDIRENTRY idEntries[1];
\r
261 Following are the members in the ICONDIR structure:
\r
263 idReserved Reserved; must be zero.
\r
264 idType Specifies the resource type. This member is set to 1.
\r
265 idCount Specifies the number of entries in the directory.
\r
266 idEntries Specifies an array of ICONDIRENTRY structures containing
\r
267 information about individual icons. The idCount member specifies the number
\r
268 of structures in the array.
\r
270 The ICONDIRENTRY structure specifies the dimensions and color format for an
\r
271 icon. The structure has the following form:
\r
275 struct IconDirectoryEntry {
\r
282 DWORD dwBytesInRes;
\r
283 DWORD dwImageOffset;
\r
286 Following are the members in the ICONDIRENTRY structure:
\r
288 bWidth Specifies the width of the icon, in pixels. Acceptable values
\r
289 are 16, 32, and 64.
\r
291 bHeight Specifies the height of the icon, in pixels. Acceptable
\r
292 values are 16, 32, and 64.
\r
294 bColorCount Specifies the number of colors in the icon. Acceptable values
\r
297 bReserved Reserved; must be zero.
\r
298 wPlanes Specifies the number of color planes in the icon bitmap.
\r
299 wBitCount Specifies the number of bits in the icon bitmap.
\r
300 dwBytesInRes Specifies the size of the resource, in bytes.
\r
301 dwImageOffset Specifies the offset, in bytes, from the beginning of the
\r
302 file to the icon image.
\r
306 Each icon-resource file contains one icon image for each image identified in
\r
307 the icon directory. An icon image consists of an icon-image header, a color
\r
308 table, an XOR mask, and an AND mask. The icon image has the following form:
\r
312 BITMAPINFOHEADER icHeader;
\r
313 RGBQUAD icColors[];
\r
317 The icon-image header, defined as a BITMAPINFOHEADER structure, specifies the
\r
318 dimensions and color format of the icon bitmap. Only the biSize through
\r
319 biBitCount members and the biSizeImage member are used. All other members
\r
320 (such as biCompression and biClrImportant) must be set to zero.
\r
322 The color table, defined as an array of RGBQUAD structures, specifies the
\r
323 colors used in the XOR mask. As with the color table in a bitmap file, the
\r
324 biBitCount member in the icon-image header determines the number of elements
\r
325 in the array. For more information about the color table, see Section 1.1,
\r
326 "Bitmap-File Formats."
\r
328 The XOR mask, immediately following the color table, is an array of BYTE
\r
329 values representing consecutive rows of a bitmap. The bitmap defines the
\r
330 basic shape and color of the icon image. As with the bitmap bits in a bitmap
\r
331 file, the bitmap data in an icon-resource file is organized in scan lines,
\r
332 with each byte representing one or more pixels, as defined by the color
\r
333 format. For more information about these bitmap bits, see Section 1.1,
\r
334 "Bitmap-File Formats."
\r
336 The AND mask, immediately following the XOR mask, is an array of BYTE values,
\r
337 representing a monochrome bitmap with the same width and height as the XOR
\r
338 mask. The array is organized in scan lines, with each byte representing 8
\r
341 When Windows draws an icon, it uses the AND and XOR masks to combine the icon
\r
342 image with the pixels already on the display surface. Windows first applies
\r
343 the AND mask by using a bitwise AND operation; this preserves or removes
\r
344 existing pixel color. Windows then applies the XOR mask by using a bitwise
\r
345 XOR operation. This sets the final color for each pixel.
\r
347 The following illustration shows the XOR and AND masks that create a
\r
348 monochrome icon (measuring 8 pixels by 8 pixels) in the form of an uppercase
\r
351 Windows Icon Selection
\r
353 Windows detects the resolution of the current display and matches it against
\r
354 the width and height specified for each version of the icon image. If Windows
\r
355 determines that there is an exact match between an icon image and the current
\r
356 device, it uses the matching image. Otherwise, it selects the closest match
\r
357 and stretches the image to the proper size.
\r
359 If an icon-resource file contains more than one image for a particular
\r
360 resolution, Windows uses the icon image that most closely matches the color
\r
361 capabilities of the current display. If no image matches the device
\r
362 capabilities exactly, Windows selects the image that has the greatest number
\r
363 of colors without exceeding the number of display colors. If all images
\r
364 exceed the color capabilities of the current display, Windows uses the icon
\r
365 image with the least number of colors.
\r
369 Cursor-Resource File Format
\r
371 A cursor-resource file contains image data for cursors used by Windows
\r
372 applications. The file consists of a cursor directory identifying the number
\r
373 and types of cursor images in the file, plus one or more cursor images. The
\r
374 default filename extension for a cursor-resource file is .CUR.
\r
378 Each cursor-resource file starts with a cursor directory. The cursor
\r
379 directory, defined as a CURSORDIR structure, specifies the number of cursors
\r
380 in the file and the dimensions and color format of each cursor image. The
\r
381 CURSORDIR structure has the following form:
\r
384 typedef struct _CURSORDIR {
\r
388 CURSORDIRENTRY cdEntries[];
\r
391 Following are the members in the CURSORDIR structure:
\r
393 cdReserved Reserved; must be zero.
\r
394 cdType Specifies the resource type. This member must be set to 2.
\r
395 cdCount Specifies the number of cursors in the file.
\r
396 cdEntries Specifies an array of CURSORDIRENTRY structures containing
\r
397 information about individual cursors. The cdCount member specifies the number
\r
398 of structures in the array.
\r
400 A CURSORDIRENTRY structure specifies the dimensions and color format of a
\r
401 cursor image. The structure has the following form:
\r
405 typedef struct _CURSORDIRENTRY {
\r
413 DWORD dwImageOffset;
\r
416 Following are the members in the CURSORDIRENTRY structure:
\r
418 bWidth Specifies the width of the cursor, in pixels.
\r
419 bHeight Specifies the height of the cursor, in pixels.
\r
420 bColorCount Reserved; must be zero.
\r
421 bReserved Reserved; must be zero.
\r
422 wXHotspot Specifies the x-coordinate, in pixels, of the hot spot.
\r
423 wYHotspot Specifies the y-coordinate, in pixels, of the hot spot.
\r
424 lBytesInRes Specifies the size of the resource, in bytes.
\r
425 dwImageOffset Specifies the offset, in bytes, from the start of the file to
\r
430 Each cursor-resource file contains one cursor image for each image identified
\r
431 in the cursor directory. A cursor image consists of a cursor-image header, a
\r
432 color table, an XOR mask, and an AND mask. The cursor image has the following
\r
437 BITMAPINFOHEADER crHeader;
\r
438 RGBQUAD crColors[];
\r
442 The cursor hot spot is a single pixel in the cursor bitmap that Windows uses
\r
443 to track the cursor. The crXHotspot and crYHotspot members specify the x- and
\r
444 y-coordinates of the cursor hot spot. These coordinates are 16-bit integers.
\r
446 The cursor-image header, defined as a BITMAPINFOHEADER structure, specifies
\r
447 the dimensions and color format of the cursor bitmap. Only the biSize through
\r
448 biBitCount members and the biSizeImage member are used. The biHeight member
\r
449 specifies the combined height of the XOR and AND masks for the cursor. This
\r
450 value is twice the height of the XOR mask. The biPlanes and biBitCount
\r
451 members must be 1. All other members (such as biCompression and
\r
452 biClrImportant) must be set to zero.
\r
454 The color table, defined as an array of RGBQUAD structures, specifies the
\r
455 colors used in the XOR mask. For a cursor image, the table contains exactly
\r
456 two structures, since the biBitCount member in the cursor-image header is
\r
459 The XOR mask, immediately following the color table, is an array of BYTE
\r
460 values representing consecutive rows of a bitmap. The bitmap defines the
\r
461 basic shape and color of the cursor image. As with the bitmap bits in a
\r
462 bitmap file, the bitmap data in a cursor-resource file is organized in scan
\r
463 lines, with each byte representing one or more pixels, as defined by the
\r
464 color format. For more information about these bitmap bits, see Section 1.1,
\r
465 "Bitmap-File Formats."
\r
467 The AND mask, immediately following the XOR mask, is an array of BYTE values
\r
468 representing a monochrome bitmap with the same width and height as the XOR
\r
469 mask. The array is organized in scan lines, with each byte representing 8
\r
472 When Windows draws a cursor, it uses the AND and XOR masks to combine the
\r
473 cursor image with the pixels already on the display surface. Windows first
\r
474 applies the AND mask by using a bitwise AND operation; this preserves or
\r
475 removes existing pixel color. Window then applies the XOR mask by using a
\r
476 bitwise XOR operation. This sets the final color for each pixel.
\r
478 The following illustration shows the XOR and the AND masks that create a
\r
479 cursor (measuring 8 pixels by 8 pixels) in the form of an arrow:
\r
481 Following are the bit-mask values necessary to produce black, white,
\r
482 inverted, and transparent results:
\r
484 Pixel result AND maskXOR mask
\r
491 Windows Cursor Selection
\r
493 If a cursor-resource file contains more than one cursor image, Windows
\r
494 determines the best match for a particular display by examining the width and
\r
495 height of the cursor images.
\r
498 ==============================================================================
\r
501 BITMAPFILEHEADER (3.0)
\r
505 typedef struct tagBITMAPFILEHEADER { /* bmfh */
\r
511 } BITMAPFILEHEADER;
\r
513 The BITMAPFILEHEADER structure contains information about the type, size, and
\r
514 layout of a device-independent bitmap (DIB) file.
\r
518 bfType Specifies the type of file. This member must be BM.
\r
519 bfSize Specifies the size of the file, in bytes.
\r
520 bfReserved1 Reserved; must be set to zero.
\r
521 bfReserved2 Reserved; must be set to zero.
\r
522 bfOffBits Specifies the byte offset from the BITMAPFILEHEADER structure
\r
523 to the actual bitmap data in the file.
\r
527 A BITMAPINFO or BITMAPCOREINFO structure immediately follows the
\r
528 BITMAPFILEHEADER structure in the DIB file.
\r
532 BITMAPCOREINFO, BITMAPINFO
\r
535 ==============================================================================
\r
540 typedef struct tagBITMAPINFO { /* bmi */
\r
541 BITMAPINFOHEADER bmiHeader;
\r
542 RGBQUAD bmiColors[1];
\r
545 The BITMAPINFO structure fully defines the dimensions and color information
\r
546 for a Windows 3.0 or later device-independent bitmap (DIB).
\r
550 bmiHeader Specifies a BITMAPINFOHEADER structure that contains
\r
551 information about the dimensions and color format of a DIB.
\r
553 bmiColors Specifies an array of RGBQUAD structures that define the
\r
554 colors in the bitmap.
\r
558 A Windows 3.0 or later DIB consists of two distinct parts: a BITMAPINFO
\r
559 structure, which describes the dimensions and colors of the bitmap, and an
\r
560 array of bytes defining the pixels of the bitmap. The bits in the array are
\r
561 packed together, but each scan line must be zero-padded to end on a LONG
\r
562 boundary. Segment boundaries, however, can appear anywhere in the bitmap. The
\r
563 origin of the bitmap is the lower-left corner.
\r
565 The biBitCount member of the BITMAPINFOHEADER structure determines the number
\r
566 of bits which define each pixel and the maximum number of colors in the
\r
567 bitmap. This member may be set to any of the following values:
\r
571 1 The bitmap is monochrome, and the bmciColors member must contain two
\r
572 entries. Each bit in the bitmap array represents a pixel. If the bit is
\r
573 clear, the pixel is displayed with the color of the first entry in the
\r
574 bmciColors table. If the bit is set, the pixel has the color of the second
\r
575 entry in the table.
\r
577 4 The bitmap has a maximum of 16 colors, and the bmciColors member
\r
578 contains 16 entries. Each pixel in the bitmap is represented by a four-bit
\r
579 index into the color table.
\r
581 For example, if the first byte in the bitmap is 0x1F, the byte represents two
\r
582 pixels. The first pixel contains the color in the second table entry, and the
\r
583 second pixel contains the color in the sixteenth table entry.
\r
585 8 The bitmap has a maximum of 256 colors, and the bmciColors member
\r
586 contains 256 entries. In this case, each byte in the array represents a
\r
589 24 The bitmap has a maximum of 2^24 colors. The bmciColors member is
\r
590 NULL, and each 3-byte sequence in the bitmap array represents the relative
\r
591 intensities of red, green, and blue, respectively, of a pixel.
\r
593 The biClrUsed member of the BITMAPINFOHEADER structure specifies the number
\r
594 of color indexes in the color table actually used by the bitmap. If the
\r
595 biClrUsed member is set to zero, the bitmap uses the maximum number of colors
\r
596 corresponding to the value of the biBitCount member.
\r
598 The colors in the bmiColors table should appear in order of importance.
\r
599 Alternatively, for functions that use DIBs, the bmiColors member can be an
\r
600 array of 16-bit unsigned integers that specify an index into the currently
\r
601 realized logical palette instead of explicit RGB values. In this case, an
\r
602 application using the bitmap must call DIB functions with the wUsage
\r
603 parameter set to DIB_PAL_COLORS.
\r
605 Note: The bmiColors member should not contain palette indexes if the bitmap
\r
606 is to be stored in a file or transferred to another application. Unless the
\r
607 application uses the bitmap exclusively and under its complete control, the
\r
608 bitmap color table should contain explicit RGB values.
\r
612 BITMAPINFOHEADER, RGBQUAD
\r
614 ==============================================================================
\r
615 BITMAPINFOHEADER (3.0)
\r
619 typedef struct tagBITMAPINFOHEADER { /* bmih */
\r
625 DWORD biCompression;
\r
627 LONG biXPelsPerMeter;
\r
628 LONG biYPelsPerMeter;
\r
630 DWORD biClrImportant;
\r
631 } BITMAPINFOHEADER;
\r
633 The BITMAPINFOHEADER structure contains information about the dimensions and
\r
634 color format of a Windows 3.0 or later device-independent bitmap (DIB).
\r
638 biSize Specifies the number of bytes required by the
\r
639 BITMAPINFOHEADER structure.
\r
641 biWidth Specifies the width of the bitmap, in pixels.
\r
642 biHeightSpecifies the height of the bitmap, in pixels.
\r
644 biPlanesSpecifies the number of planes for the target device. This
\r
645 member must be set to 1.
\r
647 biBitCount Specifies the number of bits per pixel. This value must be 1,
\r
650 biCompression Specifies the type of compression for a compressed bitmap. It
\r
651 can be one of the following values:
\r
655 BI_RGB Specifies that the bitmap is not compressed.
\r
657 BI_RLE8 Specifies a run-length encoded format for bitmaps with 8 bits
\r
658 per pixel. The compression format is a 2-byte format consisting of a count
\r
659 byte followed by a byte containing a color index. For more information, see
\r
660 the following Comments section.
\r
662 BI_RLE4 Specifies a run-length encoded format for bitmaps with 4 bits
\r
663 per pixel. The compression format is a 2-byte format consisting of a count
\r
664 byte followed by two word-length color indexes. For more information, see
\r
665 the following Comments section.
\r
667 biSizeImage Specifies the size, in bytes, of the image. It is valid to
\r
668 set this member to zero if the bitmap is in the BI_RGB format.
\r
670 biXPelsPerMeter Specifies the horizontal resolution, in pixels per meter, of
\r
671 the target device for the bitmap. An application can use this value to select
\r
672 a bitmap from a resource group that best matches the characteristics of the
\r
675 biYPelsPerMeter Specifies the vertical resolution, in pixels per meter, of
\r
676 the target device for the bitmap.
\r
678 biClrUsed Specifies the number of color indexes in the color table
\r
679 actually used by the bitmap. If this value is zero, the bitmap uses the
\r
680 maximum number of colors corresponding to the value of the biBitCount member.
\r
681 For more information on the maximum sizes of the color table, see the
\r
682 description of the BITMAPINFO structure earlier in this topic.
\r
684 If the biClrUsed member is nonzero, it specifies the actual number of colors
\r
685 that the graphics engine or device driver will access if the biBitCount
\r
686 member is less than 24. If biBitCount is set to 24, biClrUsed specifies the
\r
687 size of the reference color table used to optimize performance of Windows
\r
688 color palettes. If the bitmap is a packed bitmap (that is, a bitmap in which
\r
689 the bitmap array immediately follows the BITMAPINFO header and which is
\r
690 referenced by a single pointer), the biClrUsed member must be set to zero or
\r
691 to the actual size of the color table.
\r
693 biClrImportant Specifies the number of color indexes that are considered
\r
694 important for displaying the bitmap. If this value is zero, all colors are
\r
699 The BITMAPINFO structure combines the BITMAPINFOHEADER structure and a color
\r
700 table to provide a complete definition of the dimensions and colors of a
\r
701 Windows 3.0 or later DIB. For more information about specifying a Windows 3.0
\r
702 DIB, see the description of the BITMAPINFO structure.
\r
704 An application should use the information stored in the biSize member to
\r
705 locate the color table in a BITMAPINFO structure as follows:
\r
707 pColor = ((LPSTR) pBitmapInfo + (WORD) (pBitmapInfo->bmiHeader.biSize))
\r
709 Windows supports formats for compressing bitmaps that define their colors
\r
710 with 8 bits per pixel and with 4 bits per pixel. Compression reduces the disk
\r
711 and memory storage required for the bitmap. The following paragraphs describe
\r
716 When the biCompression member is set to BI_RLE8, the bitmap is compressed
\r
717 using a run-length encoding format for an 8-bit bitmap. This format may be
\r
718 compressed in either of two modes: encoded and absolute. Both modes can occur
\r
719 anywhere throughout a single bitmap.
\r
721 Encoded mode consists of two bytes: the first byte specifies the number of
\r
722 consecutive pixels to be drawn using the color index contained in the second
\r
723 byte. In addition, the first byte of the pair can be set to zero to indicate
\r
724 an escape that denotes an end of line, end of bitmap, or a delta. The
\r
725 interpretation of the escape depends on the value of the second byte of the
\r
726 pair. The following list shows the meaning of the second byte:
\r
732 2 Delta. The two bytes following the escape contain unsigned values
\r
733 indicating the horizontal and vertical offset of the next pixel from the
\r
736 Absolute mode is signaled by the first byte set to zero and the second byte
\r
737 set to a value between 0x03 and 0xFF. In absolute mode, the second byte
\r
738 represents the number of bytes that follow, each of which contains the color
\r
739 index of a single pixel. When the second byte is set to 2 or less, the escape
\r
740 has the same meaning as in encoded mode. In absolute mode, each run must be
\r
741 aligned on a word boundary. The following example shows the hexadecimal
\r
742 values of an 8-bit compressed bitmap:
\r
746 03 04 05 06 00 03 45 56 67 00 02 78 00 02 05 01
\r
747 02 78 00 00 09 1E 00 01
\r
749 This bitmap would expand as follows (two-digit values represent a color index
\r
750 for a single pixel):
\r
758 move current position 5 right and 1 down
\r
761 1E 1E 1E 1E 1E 1E 1E 1E 1E
\r
766 When the biCompression member is set to BI_RLE4, the bitmap is compressed
\r
767 using a run-length encoding (RLE) format for a 4-bit bitmap, which also uses
\r
768 encoded and absolute modes. In encoded mode, the first byte of the pair
\r
769 contains the number of pixels to be drawn using the color indexes in the
\r
770 second byte. The second byte contains two color indexes, one in its
\r
771 high-order nibble (that is, its low-order four bits) and one in its low-order
\r
772 nibble. The first of the pixels is drawn using the color specified by the
\r
773 high-order nibble, the second is drawn using the color in the low-order
\r
774 nibble, the third is drawn with the color in the high-order nibble, and so
\r
775 on, until all the pixels specified by the first byte have been drawn. In
\r
776 absolute mode, the first byte contains zero, the second byte contains the
\r
777 number of color indexes that follow, and subsequent bytes contain color
\r
778 indexes in their high- and low-order nibbles, one color index for each pixel.
\r
779 In absolute mode, each run must be aligned on a word boundary. The
\r
780 end-of-line, end-of-bitmap, and delta escapes also apply to BI_RLE4.
\r
782 The following example shows the hexadecimal values of a 4-bit compressed
\r
787 03 04 05 06 00 06 45 56 67 00 04 78 00 02 05 01
\r
788 04 78 00 00 09 1E 00 01
\r
790 This bitmap would expand as follows (single-digit values represent a color
\r
791 index for a single pixel):
\r
799 move current position 5 right and 1 down
\r
809 ==============================================================================
\r
814 typedef struct tagRGBQUAD { /* rgbq */
\r
821 The RGBQUAD structure describes a color consisting of relative intensities of
\r
822 red, green, and blue. The bmiColors member of the BITMAPINFO structure
\r
823 consists of an array of RGBQUAD structures.
\r
827 rgbBlue Specifies the intensity of blue in the color.
\r
828 rgbGreenSpecifies the intensity of green in the color.
\r
829 rgbRed Specifies the intensity of red in the color.
\r
830 rgbReserved Not used; must be set to zero.
\r
836 ==============================================================================
\r
839 COLORREF RGB(cRed, cGreen, cBlue)
\r
841 BYTE cRed; /* red component of color */
\r
842 BYTE cGreen; /* green component of color */
\r
843 BYTE cBlue; /* blue component of color */
\r
846 The RGB macro selects an RGB color based on the parameters supplied and the
\r
847 color capabilities of the output device.
\r
849 Parameter Description
\r
851 cRed Specifies the intensity of the red color field.
\r
852 cGreen Specifies the intensity of the green color field.
\r
853 cBlue Specifies the intensity of the blue color field.
\r
857 The return value specifies the resultant RGB color.
\r
861 The intensity for each argument can range from 0 through 255. If all three
\r
862 intensities are specified as zero, the result is black. If all three
\r
863 intensities are specified as 255, the result is white.
\r
867 The RGB macro is defined in WINDOWS.H as follows:
\r
871 #define RGB(r,g,b) ((COLORREF)(((BYTE)(r)|((WORD)(g)<<8))| \
\r
872 (((DWORD)(BYTE)(b))<<16)))
\r
876 GetBValue, GetGValue, GetRValue, PALETTEINDEX, PALETTERGB
\r
878 ==============================================================================
\r
879 BITMAPCOREINFO (3.0)
\r
883 typedef struct tagBITMAPCOREINFO { /* bmci */
\r
884 BITMAPCOREHEADER bmciHeader;
\r
885 RGBTRIPLE bmciColors[1];
\r
888 The BITMAPCOREINFO structure fully defines the dimensions and color
\r
889 information for a device-independent bitmap (DIB). Windows applications
\r
890 should use the BITMAPINFO structure instead of BITMAPCOREINFO whenever
\r
895 bmciHeader Specifies a BITMAPCOREHEADER structure that contains
\r
896 information about the dimensions and color format of a DIB.
\r
898 bmciColors Specifies an array of RGBTRIPLE structures that define the
\r
899 colors in the bitmap.
\r
903 The BITMAPCOREINFO structure describes the dimensions and colors of a bitmap.
\r
904 It is followed immediately in memory by an array of bytes which define the
\r
905 pixels of the bitmap. The bits in the array are packed together, but each
\r
906 scan line must be zero-padded to end on a LONG boundary. Segment boundaries,
\r
907 however, can appear anywhere in the bitmap. The origin of the bitmap is the
\r
910 The bcBitCount member of the BITMAPCOREHEADER structure determines the number
\r
911 of bits that define each pixel and the maximum number of colors in the
\r
912 bitmap. This member may be set to any of the following values:
\r
916 1 The bitmap is monochrome, and the bmciColors member must contain two
\r
917 entries. Each bit in the bitmap array represents a pixel. If the bit is
\r
918 clear, the pixel is displayed with the color of the first entry in the
\r
919 bmciColors table. If the bit is set, the pixel has the color of the second
\r
920 entry in the table.
\r
922 4 The bitmap has a maximum of 16 colors, and the bmciColors member
\r
923 contains 16 entries. Each pixel in the bitmap is represented by a four-bit
\r
924 index into the color table.
\r
926 For example, if the first byte in the bitmap is 0x1F, the byte represents two
\r
927 pixels. The first pixel contains the color in the second table entry, and the
\r
928 second pixel contains the color in the sixteenth table entry.
\r
930 8 The bitmap has a maximum of 256 colors, and the bmciColors member
\r
931 contains 256 entries. In this case, each byte in the array represents a
\r
934 24 The bitmap has a maximum of 2^24 colors. The bmciColors member is
\r
935 NULL, and each 3-byte sequence in the bitmap array represents the relative
\r
936 intensities of red, green, and blue, respectively, of a pixel.
\r
938 The colors in the bmciColors table should appear in order of importance.
\r
939 Alternatively, for functions that use DIBs, the bmciColors member can be an
\r
940 array of 16-bit unsigned integers that specify an index into the currently
\r
941 realized logical palette instead of explicit RGB values. In this case, an
\r
942 application using the bitmap must call DIB functions with the wUsage
\r
943 parameter set to DIB_PAL_COLORS.
\r
945 Note: The bmciColors member should not contain palette indexes if the
\r
946 bitmap is to be stored in a file or transferred to another application.
\r
947 Unless the application uses the bitmap exclusively and under its complete
\r
948 control, the bitmap color table should contain explicit RGB values.
\r
952 BITMAPINFO, BITMAPCOREHEADER, RGBTRIPLE
\r
955 ==============================================================================
\r
956 BITMAPCOREHEADER (3.0)
\r
960 typedef struct tagBITMAPCOREHEADER { /* bmch */
\r
966 } BITMAPCOREHEADER;
\r
968 The BITMAPCOREHEADER structure contains information about the dimensions and
\r
969 color format of a device-independent bitmap (DIB). Windows applications
\r
970 should use the BITMAPINFOHEADER structure instead of BITMAPCOREHEADER
\r
975 bcSize Specifies the number of bytes required by the
\r
976 BITMAPCOREHEADER structure.
\r
978 bcWidth Specifies the width of the bitmap, in pixels.
\r
979 bcHeightSpecifies the height of the bitmap, in pixels.
\r
981 bcPlanesSpecifies the number of planes for the target device. This
\r
982 member must be set to 1.
\r
984 bcBitCount Specifies the number of bits per pixel. This value must be 1,
\r
989 The BITMAPCOREINFO structure combines the BITMAPCOREHEADER structure and a
\r
990 color table to provide a complete definition of the dimensions and colors of
\r
991 a DIB. See the description of the BITMAPCOREINFO structure for more
\r
992 information about specifying a DIB.
\r
994 An application should use the information stored in the bcSize member to
\r
995 locate the color table in a BITMAPCOREINFO structure with a method such as
\r
1000 lpColor = ((LPSTR) pBitmapCoreInfo + (UINT) (pBitmapCoreInfo->bcSize))
\r
1004 BITMAPCOREINFO, BITMAPINFOHEADER, BITMAPINFOHEADER
\r
1006 =============================================================================
\r
1011 typedef struct tagRGBTRIPLE { /* rgbt */
\r
1017 The RGBTRIPLE structure describes a color consisting of relative intensities
\r
1018 of red, green, and blue. The bmciColors member of the BITMAPCOREINFO
\r
1019 structure consists of an array of RGBTRIPLE structures. Windows applications
\r
1020 should use the BITMAPINFO structure instead of BITMAPCOREINFO whenever
\r
1021 possible. The BITMAPINFO structure uses an RGBQUAD structure instead of the
\r
1022 RGBTRIPLE structure.
\r
1024 Member Description
\r
1026 rgbtBlueSpecifies the intensity of blue in the color.
\r
1027 rgbtGreen Specifies the intensity of green in the color.
\r
1028 rgbtRed Specifies the intensity of red in the color.
\r
1032 BITMAPCOREINFO, BITMAPINFO, RGBQUAD
\r
1034 ==============================================================================
\r