[英]How to capture HDR framebuffer in Windows?
我使用以下代码来读取标准的8位帧缓冲区,但是我需要读取用于HDR监视器上的HDR内容的10位HDR帧缓冲区。
据我所知, 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);
}
Direct3D
已将HDR相关功能添加到最近的API更新中,这些更新使用带有最后数字的新接口。 要访问它们,必须首先查询其基础对象。
例:
IDXGIOutput* output = /* initialize output */;
IDXGIOutput6* output6;
HRESULT hr = output->QueryInterface(__uuidof(IDXGIOutput6), (void**)&output6);
if(SUCCEEDED(hr)) {
// Use output6...
output6->Release();
} else {
// Error!
}
只有安装了足够新版本的Windows SDK,才能成功编译此代码。 仅当用户具有足够新版本的Windows 10时,代码才会成功执行(而不是使用错误代码失败)。
然后,您可以通过调用函数IDXGIOutput6 :: GetDesc1来查询监视器功能。 您将获得结构DXGI_OUTPUT_DESC1 ,其中描述了可用的颜色空间,每个组件的位数,红色/绿色/蓝色原色,白点以及设备上可用的亮度范围。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.