title: How to extract bitmap out of Direct3D 11 Texture2D object?
body: <p>I am using the Desktop Duplication API (C++) and have created an output duplication object and further queried the interface for a ID3D11Texture2D object.</p>
  
  <p>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. </p>
  
  <p>Is there anyway I can extract the pixel buffer/bitmap/image out of the texture2D object?</p>
  
  <p>Thanks!</p>
  
  <p>UPDATE : I solved this using the <code>CaptureTexture</code> function in DirectXTex. You can create a <code>HBITMAP</code> from the resultant <code>ScratchImage</code></p>