I need a DirectX Expert to help finish a function I use to take a ingame screenshot using the backbuffer.
My screenshot function works fine, I am able to save the screenshot however I want to crop the center of it and save that, instead of the whole image.
The resulting size should be 320 x 200 from the center of the screen image.
I do not want to use any external classes, or libraries. I am hoping to pass the mapped buffer pData to a function to have it resized/cropped.
my function to get screenshot data:
D3D11_TEXTURE2D_DESC StagingDesc;
ID3D11Texture2D *pBackBuffer = NULL;
g_DX11Renderer->m_swapChain->GetBuffer( 0,
__uuidof( ID3D11Texture2D ), (LPVOID*)&pBackBuffer );
pBackBuffer->GetDesc(&StagingDesc);
[login to view URL] = D3D11_USAGE_STAGING;
[login to view URL] = 0;
[login to view URL] = D3D11_CPU_ACCESS_READ;
[login to view URL] = 0;
[login to view URL] = 1;
[login to view URL] = 1;
[login to view URL] = 1;
[login to view URL] = 0;
[login to view URL] = DXGI_FORMAT_R8G8B8A8_UNORM;
ID3D11Texture2D *pBackBufferStaging = NULL;
HRESULT hr = g_DX11Renderer->m_device->CreateTexture2D(&StagingDesc, NULL, &pBackBufferStaging);
g_DX11Renderer->m_deviceContext->CopyResource(pBackBufferStaging,pBackBuffer);
D3D11_MAPPED_SUBRESOURCE mappedData;
g_DX11Renderer->m_deviceContext->Map(pBackBufferStaging, 0, D3D11_MAP_READ, 0, &mappedData);
BYTE* bufData = (BYTE*)[login to view URL];
g_DX11Renderer->m_deviceContext->Unmap(pBackBufferStaging,0);