📄 bmp.txt
字号:
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 SelectionWindows 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 proper 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. If all imagesexceed the color capabilities of the current display, Windows uses the iconimage with the least number of colors.Cursor-Resource File FormatA 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 DirectoryEach 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[];} CURSORDIR;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 structures in the array.A CURSORDIRENTRY structure specifies the dimensions and color format of acursor image. The structure has the following form:typedef struct _CURSORDIRENTRY { BYTE bWidth; BYTE bHeight; BYTE bColorCount; BYTE bReserved; WORD wXHotspot; WORD wYHotspot; DWORD lBytesInRes; DWORD dwImageOffset;} CURSORDIRENTRY;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 ImageEach 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 of 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 each byte representing one or more pixels, as defined by thecolor 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 sets 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,inverted, and transparent results:Pixel result AND mask XOR maskBlack 0 0 White 0 1 Transparent 1 0 Inverted 1 1 Windows Cursor SelectionIf a cursor-resource file contains 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 DescriptionbfType 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.CommentsA BITMAPINFO or BITMAPCOREINFO structure immediately follows theBITMAPFILEHEADER structure in the DIB file.See AlsoBITMAPCOREINFO, BITMAPINFO ==============================================================================BITMAPINFO (3.0)typedef struct tagBITMAPINFO { /* bmi */ BITMAPINFOHEADER bmiHeader; RGBQUAD bmiColors[1];} BITMAPINFO;The BITMAPINFO structure fully defines the dimensions and color informationfor a Windows 3.0 or later device-independent bitmap (DIB).Member DescriptionbmiHeader 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.CommentsA 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 following values:Value Meaning1 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.8 The bitmap has a maximum of 256 colors, and the bmciColors membercontains 256 entries. In this case, each byte in the array represents asingle pixel.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 AlsoBITMAPINFOHEADER, 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 DescriptionbiSize Specifies the number of bytes required by theBITMAPINFOHEADER structure.biWidth Specifies the width of the bitmap, in pixels. biHeight Specifies the height of the bitmap, in pixels. biPlanes Specifies the number of planes for the target device. Thismember 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 MeaningBI_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 Specifies 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 value of the biBitCount member.For more information on the maximum sizes of the color table, see thedescription of the BITMAPINFO structure earlier in this topic.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 which
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -