小编nyt*_*rix的帖子

设置窗口像素的正确(且无闪烁)方法?

我正在努力找出在 WM_PAINT 期间将纯 RGBA 值数组转储到 Win32 窗口的客户区的正确方法。我有以下代码,但它看起来已经很复杂,我什至还没有完成:

case WM_ERASEBKGND:
  return 1;
case WM_PAINT:
{
  PAINTSTRUCT paintInfo{};
  HDC device = BeginPaint(window, &paintInfo);
  if (device == nullptr)
    throw runtime_error(RG_LOCATION());
  ScopeExit endPaint([&] { EndPaint(window, &paintInfo); });

  HDC offscreenDevice = CreateCompatibleDC(device);
  ScopeExit deleteOffscreenDevice([&] { DeleteDC(offscreenDevice); });
  HBITMAP offscreenBitmap = CreateCompatibleBitmap(device, Distance(paintInfo.rcPaint.left, paintInfo.rcPaint.right),
                                                   Distance(paintInfo.rcPaint.top, paintInfo.rcPaint.bottom));
  ScopeExit deleteOffscreenBitmap([&] { DeleteObject(offscreenBitmap); });
  HBITMAP previousBitmap = reinterpret_cast<HBITMAP>(SelectObject(offscreenDevice, offscreenBitmap));

  // now I need to blit the available pixel data...
  vector<array<uint8_t, 4>> mypixels;
  // ...onto the client area of the …
Run Code Online (Sandbox Code Playgroud)

c++ winapi gdi

6
推荐指数
2
解决办法
624
查看次数

标签 统计

c++ ×1

gdi ×1

winapi ×1