问题描述
- Bitblt后图像出现在屏幕右上方而不是窗口中
-
void Device::Display() { hdc = GetDC(hwnd); BitBlt(hdc, 0, 0, VIEWWIDTH, VIEWHEIGHT, hdcMem, 0, 0, SRCCOPY); ReleaseDC(hwnd, hdc); for (int j = 0; j < VIEWHEIGHT; j++) { memset(frameBuffer[j], 0, VIEWWIDTH*sizeof(unsigned int)); } } void Device::Init() { hdc = GetDC(hwnd); hdcMem = CreateCompatibleDC(hdc); ReleaseDC(hwnd, hdc);//暂时断开 bmpInfo = { { sizeof(BITMAPINFOHEADER), VIEWWIDTH, -VIEWHEIGHT, 1, 32, BI_RGB, VIEWWIDTH * VIEWHEIGHT * 4, 0, 0, 0, 0 } }; LPVOID ptr; nBmp = CreateDIBSection(hdcMem, &bmpInfo, DIB_RGB_COLORS, &ptr, 0, 0); oBmp = (HBITMAP)SelectObject(hdcMem, nBmp); frameBuffer = new unsigned int*[VIEWHEIGHT]; char*framebuf = (char*)ptr; for (int j = 0; j < VIEWHEIGHT; j++) { frameBuffer[j] = (unsigned int*)(framebuf + VIEWWIDTH * 4 * j); } }
解决方案
参考:http://blog.csdn.net/frenzy/article/details/1432628
时间: 2024-09-17 02:50:40