typedef struct tagBITMAPFILEHEADER { WORD bfType; DWORD bfSize; WORD bfReserved1; WORD bfReserved2; DWORD bfOffBits; } BITMAPFILEHEADER; typedef struct tagBITMAPINFOHEADER{ DWORD biSize; LONG biWidth; LONG biHeight; WORD biPlanes; WORD biBitCount DWORD biCompression; DWORD biSizeImage; LONG biXPelsPerMeter; LONG biYPelsPerMeter; DWORD biClrUsed; DWORD biClrImportant; } BITMAPINFOHEADER;
WORD bfType;
DWORD bfSize;
WORD bfReserved1;
WORD bfReserved2;
DWORD bfOffBits;
} BITMAPFILEHEADER; typedef struct tagBITMAPINFOHEADER{
DWORD biSize;
LONG biWidth;
LONG biHeight;
WORD biPlanes;
WORD biBitCount
DWORD biCompression;
DWORD biSizeImage;
LONG biXPelsPerMeter;
LONG biYPelsPerMeter;
DWORD biClrUsed;
DWORD biClrImportant;
} BITMAPINFOHEADER;
而且换行时是4字节对齐的
放的时候是BGR的顺序
还因为16位,24位,32位的不同而不同很麻烦
太久了,记不清楚了,下面是一个得到位图数据后提取每一个点象素然后一点一点画出来的函数,很久以前做的,不知对你有没有帮助:
for(int jBitmap.bmHeight-1;j>=0;j--)
{
for(int i=0;i<Bitmap.bmWidth;i++)
{
int coli[3];
COLORREF col=0;
for(int k=0;k<lpbi->biBitCount/8;k++)
{
coli[k]=cc[j*(4*((Bitmap.bmWidth*lpbi->biBitCount/8)+((Bitmap.bmWidth*lpbi->biBitCount/8)%4!=0)*(4-(Bitmap.bmWidth*lpbi->biBitCount/8)%4))/4)+i*lpbi->biBitCount/8+k];
}
col=RGB(coli[2],coli[1],coli[0]);
//将对应点画出来
//::SetPixel(hdcPic,i,j1,col); }
}
for(int j=Bitmap.bmHeight-1;j>=0;j--)