Graphics File Formats(Windows的.BMP .CUR .ICO文件的格式,有范例)
default 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 the resource and the dimensions and color format of each icon image. the icondir structure has the following form:
typedef struct icondir { word idreserved; word idtype; word idcount; 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 containing information about individual icons. the idcount member specifies the number of structures in the array.
the icondirentry structure specifies the dimensions and color format for an icon. the structure has the following form:
struct icondirectoryentry { byte bwidth; byte bheight; byte bcolorcount; byte breserved; word wplanes; word wbitcount; dword dwbytesinres; dword dwimageoffset; };
following are the members in the icondirentry structure:
bwidth specifies the width of the icon, in pixels. acceptable values are 16, 32, and 64.
bheight specifies the height of the icon, in pixels. acceptable values are 16, 32, and 64.
bcolorcount specifies the number of colors in the icon. acceptable values are 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 file to the icon image.
icon image
each icon-resource file contains one icon image for each image identified in the icon directory. an icon image consists of an icon-image header, a color table, an xor mask, and an and mask. the icon image has the following form:
bitmapinfoheader icheader; rgbquad iccolors[]; byte icxor[]; byte icand[];
the icon-image header, defined as a bitmapinfoheader structure, specifies the dimensions and color format of the icon bitmap. only the bisize through bibitcount 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 the colors used in the xor mask. as with the color table in a bitmap file, the bibitcount member in the icon-image header determines the number of elements in 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 byte values representing consecutive rows of a bitmap. the bitmap defines the basic shape and color of the icon image. as with the bitmap bits in a bitmap file, the bitmap data in an icon-resource file is organized in scan lines, with each byte representing one or more pixels, as defined by the color |