BITMAPFILEHEADER和BITMAPCOREHEADER区分(转载)

来源:互联网 发布:资本论中心思想 知乎 编辑:程序博客网 时间:2024/05/02 04:43

在OS/2样式的DIB内,BITMAPFILEHEADER结构后紧跟了BITMAPCOREHEADER结构,它提供了关于DIB图像的基本信息。

typedef struct tagBITMAPCOREHEADER  // bmch   
{
          DWORD        bcSize ;              // size of the structure = 12
          WORD          bcWidth ;            // width of image in pixels
          WORD          bcHeight ;          // height of image in pixels
          WORD          bcPlanes ;            // = 1
          WORD          bcBitCount ;          // bits per pixel (1, 4, 8, or 24)
}
BITMAPCOREHEADER, * PBITMAPCOREHEADER ;

typedef struct tagBITMAPINFOHEADER  // bmih       
{       
          DWORD biSize ;              // size of the structure = 40       
          LONG  biWidth ;            // width of the image in pixels       
          LONG  biHeight ;            // height of the image in pixels       
          WORD  biPlanes ;            // = 1       
          WORD  biBitCount ;          // bits per pixel (1, 4, 8, 16, 24, or 32)     
          DWORD biCompression ;      // compression code 
          DWORD biSizeImage ;        // number of bytes in image 
          LONG  biXPelsPerMeter ;    // horizontal resolution 
          LONG  biYPelsPerMeter ;    // vertical resolution
          DWORD biClrUsed ;          // number of colors used
          DWORD biClrImportant ;      // number of important colors

BITMAPINFOHEADER, * PBITMAPINFOHEADER ;
您可以通过检查结构的第一字段区分与OS/2兼容的DIB和Windows DIB,前者为12,后者为40。
就是说这两个结构1个是os/2的,1个是windows用的。

原创粉丝点击