Windows图标-Icon文件格式分析。[3]

[入库:2006年2月23日] [更新:2007年3月24日]

本文简介:

VB定义:
'--------------------位图信息头,BITMAPINFOHEADER
'说明BITMAPINFOHEADER结构,其中包含了有关位图的尺寸及位格式等信息
Public Type bmih    'BITMAPINFOHEADER ,bmiHeader;
    biSize As Long 'DWORD ;Bitmap Header Size,BITMAPINFOHEADER段尺寸。*
    biWidth As Long 'LONG ;Width 1 dword 位图的宽度,以象素为单位*
    biHeight As Long 'LONG ;Height 1 dword 位图的高度,以象素为单位*
    biPlanes As Integer 'WORD ;Planes 1 word 位图的位面数(注:该值将总是1)*
    biBitCount  As Integer ';WORD;Bits Per Pixel,每个象素的位数*
    biCompression  As Long ';DWORD,Compression,压缩说明:
    biSizeImage  As Long ';DWORD;Bitmap Data Size 1 dword 用字节数表示的位图数据的大小。该数必须是4的倍数*
    biXPelsPerMeter  As Long ';LONG;HResolution 1 dword 用象素/米表示的水平分辨率
    biYPelsPerMeter  As Long ';LONG;VResolution 1 dword 用象素/米表示的垂直分辨率
    biClrUsed  As Long ';DWORD;Colors 1 dword 位图使用的颜色数。如8-比特/象素表示为100h或者 256.
    biClrImportant As Long ';DWORD;Important Colors 1 dword 指定重要的颜色数。当该域的值等于颜色数时(或者等于0时),表示所有颜色都一样重要
End Type

在ICON文件中使用的关键变量只用到:bisize, biwidth, biheight, biplanes, bibitcount, bisizeimage.几个,其他变量必须为0。biheight变量的值为高度象素量的2倍。

关于BITMAPINFOHEADER的更多介绍参见BMP文件格式分析的文章,在此不作冗述。

2.2色彩表:rgbquad:iccolors() As rgbq

[摘自:BMP文件格式分析:彩色表包含的元素与位图所具有的颜色数相同,象素的颜色用RGBQUAD结构来定义。对于24-位真彩色图象就不使用彩色表(同样也包括16位、和32位位图),因为位图中的RGB值就代表了每个象素的颜色。彩色表中的颜色按颜色的重要性排序,这可以辅助显示驱动程序为不能显示足够多颜色数的显示设备显示彩色图象。RGBQUAD结构描述由R、G、B相对强度组成的颜色,定义如下]

C原型定义:
typedef struct tagRGBQUAD { /* rgbq */
BYTE rgbBlue;
BYTE rgbGreen;
BYTE rgbRed;
BYTE rgbReserved;
} RGBQUAD;

VB定义:
'-----------------色彩表
'说明彩色表RGBQUAD结构的阵列,其中包含索引图像的真实RGB值。
Public Type rgbq    'RGBQUAD, bmiColors[];
    rgbBlue As Byte  ' 指定蓝色强度
    rgbGreen As Byte ' 指定绿色强度
    rgbRed As Byte ' 指定红色强度
    rgbReserved As Byte ' 保留,设置为0
End Type

色彩表的定义也是来自BMP文件结构的定义,定义的类型格式和BMP文件的相同。

3.ICON文件的完整结构

Public Type icondirentry
    bwidth  As Byte ';byte    // width, in pixels, of the image:图像宽度,以象素为单位。一个字节
    bheight  As Byte ';byte   // height, in pixels, of the image:图像高度,以象素为单位。一个字节
    bcolorcount  As Byte ';byte  // number of colors in image (0 if >=8bpp):图像中的颜色数(如果是>=8bpp的位图则为0)
    breserved  As Byte ';byte    // reserved ( must be 0):保留字必须是0
    wplanes  As Integer ';word   // color planes:为目标设备说明位面数,其值将总是被设为1
    wbitcount  As Integer ';word   // bits per pixel:每象素所占位数。
    dwbytesinres  As Long  ';dword   // how many bytes in this resource?:这份资源所占字节数
    dwimageoffset  As Long ';dword   // where in the file is this image?:图像数据(iconimage)起点偏移位置。
End Type ' icondirentry

Public Type icondir
    idreserved As Integer       '; word   // reserved (must be 0):保留字必须是0
    idtype As Integer           '; word     // resource type (1 for icons):资源类型,1是图标,2就是光标了?
    idcount As Integer          '; word      // how many images?:有几个图像
    identries() As icondirentry '[1]'icondirentry; // an entry for each image (idcount of 'em):每个图像的入口定义
End Type

本文关键:Windows图标-Icon文件格式分析。
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top