I use AcquireNextFrameto take a screenshot of my desktop. Can I set the dimension of the output image that I want to set? I saw this feature in the documentation IDXGIOutput::SetDisplaySurfacethat could help. Here is my code:
D3D11_TEXTURE2D_DESC desc;
desc.Width = 1280;
desc.Height = 720;
desc.MipLevels = desc.ArraySize = 1;
desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
desc.SampleDesc.Count = 1;
desc.Usage = D3D11_USAGE_DYNAMIC;
desc.BindFlags = 0;
desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
desc.MiscFlags = 0;
ID3D11Texture2D *pTexture = NULL;
gDevice->CreateTexture2D(&desc, NULL, &pTexture);
IDXGISurface *surface = nullptr;
hr = gDevice->QueryInterface(__uuidof(IDXGISurface), reinterpret_cast<void **>(&pTexture));
if (FAILED(hr))
return;
hr = lDxgiOutput->GetDesc(&gOutputDesc);
if (FAILED(hr))
return;
IDXGIOutput1 *lDxgiOutput1 = nullptr;
hr = lDxgiOutput->QueryInterface(IID_PPV_ARGS(&lDxgiOutput1));
if (FAILED(hr))
return;
lDxgiOutput->Release();
hr = lDxgiOutput1->DuplicateOutput(gDevice, &gDeskDupl);
if (FAILED(hr))
return;
My screen is 1920x1080, and I would like to get an image at 1280x720, for example. I get an error in a function queryinterface. Can someone tell me what I am missing? Or is there a solution that makes setting resolution easier? Thanks
source
share