已知位图的点阵数据,如何将其生成位图

来源:互联网 发布:济南美食 知乎 编辑:程序博客网 时间:2024/05/22 04:27

已知位图的点阵数据,如何将其生成位图

http://bbs.csdn.net/topics/60324144


用StretchDIBits函数:

CClientDC dc(this);

CDC *theDC=&dc;

if (theDC!=NULL) 
{
BITMAPINFOHEADER bmiHeader;
bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmiHeader.biWidth = 位图宽度(像素);
bmiHeader.biHeight = 位图高度(像素);
bmiHeader.biPlanes = 1;
bmiHeader.biBitCount = 24;
bmiHeader.biCompression = BI_RGB;
bmiHeader.biSizeImage = 0;
bmiHeader.biXPelsPerMeter = 0;
bmiHeader.biYPelsPerMeter = 0;
bmiHeader.biClrUsed = 0;
bmiHeader.biClrImportant = 0;


// now blast it to the CDC passed in.
// lines returns the number of lines actually displayed
int lines = StretchDIBits(theDC->m_hDC,
0, 0,
bmiHeader.biWidth,
bmiHeader.biHeight,
0,0,
bmiHeader.biWidth,
bmiHeader.biHeight,
m_buf,              //DIB数据缓存区指针(BYTE * 类型)
(LPBITMAPINFO)&bmiHeader,
DIB_RGB_COLORS,
SRCCOPY);
}


只截取了网页中的一个回答