如何根据内存数据生成位图

来源:互联网 发布:linux文件指针file 编辑:程序博客网 时间:2024/05/17 21:48
HBITMAP hCustomBmp = CreateCompatibleBitmap(window.hDC, WIDTH, HEIGHT); //创建一副与当前DC兼容的位图
BITMAPINFO bmpInfo;

bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);

bmpInfo.bmiHeader.biWidth = WIDTH;

bmpInfo.bmiHeader.biHeight = HEIGHT;

bmpInfo.bmiHeader.biPlanes = 1;

bmpInfo.bmiHeader.biCompression = BI_RGB;

bmpInfo.bmiHeader.biBitCount = 32;

SetDIBits(window.hDC, hCustomBmp, 0, HEIGHT, g_resultBuf.data, &bmpInfo, DIB_RGB_COLORS);使用指定的DIB颜色数据来设置位图中的像素

HDC hh = CreateCompatibleDC(NULL);
SelectObject(hh, hCustomBmp);
//BitBlt(window.hDC, 0, 0, WIDTH, HEIGHT, hh, 0, 0, SRCCOPY);
StretchBlt(window.hDC, 0, 0, window.init.width, window.init.height, hh, 0, 0,WIDTH,HEIGHT,SRCCOPY);
DeleteObject(hCustomBmp);
DeleteDC(hh);

0 0
原创粉丝点击