I am using the Desktop Duplication API (C++) and have created an output duplication object and further queried the interface for a ID3D11Texture2D object.
I have tried using "D3DX11SaveTextureToFile" and "DirectX::SaveWICTextureToFile" but it gives an error. I need to extract the bitmap or pixel buffer out of this texture so that I can save it as an image. I have tried using a subresource and ID3D11DeviceContext::Map function to extract the pixel buffer but it seems to be empty. But context->Draw() seems to work.
Is there anyway I can extract the pixel buffer/bitmap/image out of the texture2D object?
Thanks!
UPDATE : I solved this using the CaptureTexture function in DirectXTex. You can create a HBITMAP from the resultant ScratchImage
E_NOINTERFACEinto something meaningful which it isn't anymore. Can you tell me exactly which line of code inScreenGrab.cpporDirectXTexWIC.cppwhere you are seeing this error generated? - Chuck WalbournIWICImagingFactory* pWIC = _GetWIC();is failing and the return isE_NOINTERFACE- arch3r_GetWICwill either try to use WIC2 and then WIC1, or just WIC1. See this post - Chuck Walbourn