16位图像的文件类顺序是这样的
Public Type BITMAPFILEHEADER
bfType As Integer
bfSize As Long
bfReserved1 As Integer
bfReserved2 As Integer
bfOffBits As Long
End Type
Public Type BITMAPV4HEADER
bV4Size As Long
bV4Width As Long
bV4Height As Long
bV4Planes As Integer
bV4BitCount As Integer
bV4V4Compression As Long
bV4SizeImage As Long
bV4XPelsPerMeter As Long
bV4YPelsPerMeter As Long
bV4ClrUsed As Long
bV4ClrImportant As Long
bV4RedMask As Long
bV4GreenMask As Long
bV4BlueMask As Long
bV4AlphaMask As Long
End Type
之后是图像图像数据
即位图数据前4个DWORD处是红色掩码,如果biCompression是BI_BITFIELDS的时候,要根据RGB掩码来判断图片是555格式还是565格式,
if(info.bmiHeader.biBitCount == 16 && info.bmiHeader.biCompression == BI_BITFIELDS)
{
fseek(fp,fileheader.bfOffBits-sizeof(DWORD)*4, SEEK_SET);//移动文件指针到红色掩码处
fread(&rMask, sizeof(DWORD),1,fp);//读取红色掩码
}
如果rMask为0x7C00就是555格式,是0xF800就是565格式