Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何在Windows中捕获HDR帧缓冲区?_C++_Windows_Winapi_Framebuffer_Hdr - Fatal编程技术网

C++ 如何在Windows中捕获HDR帧缓冲区?

C++ 如何在Windows中捕获HDR帧缓冲区?,c++,windows,winapi,framebuffer,hdr,C++,Windows,Winapi,Framebuffer,Hdr,我使用以下代码读取标准8位帧缓冲区,但是我需要读取用于HDR监视器上HDR内容的10位HDR帧缓冲区 据我所知,BI_RGB是唯一相关的枚举选项。以下是我到目前为止得到的,适用于8位通道: #include <iostream> #include <windows.h> #include <fstream> void capture_screen() { int nScreenWidth = GetSystemMetrics(SM_CXSCREEN);

我使用以下代码读取标准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);
}
#包括
#包括
#包括
无效捕获屏幕(){
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);
选择对象(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=nsScreenWidth;
bmi.bmiHeader.biHeight=屏幕高度;
bmi.bmiHeader.biPlanes=1;
bmi.bmiHeader.biBitCount=32;
bmi.bmiHeader.biCompression=BI_RGB;
auto*pPixels=新RGBQUAD[nsScreenWidth*nsScreenHeight];
GetDIBits(hCaptureDC、hCaptureBitmap、0、nsScreenHeight、像素和bmi、DIB_RGB_颜色);
//...               
删除[]个像素;
ReleaseDC(hDesktopWnd,hDesktopDC);
DeleteDC(hCaptureDC);
DeleteObject(hCaptureBitmap);
}

Direct3D
在最近的API更新中添加了与HDR相关的功能,这些功能使用了带有最后数字的新接口。要访问它们,必须首先查询它们的基础对象

例如:

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时,代码才会成功执行(而不是出现错误代码而失败)


然后,您可以通过调用函数来查询监视器功能。您将获得结构填充,其中描述了可用的颜色空间、每个组件的位、红/绿/蓝原色、白点以及设备上可用的亮度范围。

对于Win 8及更高版本,您最好使用桌面复制API来捕获桌面谢谢!有几件事:首先,我应该如何初始化
IDXGIOutput
?(我对C++相当陌生)。另外,是否可以使用此工具获取特定像素值?@RichardRobinson很抱歉现在回复您。因为你是这个领域的新手,我给你举了一些例子。甚至可以用这种方法获得每个像素的rgb分量吗?@RichardRobinson我没有尝试使用
DirectX
来获得HDR的特定像素值,但根据当前数据,
DirectX
更多的是渲染颜色。您可以参考的官方文档,其中显示了如何获取结构。