【C】BitmapInfoHeader等结构体的可移植声明
这些代码用于操作BMP文件。这些代码是跨平台的。能在不同的平台完成编译。为了和Windows自带的结构体区分开来,我改变了大小写。#include<stdint.h>
#pragma pack(push,1)
typedef struct
{
uint16_t bfType;
uint32_t bfSize;
uint16_t bfReserved1;
uint16_t bfReserved2;
uint32_t bfOffBits;
}BitmapFileHeader,*BitmapFileHeaderP;
typedef struct
{
uint32_t biSize;
int32_t biWidth;
int32_t biHeight;
uint16_t biPlanes;
uint16_t biBitCount;
uint32_t biCompression;
uint32_t biSizeImage;
int32_t biXPelsPerMeter;
int32_t biYPelsPerMeter;
uint32_t biClrUsed;
uint32_t biClrImportant;
}BitmapInfoHeader,*BitmapInfoHeaderP;
typedef struct
{
uint8_t B;
uint8_t G;
uint8_t R;
uint8_t X;
}RGBQuad,*RGBQuadP;
typedef struct
{
BitmapInfoHeader bmiHeader;
RGBQuad bmiColors;
}BitmapInfo,*BitmapInfoP;
#pragma pack(pop) 为什么要跨平台?为了不让自己写过的代码随着时间老去!
页:
[1]