已知位图的点阵数据,如何将其生成位图
http://bbs.youkuaiyun.com/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);
}
只截取了网页中的一个回答