title: Windows Imaging Component - How to get an encoder from an HBITMAP?
body: <p>I have an HBITMAP provided by a 3rd party library, and need to write it rescaled on disk as a JPEG. </p>
  
  <p>I have never used WIC, so I've been following this tutorial: <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ff973956.aspx" rel="nofollow">https://msdn.microsoft.com/en-us/library/windows/desktop/ff973956.aspx</a></p>
  
  <p>I have created a WicBitmap from my HBITMAP.</p>
  
  <p>In Listing 9 it becomes apparent that I need a decoder, but the only way to create it I have found is with IWICImagingFactory::CreateDecoderFromFilename. There is an Initialize method that receives a IStream, but I'm not sure of the correct way to use it.</p>
  
  <p>Is this the correct way to save an HBITMAP to disk? If so, how can I get a decoder from my HBITMAP or WicBitmap?</p>