title: Direct3D: efficient way to get system memory bitmap from IDirect3DSurface9 (default pool)?
body: <p>I have IDirect3DSurface9, default pool, YUV format. How can I efficiently get bitmap bits from it? At the moment I:<br/></p>
  
  <ul>create render target:<br/>
  <code>device->CreateRenderTarget(surf_desc.Width, surf_desc.Height, D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, 0, TRUE, &render_target, NULL)</code></ul>
  
  <ul>convert YUV to RGB32:<br/>
  <code>device->StretchRect(videomem_surf, NULL, render_target_, NULL, D3DTEXF_NONE)</code><br/>
  (complete rectangle, no stretching)</ul>
  
  <ul>create plain offscreen surface in system memory<br/>
  <code>device->CreateOffscreenPlainSurface(surf_desc.Width, surf_desc.Height, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &sysmem_offscreen_surf, NULL)</code></ul>
  
  <ul>copy data from video mem to sysmem:<br/>
  <code>device->GetRenderTargetData(render_target, sysmem_offscreen_surface)</code></ul>
  
  <ul>GetDC from offscreen surface, create compatible DC and compatible bitmap, BitBlt from offscreen sufrace DC to compatible DC and copy bitmap bits to my buffer by GetDIBits()</ul>
  
  <p>this looks a bit of overhead, because of so many copying: from original surface to render target, then to offscreen surface, then to compatible bitmap, and then finally to my buffer. How can this be improved?</p>
  
  <p>thanks</p>