Graphics File Formats
This Topic Describes The Graphics-File Formats Used by The Microsoft WindowsOperating System. Graphics Files Include Bitmap Files, Icon-Resource Files, and Cursor-Resource Files.
Bitmap-file formats
Windows bitmap files are stored in a device-independent bitmap (DIB) formatthat allows Windows to display the bitmap on any type of display device. Theterm "device independent" means that the bitmap specifies pixel color in aform independent of the method used by a display TO Represent Color. TheDefault FileName Extension of A Windows Dib file is .bmp.
Bitmap-File Structure
Each Bitmap File Contains A Bitmap-File HEADER, A Bitmap-Information Header, a Color Table, And An Array Of bytes That Defines The Bitmap Bits. The FileHas The Following Form:
BitmapfileHeader BMFH; BitmapInfoHeader Bmih; Rgbquad Acolors []; Byte Abitmapbits [];
The Bitmap-File HEPE, SIZE, AND LAYOUTOF A Device-Independent Bitmap File. The header is defined as anibitmapfileheader structure.
.
The color table, defined as an array of RGBQUAD structures, contains as manyelements as there are colors in the bitmap. The color table is not presentfor bitmaps with 24 color bits because each pixel is represented by 24-bitred-green-blue (RGB) values in the actual bitmap data area. The colors in thetable should appear in order of importance. This helps a display driverrender a bitmap on a device that can not display as many colors as there arein the bitmap. If the DIB is in Windows version 3.0 or later format, thedriver can use the biClrImportant member of the BITMAPINFOHEADER structure todetermine which colors are important.The BITMAPINFO structure can be used to represent a combinedbitmap-information header and color table. The bitmap bits, immediatelyfollowing the color table, consist of an array of BYTE VALUES REPRESENTIONINGCONSECUTIVE ROWS, OR "Scan Lines," of the bitmap. Each Scan Line Consists Offers in The Scan Line, In Left-to-RightOrder. TH e number of bytes representing a scan line depends on the colorformat and the width, in pixels, of the bitmap. If necessary, a scan linemust be zero-padded to end on a 32-bit boundary. However, segment boundariescan appear anywhere in the bitmap. The scan lines in the bitmap are storedfrom bottom up. This means that the first byte in the array represents thepixels in the lower-left corner of the bitmap and the last byte representsthe pixels in the upper-right corner.
The biBitCount member of the BITMAPINFOHEADER structure determines the numberof bits that define each pixel and the maximum number of colors in thebitmap These members can have any of the following values.:
Value meaning
1 Bitmap is monochrome and the color table contains two entries. Eachbit in the bitmap array represents a pixel. If the bit is clear, the pixel isdisplayed with the color of the first entry in the color table. If the bit isset, the pixel has the color of the second entry in the table.4 Bitmap has a maximum of 16 colors. Each pixel in the bitmap isrepresented by a 4-bit index into the color table. For example, if the firstbyte in the bitmap is 0x1F, the byte ........................
8 Bitmap has a maximum of 256 colors. Each pixel in the bitmap isrepresented by a 1-byte index into the color table. For example, if the firstbyte in the bitmap is 0x1F, the first pixel has the color of thethirty-second table entry .
24 Bitmap has a maximum of 2 ^ 24 colors. The bmiColors (or bmciColors) member is NULL, and each 3-byte sequence in the bitmap array represents therelative intensities of red, green, and blue, respectively, for a pixel.
The biClrUsed member of the BITMAPINFOHEADER structure specifies the numberof color indexes in the color table actually used by the bitmap. If thebiClrUsed member is set to zero, the bitmap uses the maximum number of colorscorresponding to the value of the biBitCount member. An alternative form ofbitmap File Uses The BitmapcoreInfo, Bitmapcoreheader, And RGBtriplestructure.
Bitmap compression
Windows Versions 3.0 and Later Support Run-Length Encoded (RLE) Formats Forcompressing Bitmaps That Use 4 Bits Per Pixel and 8 Bits Per Pixel.comPression Reduces The Disk and Memory Storage Required for a bitmap.
Compression of 8-Bits-Per-Pixel Bitmaps
When the biCompression member of the BITMAPINFOHEADER structure is set toBI_RLE8, the DIB is compressed using a run-length encoded format for a256-color bitmap This format uses two modes:. Encoded mode and absolute mode.Both modes can occur anywhere throughout a single bitmap .Encoded mode
A unit of information in encoded mode consists of two bytes. The first bytespecifies the number of consecutive pixels to be drawn using the color indexcontained in the second byte. The first byte of the pair can be set to zeroto indicate an escape that denotes the end of a line, the end of the bitmap, or a delta. The interpretation of the escape depends on the value of thesecond byte of the pair, which must be in the range 0x00 through 0x02.Following are the meanings of the escape values that can BE Used in thiscond byte:
SECOND BYTE meaning
0 End of line. 2 Delta. The Two Bytes Following The Escape Contain Unsigned Valuesindicating The Horizontal and Vertical Offsets of The next Pixel from thecurrent position.
Absolute Mode
Absolute mode is signaled by the first byte in the pair being set to zero andthe second byte to a value between 0x03 and 0xFF. The second byte representsthe number of bytes that follow, each of which contains the color index of asingle pixel. Each run must BE Aligned On a Word Boundary. Following IS Anexample of An 8-Bit Rle Bitmap (The Two-Digit Hexadecimal Values in Thesecond Column Represent A Color Index for a Single Pixel):
Compressed Data Expanded Data
03 04 04 04 06 06 06 06 06 06 00 03 45 56 67 00 45 56 67 02 78 78 78 00 02 05 01 Move 5 Right and 1 Down 02 78 78 78 00 00 end of line 09 1e 1e 1e 1e 1e 1e 1e 1e 1e 1e 00 01 End of Rle Bitmapcompression of 4-Bits-Per-Pixel Bitmaps
When the biCompression member of the BITMAPINFOHEADER structure is set toBI_RLE4, the DIB is compressed using a run-length encoded format for a16-color bitmap This format uses two modes:. Encoded mode and absolute mode.
Encoded mode
A UNIT OF INFORMATION IN ENCODED MODE CONSISTS OF TWO BYTES. The first byteof the pair contains the number of pixels to be drawn using the color indexesin the second byte.
The Second Byte Contains Two Color Indexes, One In Its High-Order Nibble (That IS, ITS Low-Order 4 Bits) and one in its low-order nibble.
The first pixel is drawn using the color specified by the high-order nibble, the second is drawn using the color in the low-order nibble, the third isdrawn with the color in the high-order nibble, and so on, until all thepixels Specified by The First byte Have Been Drawn.
The first byte of the pair can be set to zero to indicate an escape thatdenotes the end of a line, the end of the bitmap, or a delta. Theinterpretation of the escape depends on the value of the second byte of thepair. In encoded mode ...................... ..
Absolute Mode
In absolute mode, the first byte contains zero, the second byte contains thenumber of color indexes that follow, and subsequent bytes contain colorindexes in their high- and low-order nibbles, one color index for each pixel.Each run must be aligned on a Word Boundary.Following IS An Example of A 4-Bit Rle Bitmap (The One-Digit Hexadecimalvalues in The Second Column Represent A Color Index for a Single Pixel):
Compressed Data Expanded Data
03 04 0 4 005 06 0 6 0 6 0 00 06 45 56 67 00 4 5 5 6 6 7 04 78 7 8 7 8 00 02 05 01 MOVE 5 Right and 1 Down 04 78 7 8 7 8 00 00 e line 09 1e 1 E 1 E 1 E 1 E 1 00 01 End of Rle Bitmap
Bitmap Example
The Following Example Is A Text Dump of A 16-Color Bitmap:
Win3Dibfile BitmapfileHeader Type 19778 Size 3118 Reserved1 0 reserved2 0 OffsetBits 118 BitmapInfoHeader Size 40 Width 80 HEIGHT 75 Planes 1 Bitcount 4 Compression 0 SizeImage 3000
XPelsPerMeter 0 YPelsPerMeter 0 ColorsUsed 16 ColorsImportant 16 Win3ColorTable Blue Green Red Unused [00000000] 84 252 84 0 [00000001] 252 252 84 0 [00000002] 84 84 252 0 [00000003] 252 84 252 0 [00000004] 84 252 252 0 [00000005 ] 252 252 252 0 [00000006] 0 0 0 0 [00000008] 0 168 0 0 [00000009] 168 168 0 0 [0000000A] 0 0 168 0 [0000000B] 168 0 168 0 [0000000c] 0 168 168 0 [0000000D] 168 168 168 0 [0000000E] 84 84 84 0 [0000000F] 252 84 84 0 Image.. Bitmap Data .icon-Resource File Format
An icon-resource file contains image data for icons used by Windowsapplications. The file consists of an icon directory identifying the numberand types of icon images in the file, plus one or more icon images. Thedefault filename extension for an icon-resource file is. ICO.
Icon Directory
. Each icon-resource file starts with an icon directory The icon directory, defined as an ICONDIR structure, specifies the number of icons in theresource and the dimensions and color format of each icon image The ICONDIRstructure has the following form.:
Typedef struct icondir {Word IDReServed; Word IDTYPE; ICONDIRENTRY IDENTRIES [1];} iconheader;
Following Are the Members in the icondir structure:
idReserved Reserved;.. must be zero idType Specifies the resource type This member is set to 1. idCount Specifies the number of entries in the directory idEntries Specifies an array of ICONDIRENTRY structures containinginformation about individual icons The idCount member specifies the numberof structures in.. The Array.The IconDirentry Structure Specifier The Dimensions and Color Format for Anicon. The Structure Has The Following Form:
Struct iCondirectoryEntry {byte bwidth; Byte Bheight; Byte Breserved; Word Word Wbit; DWORD DWBYTESINRES; DWORD DWIMAGEOFFSET;
FOLLOWING Are The Members in The IconDirentry Structure:
BWidth Specifies The Width of The Icon, in Pixels. Acceptable Valuesare 16, 32, And 64.
BHEIGHT SPECIFIES The Height of the Icon, in Pixels. AcceptableValues Are 16, 32, and 64.
Bcolorcount Specifier The Number of Colors in The icon. Acceptable Valuesare 2, 8, And 16.
bReserved Reserved;... must be zero wPlanes Specifies the number of color planes in the icon bitmap wBitCount Specifies the number of bits in the icon bitmap dwBytesInRes Specifies the size of the resource, in bytes dwImageOffset Specifies the offset, in bytes, from. The beginning of the the the icon image.
Icon Image
Each icon-resource file contains one icon image for each image identified inthe icon directory An icon image consists of an icon-image header, a colortable, an XOR mask, and an AND mask The icon image has the following form..:
Bitmapinfoheader ichead; rgbquad iccolors []; byte icxor []; byte icand [];
The icon-image header, defined as a BITMAPINFOHEADER structure, specifies thedimensions and color format of the icon bitmap. Only the biSize throughbiBitCount members and the biSizeImage member are used. All other members (such as biCompression and biClrImportant) must be set to zero. The color table, defined as an array of RGBQUAD structures, specifies thecolors used in the XOR mask. As with the color table in a bitmap file, thebiBitCount member in the icon-image header determines the number of elementsin the array. For more information about The Color Table, See Section 1.1, "Bitmap-file Formats."
The XOR mask, immediately following the color table, is an array of BYTEvalues representing consecutive rows of a bitmap. The bitmap defines thebasic shape and color of the icon image. As with the bitmap bits in a bitmapfile, the bitmap data in an icon- Resource File Is Organized in Scan Lines, With Byte Repensenting One or More Pixels, As Defined by The Colorformat. for More Information About these Bitmap Bits, See Section 1.1, "Bitmap-file formats."
The AND mask, immediately following the XOR mask, is an array of BYTE values, representing a monochrome bitmap with the same width and height as the XORmask. The array is organized in scan lines, with each byte representing 8pixels.
When Windows draws an icon, it uses the AND and XOR masks to combine the iconimage with the pixels already on the display surface Windows first appliesthe AND mask by using a bitwise AND operation;.. This preserves or removesexisting pixel color Windows then applies the XOR Mask by using a bitwisexor Operation. This Sets The final color for Each Pixel.
The Following Illustration Shows The XOR AND and MASKS That Create Amonochrome icon (Measuring 8 Pixels By 8 Pixels) In The Form of An Uppercasek: Windows Icon Selection
Windows detects the resolution of the current display and matches it againstthe width and height specified for each version of the icon image. If Windowsdetermines that there is an exact match between an icon image and the currentdevice, it uses the matching image. Otherwise, it selects The closest matchand stretches the Image to the property size.
If an icon-resource file contains more than one image for a particularresolution, Windows uses the icon image that most closely matches the colorcapabilities of the current display. If no image matches the devicecapabilities exactly, Windows selects the image that has the greatest numberof colors without EXCEEDING The Number Of Display Colors. IMAGESEXCEED The Color Capabilities of The Current Display, Windows Uses The iconimage with the Least Number of Colors.
Cursor-Resource File Format
A cursor-resource file contains image data for cursors used by Windowsapplications. The file consists of a cursor directory identifying the numberand types of cursor images in the file, plus one or more cursor images. Thedefault filename extension for a cursor-resource file is. Cur.
Cursor Directory
.. Each cursor-resource file starts with a cursor directory The cursordirectory, defined as a CURSORDIR structure, specifies the number of cursorsin the file and the dimensions and color format of each cursor image TheCURSORDIR structure has the following form:
Typedef struct _cursordir {word cdreserved; word cdtype; word cdcount; cursordirentry cdentries [];
Following are the members in the CURSORDIR structure: cdReserved Reserved; must be zero cdType Specifies the resource type This member must be set to 2. cdCount Specifies the number of cursors in the file cdEntries Specifies an array of CURSORDIRENTRY structures containinginformation about individual... Cursors. The cdcount member specifies the numberof structure in the array.
A Cursordirentry Structure Specifies The Dimensions and Color Format of Acursor Image. The Structure Has The Following Form:
Typedef struntry {byte bwidth; byte bheight; byte bcolorcount; byte breserved; word wxhotspot; word wyhotspot; dword lbytesinres; dword dwimageoffset;
FOLLOWING ARE The Members in The Cursordirentry Structure:
bWidth Specifies the width of the cursor, in pixels bHeight Specifies the height of the cursor, in pixels bColorCount Reserved;.. must be zero bReserved Reserved;. must be zero.wXHotspot Specifies the x-coordinate, in pixels, of the hot spot . wYHotspot Specifies the y-coordinate, in pixels, of the hot spot. lBytesInRes Specifies the size of the resource, in bytes. dwImageOffset Specifies the offset, in bytes, from the start of the file tothe cursor image.
Cursor Image
. Each cursor-resource file contains one cursor image for each image identifiedin the cursor directory A cursor image consists of a cursor-image header, acolor table, an XOR mask, and an AND mask The cursor image has the followingform.:
BitmapInfoheader Crheader; Rgbquad Crcolors []; byte crxor []; byte crand [];
The cursor hot spot is a single pixel in the cursor bitmap that Windows usesto track the cursor. The crXHotspot and crYHotspot members specify the x- andy-coordinates of the cursor hot spot. These coordinates are 16-bit integers.The cursor-image header , defined as a BITMAPINFOHEADER structure, specifiesthe dimensions and color format of the cursor bitmap. Only the biSize throughbiBitCount members and the biSizeImage member are used. The biHeight memberspecifies the combined height of the XOR and aND masks for the cursor. Thisvalue is twice the height The xor mask. The Biplanes and Bibitcountmembers Must Be 1. All Other Members (Such as Bicompression andbiClrimportant) Must Be Set To Zero.
The color table, defined as an array of RGBQUAD structures, specifies thecolors used in the XOR mask. For a cursor image, the table contains exactlytwo structures, since the biBitCount member in the cursor-image header isalways 1.
The XOR mask, immediately following the color table, is an array of BYTEvalues representing consecutive rows of a bitmap. The bitmap defines thebasic shape and color of the cursor image. As with the bitmap bits in abitmap file, the bitmap data in a cursor- Resource File Is Organized in Scanlines, With Byte Representing One or More Pixels, As Defined by Thecilor Format. for More Information About These Bitmap Bits, See Section 1.1, "Bitmap-file formats."
The AND mask, immediately following the XOR mask, is an array of BYTE valuesrepresenting a monochrome bitmap with the same width and height as the XORmask. The array is organized in scan lines, with each byte representing 8pixels.
When Windows draws a cursor, it uses the AND and XOR masks to combine thecursor image with the pixels already on the display surface Windows firstapplies the AND mask by using a bitwise AND operation;. This preserves orremoves existing pixel color Window then applies the XOR. Mask by using Abitwise xor Operation. This set The final color for Each Pixel.The Following Illustration Shows The xor and the and masks That Create Acursor (Measuring 8 Pixels By 8 Pixels) In The Form of an Arrow:
FOLLOWING ARE The Bit-Mask Values Necessary To Produce Black, White, Inveted, and Transparent Results:
Pixel Result and Maskxor Mask
Black 0 0 White 0 1 Transparent 1 0 Inverted1 1
Windows Cursor Selection
IF a Cursor-Resource File Contain More Than ONE CURSOR Image, WindowsDetermines The Best Match for a Particular Display by Examining The Width andHeight of The Cursor images.
============================================================================================================================================================================================================= ============================
BitmapfileHeader (3.0)
Typedef struct tagbitmapfileheader {/ * bmfh * / uint bftype; dword bfSize; uint bfreserved1; uint bfreserved2; dword bfoffbits;} BitmapFileHeader;
The BitmapfileHeader Structure Contains Information About The Type, Size, ANDLAYOUT OF A Device-Independent Bitmap (DIB) file.
MEMBER DESCRIPTION
.. BfType Specifies the type of file This member must be BM bfSize Specifies the size of the file, in bytes bfReserved1 Reserved;. Must be set to zero bfReserved2 Reserved;. Must be set to zero.bfOffBits Specifies the byte offset from the BITMAPFILEHEADER Structureto the actual bitmap data in the file.comments
A BitmapInfo Or BitmapcoreInfo Structure Immediately Follows ThebitmapfileHeader Structure In The Dib file.
See Also
BitmapcoreInfo, BitmapInfo
============================================================================================================================================================================================================= ============================ BitmapInfo (3.0)
Typedef struct tagbitmapinfo {/ * bmi * / bitmapinfoheader bmihead; rgbquad bmicolors [1];} BitmapInfo;
.
MEMBER DESCRIPTION
Bmiheader Specifies A BitmapInfoheader Structure That ContainSinformation About The Dimensions and Color Format of A Dib.
BMicolors Specifies An Array of Rgbquad Structures That Define Thecolors in The Bitmap.
Comments
A Windows 3.0 or later DIB consists of two distinct parts: a BITMAPINFOstructure, which describes the dimensions and colors of the bitmap, and anarray of bytes defining the pixels of the bitmap The bits in the array arepacked together, but each scan line must be. zero-padded to end on a LONGboundary. Segment boundaries, however, can appear anywhere in the bitmap. Theorigin of the bitmap is the lower-left corner.The biBitCount member of the BITMAPINFOHEADER structure determines the numberof bits which define each pixel and the maximum Number of colors in thebitmap. this Member May Be set to any of the folload value:
Value meaning
1 The bitmap is monochrome, and the bmciColors member must contain twoentries. Each bit in the bitmap array represents a pixel. If the bit isclear, the pixel is displayed with the color of the first entry in thebmciColors table. If the bit is set, The Pixel Has The Color of The Secondentry in The Table.
4 The Bitmap Has a Maximum of 16 Colors, And The Bmcicolors Membercontains 16 Entries. Each Pixel in The Bitmap IS Represented by A Four-BitIndex INTO The Color Table.
For example, if the first byte in the bitmap is 0x1F, the byte represents twopixels. The first pixel contains the color in the second table entry, and thesecond pixel contains the color in the sixteenth table entry.
..................................... ..
24 The bitmap has a maximum of 2 ^ 24 colors. The bmciColors member isNULL, and each 3-byte sequence in the bitmap array represents the relativeintensities of red, green, and blue, respectively, of a pixel.
The biClrUsed member of the BITMAPINFOHEADER structure specifies the numberof color indexes in the color table actually used by the bitmap. If thebiClrUsed member is set to zero, the bitmap uses the maximum number of colorscorresponding to the value of the biBitCount member.The colors in the bmiColors table should appear in order of importance.Alternatively, for functions that use DIBs, the bmiColors member can be anarray of 16-bit unsigned integers that specify an index into the currentlyrealized logical palette instead of explicit RGB values. in this case, anapplication using The Bitmap Must Call Dib Functions with The WusageParameter Set To Dib_pal_colors.
Note: The bmiColors member should not contain palette indexes if the bitmapis to be stored in a file or transferred to another application Unless theapplication uses the bitmap exclusively and under its complete control, thebitmap color table should contain explicit RGB values..
See Also
BitmapInfoHeader, Rgbquad
============================================================================================================================================================================================================= ============================ BitmapInfoHeader (3.0)
typedef struct tagBITMAPINFOHEADER {/ * bmih * / DWORD biSize; LONG biWidth; LONG biHeight; WORD biPlanes; WORD biBitCount; DWORD biCompression; DWORD biSizeImage; LONG biXPelsPerMeter; LONG biYPelsPerMeter; DWORD biClrUsed; DWORD biClrImportant;} BITMAPINFOHEADER;
The BitmapInfoHeader Structure Contains Information About The Dimensions AndColor Format of A Windows 3.0 or Later Device-Independent Bitmap (DIB) .member Description
Bisize specifies the number of bytes required by thebitmapinfoheader structure.
.
BIPLANESSPECIFIES The Number of Plaso for the Target Device. This Member Must Be Set To 1.
BIBITCOUNT Specifies The Number of Bits Per Pixel. This value must be 1, 4, 8, or 24.
BiCompression Specifies The Type of Compression for a Compressed Bitmap. Itcan Be One of the Following Values:
Value meaning
Bi_RGB Specifies That The Bitmap is Not Compressed.
BI_RLE8 Specifies a run-length encoded format for bitmaps with 8 bitsper pixel. The compression format is a 2-byte format consisting of a countbyte followed by a byte containing a color index. For more information, seethe following Comments section.
BI_RLE4 Specifies a run-length encoded format for bitmaps with 4 bitsper pixel. The compression format is a 2-byte format consisting of a countbyte followed by two word-length color indexes. For more information, seethe following Comments section.
BisizeImage Specifier The size, in bytes, of the image. it is valid toset this member to zero if the bitmap is in the bi_rgb format.
biXPelsPerMeter Specifies the horizontal resolution, in pixels per meter, ofthe target device for the bitmap. An application can use this value to selecta bitmap from a resource group that best matches the characteristics of thecurrent device.
biYPelsPerMeter Specifies the vertical resolution, in pixels per meter, ofthe target device for the bitmap.biClrUsed Specifies the number of color indexes in the color tableactually used by the bitmap. If this value is zero, the bitmap uses themaximum number of colors corresponding to the .
If the biClrUsed member is nonzero, it specifies the actual number of colorsthat the graphics engine or device driver will access if the biBitCountmember is less than 24. If biBitCount is set to 24, biClrUsed specifies thesize of the reference color table used to optimize performance of Windowscolor palettes. If the bitmap is a packed bitmap (that is, a bitmap in whichthe bitmap array immediately follows the BITMAPINFO header and which isreferenced by a single pointer), the biClrUsed member must be set to zero orto the actual size of the color table .
BICLRIMPORTANT Specifies The Number of Color Indexes That Are ConsideredImportant for Displaying The Bitmap. if this value is Zero, All Colors Areimportant.
Comments
The BITMAPINFO structure combines the BITMAPINFOHEADER structure and a colortable to provide a complete definition of the dimensions and colors of aWindows 3.0 or later DIB. For more information about specifying a Windows 3.0DIB, see the description of the BITMAPINFO structure.
An Application Should Use The Information Stored in The Bisize Member Tolocate The Color Table in A BitmapInfo Structure As Follows:
Pcolor = ((LPSTR) PbitmapInfo (Word) (pbitmapinfo-> bmiheader.bisize))
Windows supports formats for compressing bitmaps that define their colorswith 8 bits per pixel and with 4 bits per pixel. Compression reduces the diskand memory storage required for the bitmap. The following paragraphs describethese formats.BI_RLE8
When the biCompression member is set to BI_RLE8, the bitmap is compressedusing a run-length encoding format for an 8-bit bitmap This format may becompressed in either of two modes:.. Encoded and absolute Both modes can occuranywhere throughout a single bitmap.
Encoded mode consists of two bytes: the first byte specifies the number ofconsecutive pixels to be drawn using the color index contained in the secondbyte In addition, the first byte of the pair can be set to zero to indicatean escape that denotes an end of line. , End of Bitmap, or a delta. Theinterpretation of the escape dends on the value of the second byte of thepair. The following list shows the meaning of the second byte:
Value meaning
0 End of line. 2 Delta. The Two Bytes Following The escape contain unsigned valueindicating the horizontal and vertical offset of the next pixel from thecurrent position.
Absolute mode is signaled by the first byte set to zero and the second byteset to a value between 0x03 and 0xFF. In absolute mode, the second byterepresents the number of bytes that follow, each of which contains the colorindex of a single pixel. When the second byte is set to 2 or less, the escapehas the same meaning as in encoded mode in absolute mode, each run must bealigned on a word boundary The following example shows the hexadecimalvalues of an 8-bit compressed bitmap..:
03 04 05 06 00 03 45 56 67 00 02 78 00 02 05 0102 78 00 00 09 1e 00 01
This bitmap would expand as follows (two-digit values represent a color indexfor a single pixel): 04 04 0406 06 06 06 0645 56 6778 78move current position 5 right and 1 down78 78end of line1E 1E 1E 1E 1E 1E 1E 1E 1Eend of RLE Bitmap
BI_RLE4
When the biCompression member is set to BI_RLE4, the bitmap is compressedusing a run-length encoding (RLE) format for a 4-bit bitmap, which also usesencoded and absolute modes. In encoded mode, the first byte of the paircontains the number of pixels to be drawn using the color indexes in thesecond byte. The second byte contains two color indexes, one in itshigh-order nibble (that is, its low-order four bits) and one in its low-ordernibble. The first of the pixels is drawn using the color specified by thehigh-order nibble, the second is drawn using the color in the low-ordernibble, the third is drawn with the color in the high-order nibble, and soon, until all the pixels specified by the first byte have been drawn. Inabsolute mode, the first byte contains zero, the second byte contains thenumber of color indexes that follow, and subsequent bytes contain colorindexes in their high- and low-order nibbles, one color index for each pixel.In absolute mode, Each Run Must Be Aligned ON A Word Boundary. theend-of-line, end-of-bitmap, and delta escapes also coply to bi_rle4.
The Following Example Shows The Hexadecimal Values of A 4-bit compressedbitMap:
03 04 05 06 00 06 45 56 67 00 04 78 00 02 05 0104 78 00 00 09 1e 00 01
This Bitmap Would Expand As Follows (Single-Digit Values Repesent A ColorIndex for a Single Pixel):
0 4 00 6 0 6 04 5 5 6 6 77 8 7 8Move Current Position 5 Right and 1 DOWN7 8 7 8End Of Line1 E 1 E 1 E 1 E 1END OF RLE Bitmap
See Also
BitmapInfo
============================================================================================================================================================================================================= ============================ rb (3.0) Typedef struct tagrgbquad {/ * rgbq * / byte rgbblue; Byte rgbgreen; byte rgbred; RGBRESERVED;} RGBQUAD;
The Rgbquad Structure Describes A Color Construction of Relative Intensities ofre, Green, And Blue. The Bmicolors Member of The BitmapInfo StructureConsistss of An Array of Rgbquad structures.
MEMBER DESCRIPTION
rgbBlue Specifies the intensity of blue in the color rgbGreenSpecifies the intensity of green in the color rgbRed Specifies the intensity of red in the color rgbReserved Not used;... must be set to zero.
See Also
BitmapInfo
============================================================================================================================================================================================================= ============================ rs (2.x)
ColorRef RGB (CRED, CGREEN, CBLUE)
BYTE CRED; / * Red Component of Color * / Byte CGreen; / * Green Component Of Color * / Byte CBLUE; / * Blue Component Of Color * /
.. '' '' '' '' '' '' '' '' '' '
Parameter Description
Cred Specifies The Intensity of The Green Color Field. CBLUE Specifies The Intensity of the Blue Color Field.returns
The Return Value Specifier The Resultant RGB Color.
Comments
The Intensity for Each Argument Can Range from 0 Through 255. IF All Threeintensities Are Specified As Zero, The Result Is Black. If All Threeintensity Are Specified As 255, The Result is White.
Comments
The RGB Macro Is Defined in Windows.h As Follows:
#define RGB (R, G, B) ((Byte) | ((Word) (G) << 8)) | / ((DWORD) (BYTE) (B)) < <16))))
See Also
GetBvalue, Getgvalue, GtrValue, Paletteindex, Palettergb
============================================================================================================================================================================================================= ============================ BitmapcoreInfo (3.0)
Typedef struct tagbitmapcoreInfo {/ * BMCI * / Bitmapcoreheader BMCIHeader; RGBTrIPLE BMCICOLORS [1];} BitmapcoreInfo;
The BITMAPCOREINFO structure fully defines the dimensions and colorinformation for a device-independent bitmap (DIB). Windows applicationsshould use the BITMAPINFO structure instead of BITMAPCOREINFO wheneverpossible.
MEMBER DESCRIPTION
BMCIHeader Specifies A Bitmapcoreheader Structure That ContainSinformation About The Dimensions and Color Format of A Dib.
Bmcicolors Specifies An Array of Rgbtriple Structures That Define Thecolors in The Bitmap.
Comments
The BITMAPCOREINFO structure describes the dimensions and colors of a bitmap.It is followed immediately in memory by an array of bytes which define thepixels of the bitmap. The bits in the array are packed together, but eachscan line must be zero-padded to end on a LONG boundary. Segment boundaries, however, can appear anywhere in the bitmap. The origin of the bitmap is thelower-left corner.The bcBitCount member of the BITMAPCOREHEADER structure determines the numberof bits that define each pixel and the maximum number of colors in thebitmap MEMBER May Be set to any of the folload value:
Value meaning
1 The bitmap is monochrome, and the bmciColors member must contain twoentries. Each bit in the bitmap array represents a pixel. If the bit isclear, the pixel is displayed with the color of the first entry in thebmciColors table. If the bit is set, The Pixel Has The Color of The Secondentry in The Table.
4 The Bitmap Has a Maximum of 16 Colors, And The Bmcicolors Membercontains 16 Entries. Each Pixel in The Bitmap IS Represented by A Four-BitIndex INTO The Color Table.
For example, if the first byte in the bitmap is 0x1F, the byte represents twopixels. The first pixel contains the color in the second table entry, and thesecond pixel contains the color in the sixteenth table entry.
..................................... ..
24 The bitmap has a maximum of 2 ^ 24 colors. The bmciColors member isNULL, and each 3-byte sequence in the bitmap array represents the relativeintensities of red, green, and blue, respectively, of a pixel.
The colors in the bmciColors table should appear in order of importance.Alternatively, for functions that use DIBs, the bmciColors member can be anarray of 16-bit unsigned integers that specify an index into the currentlyrealized logical palette instead of explicit RGB values. In this case, anapplication using the bitmap must call DIB functions with the wUsageparameter set to DIB_PAL_COLORS.Note: The bmciColors member should not contain palette indexes if thebitmap is to be stored in a file or transferred to another application.Unless the application uses the bitmap exclusively and Under ITS CompleteControl, The Bitmap Color Table Should Contain Explicit RGB VALUES.
See Also
BitmapInfo, Bitmapcoreheader, RGBTrIple
============================================================================================================================================================================================================= ============================ Bitmapcoreheader (3.0)
Typedef struct tagbitmapcorehead {/ * bmch * / dword bcsize; short bcwidth; short bcheight; word bcbitcount;} Bitmapcorehead;
The BITMAPCOREHEADER structure contains information about the dimensions andcolor format of a device-independent bitmap (DIB). Windows applicationsshould use the BITMAPINFOHEADER structure instead of BITMAPCOREHEADERwhenever possible.
MEMBER DESCRIPTION
BCSIZE SPECIFIES The Number of Bytes Required by Thebitmapcoreheader Structure.
BCWIDTH SPECIES The Width of The Bitmap, in Pixels. BcHeightspecifies The Height of the Bitmap, in Pixels.bcplanesspecifies The Number of Plaso For The Target Device. This.
BCBITCOUNT Specifier The Number of Bits Per Pixel. This value must be 1,4, 8, or 24.
Comments
The BITMAPCOREINFO structure combines the BITMAPCOREHEADER structure and acolor table to provide a complete definition of the dimensions and colors ofa DIB. See the description of the BITMAPCOREINFO structure for moreinformation about specifying a DIB.
An Application Should Use The Information Stored in The Bcsize Member Tolocate The Color Table in A BitmapcoreInfo Structure with a Method Such Asthe Following:
LpColor = ((lpstr) PbitmapcoreInfo (PbitmapcoreInfo-> BCSIZE))
See Also
BitmapcoreInfo, BitmapInfoHeader, BitmapInfoHeader
============================================================================================================================================================================================================= =========================== rrBTrIPLE (3.0)
TYPEDEF STRUCT TAGRGBTRIPLE {/ * RGBT * / BYTE RGBTBLUE; BYTE RGBTGREEN; BYTE RGBTRED;} RGBTRIPLE
The RGBTRIPLE structure describes a color consisting of relative intensitiesof red, green, and blue. The bmciColors member of the BITMAPCOREINFOstructure consists of an array of RGBTRIPLE structures. Windows applicationsshould use the BITMAPINFO structure instead of BITMAPCOREINFO wheneverpossible. The BITMAPINFO structure uses an RGBQUAD structure instead of Thermtriple Structure.Member Description
RGBTBLUESPECIFIES THE INTENSITY OF BLUE in The Color. Rgbtgreen Specifies The in The Color. Rgbtred Specifies The Intensity of Red in The Color.
See Also
BitmapcoreInfo, BitmapInfo, RGBQUAD
============================================================================================================================================================================================================= ============================