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
Public Type rgbq 'RGBQUAD;
rgbBlue As Byte ' 指定蓝色强度
rgbGreen As Byte ' 指定绿色强度
rgbRed As Byte ' 指定红色强度
rgbReserved As Byte ' 保留,设置为0
End Type
Public Type iconimage '{
icheader As bmih ';DIB位图信息头:bitmapinfoheader // dib header,注:bmih 是我简化了bitmapinfoheader的名称。
' used: bisize, biwidth, biheight(xorH+andH)即2倍高度, biplanes, bibitcount, bisizeimage.
'all other members must be 0.
iccolors() As rgbq '[1]';色彩表:rgbquad // color table
icxor() As Byte '[1];byte // dib bits for xor mask:DIB结构的图像数据。XOR掩码?4bpp
icand() As Byte '[1];byte // dib bits for and mask:DIB结构的图像数据。AND掩码?1bpp
End Type '} iconimage
Public Type Iconfile
iDir As icondir '目录
imgDate() As iconimage '图像数据段
End Type
由结构定义得知,ICON文件由目录段和图像数据段组成。完整的结构示意图如下:
'-------------完整的文件构成
+---目录段
+------目录头
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?:有几个图像
+-------------目录索引1
identries(0) As icondirentry
+-------------目录索引2
identries(1) As icondirentry
+-------------目录索引x最大为32767
identries(X) As icondirentry
+---图像数据段
+--------------图像1
icheader As bmih
iccolors(0 to 15) As rgbq '16色
icxor(0 to 511) As Byte '32*32
icand(0 to 127) As Byte '32*32
+--------------图像2
.
+--------------图像x最大为32768
.
'--------------END file.
通过以上结构,你就可以方便的读写ICON文件并制作属于你自己的ICON文件编辑器了。
4.显示ICON图像的方法之一
我们大家都知道用LoadPicture可以直接加载ICON文件,在此向大家介绍另外一种显示方法,相信会使你得到一些启发。
在此用到几个API函数:
'ICON图像描述
Public Type ICONINFO
fIcon As Long
xHotspot As Long
yHotspot As Long
hbmMask As Long
hbmColor As Long
End Type