我使用下面的代码读取标准的8位帧缓冲器,但我需要读取用于HDR显示器上HDR内容的10位帧缓冲器。
据我所知,
据我所知,
BI_RGB
是唯一相关的枚举选项。以下是我目前为止的代码,适用于8位通道:#include <iostream>
#include <windows.h>
#include <fstream>
void capture_screen() {
int nScreenWidth = GetSystemMetrics(SM_CXSCREEN);
int nScreenHeight = GetSystemMetrics(SM_CYSCREEN);
HWND hDesktopWnd = GetDesktopWindow();
HDC hDesktopDC = GetDC(NULL);
HDC hCaptureDC = CreateCompatibleDC(hDesktopDC);
HBITMAP hCaptureBitmap = CreateCompatibleBitmap(hDesktopDC, nScreenWidth, nScreenHeight);
SelectObject(hCaptureDC, hCaptureBitmap);
BitBlt(hCaptureDC, 0, 0, nScreenWidth, nScreenHeight, hDesktopDC, 0, 0, SRCCOPY | CAPTUREBLT);
BITMAPINFO bmi = { 0 };
bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);
bmi.bmiHeader.biWidth = nScreenWidth;
bmi.bmiHeader.biHeight = nScreenHeight;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 32;
bmi.bmiHeader.biCompression = BI_RGB;
auto* pPixels = new RGBQUAD[nScreenWidth * nScreenHeight];
GetDIBits(hCaptureDC, hCaptureBitmap, 0,nScreenHeight, pPixels, &bmi, DIB_RGB_COLORS);
//...
delete[] pPixels;
ReleaseDC(hDesktopWnd, hDesktopDC);
DeleteDC(hCaptureDC);
DeleteObject(hCaptureBitmap);
}