我在窗口中央显示图像。但是我希望窗口的所有其他区域都是黑色的。我如何实现这一目标? 我正在使用 StretchBlt 使图像居中。请指教
RECT clientRect,rect;
HDC hDC = GetDC(hwnd);
HDC hMemDC = CreateCompatibleDC(hDC);
::SelectObject(hMemDC, bmp);
GetClientRect(hwnd, &clientRect);
StretchBlt(hDC, clientRect.left, clientRect.top, newwidth, newheight, hMemDC, 0, 0,bmpdata.bmWidth, bmpdata.bmHeight,SRCCOPY);
最佳答案
使用ExcludeClipRect
剪掉图像区域,然后使用 FillRect
填充它周围的背景.
关于c++ - 使用 GDI 以图像为中心的黑色背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27309962/