【问题标题】:Black background with image in center using GDI使用 GDI 以图像为中心的黑色背景
【发布时间】:2015-02-03 06:33:34
【问题描述】:

我在窗口中心显示图像。但是我希望窗口的所有其他区域都是黑色的。我如何实现这一目标? 我使用 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);

【问题讨论】:

    标签: c++ winapi bitmap gdi


    【解决方案1】:

    使用ExcludeClipRect 裁剪图像区域,然后使用FillRect 填充其周围的背景。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多