Graphics File Formats(Windows的.BMP .CUR .ICO文件的格式,有范例)
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 to the cursor image.
cursor image
each cursor-resource file contains one cursor image for each image identified in the cursor directory. a cursor image consists of a cursor-image header, a color table, an xor mask, and an and mask. the cursor image has the following form:
bitmapinfoheader crheader; rgbquad crcolors[]; byte crxor[]; byte crand[];
the cursor hot spot is a single pixel in the cursor bitmap that windows uses to track the cursor. the crxhotspot and cryhotspot members specify the x- and y-coordinates of the cursor hot spot. these coordinates are 16-bit integers.
the cursor-image header, defined as a bitmapinfoheader structure, specifies the dimensions and color format of the cursor bitmap. only the bisize through bibitcount members and the bisizeimage member are used. the biheight member specifies the combined height of the xor and and masks for the cursor. this value is twice the height of the xor mask. the biplanes and bibitcount members must be 1. all other members (such as bicompression and biclrimportant) must be set to zero.
the color table, defined as an array of rgbquad structures, specifies the colors used in the xor mask. for a cursor image, the table contains exactly two structures, since the bibitcount member in the cursor-image header is always 1.
the xor mask, immediately following the color table, is an array of byte values representing consecutive rows of a bitmap. the bitmap defines the basic shape and color of the cursor image. as with the bitmap bits in a bitmap file, the bitmap data in a cursor-resource file is organized in scan lines, with each byte representing one or more pixels, as defined by the color 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 values representing a monochrome bitmap with the same width and height as the xor mask. the array is organized in scan lines, with each byte representing 8 pixels.
when windows draws a cursor, it uses the and and xor masks to combine the cursor image with the pixels already on the display surface. windows first applies the and mask by using a bitwise and operation; this preserves or removes existing pixel color. window then applies the xor mask by using a bitwise xor operation. this sets the final color for each pixel.
the following illustration shows the xor and the and masks that create a cursor (measuring 8 pixels by 8 pixels) in the form of an arrow: |