title: IWICImagingFactory::CreateDecoderFromStream() fails, error message message is not helpful
body: <p>I'm trying to load a ID2D1Bitmap from a bitmap resource. To do so, I consulted an <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd756685%28v=vs.85%29.aspx" rel="nofollow">MSDN guide</a> which told me to use the Windows Imaging Component (IWIC) to process the image before Direct2D uses it.</p>
  
  <p>However, it fails when I call <code>CreateDecoderFromStream()</code>, and it returns a strange error message – <code>0x88982f50</code> – that tells me nothing. I've searched Google and used DirectX Error Lookup. The DirectX Error Lookup tool only tells me this:</p>
  
  <pre><code>HRESULT: 0x88982f50 (2291674960)
  Name: Unknown
  Description: n/a
  Severity code: Failed
  Facility Code: FACILITY_DWRITE (2200)
  Error Code: 0x2f50 (12112)
  </code></pre>
  
  <p>This is the code I'm using to try and load an ID2D1Bitmap from a resource:</p>
  
  <pre><code>int LoadBitmapFromResource( IWICImagingFactory *pIWICFactory, ID2D1RenderTarget *pRT, int resID, ID2D1Bitmap **ppD2DBitmap )
  {
      int errmsg;
  
      HRSRC hbmp;
      HGLOBAL hbmpdata;
      void *pbmp; //system memory pointer to bitmap resource
      DWORD bmpsize;
      IWICStream *pStream;
      IWICBitmapDecoder *pbmpdecoder;
      IWICBitmapFrameDecode *pSource;
      IWICFormatConverter *pConverter;
  
      hbmp = FindResourceW( GetModuleHandleW(NULL), MAKEINTRESOURCEW(resID), RT_BITMAP );
      if( NULL == hbmp )
      {
          printf("LoadBitmapFromResource::FindResourceW() error: %d\r\n", GetLastError() );
          return GetLastError();
      }
  
      hbmpdata = LoadResource( GetModuleHandleW(NULL), hbmp );
      if( NULL == hbmpdata )
      {
          printf("LoadBitmapFromResource::LoadResource() error: %d\r\n", GetLastError() );
          return GetLastError();
      }
  
      pbmp = LockResource( hbmpdata );
      if( NULL == pbmp )
      {
          printf("LoadBitmapFromResource::LockResource() error: %d\r\n", GetLastError() );
          return GetLastError();
      }
  
      bmpsize = SizeofResource( GetModuleHandleW(NULL), hbmp );
      if( NULL == bmpsize )
      {
          printf("LoadBitmapFromResource::SizeofResource() error: %d\r\n", GetLastError() );
          return GetLastError();
      }
  
      errmsg = pIWICFactory-&gt;CreateStream( &amp;pStream );
      if( !SUCCEEDED(errmsg) )
      {
          printf("LoadBitmapFromResource::CreateStream() error: %x\r\n", errmsg );
          return errmsg;
      }
  
      errmsg = pStream-&gt;InitializeFromMemory( (BYTE*)pbmp, bmpsize );
      if( !SUCCEEDED(errmsg) )
      {
          printf("LoadBitmapFromResource::InitializeFromMemory() error: %x\r\n", errmsg );
          return errmsg;
      }
  
      errmsg = pIWICFactory-&gt;CreateDecoderFromStream( pStream, NULL, WICDecodeMetadataCacheOnLoad, &amp;pbmpdecoder );
      if( !SUCCEEDED(errmsg) )
      {
          printf("LoadBitmapFromResource::CreateDecoderFromStream() error: %x\r\n", errmsg );
          return errmsg;
      }
  
      errmsg = pbmpdecoder-&gt;GetFrame( 0, &amp;pSource );
      if( !SUCCEEDED(errmsg) )
      {
          printf("LoadBitmapFromResource::GetFrame() error: %x\r\n", errmsg );
          return errmsg;
      }
  
      errmsg = pIWICFactory-&gt;CreateFormatConverter( &amp;pConverter );
      if( !SUCCEEDED(errmsg) )
      {
          printf("LoadBitmapFromResource::CreateFormatConverter() error: %x\r\n", errmsg );
          return errmsg;
      }
  
      errmsg = pConverter-&gt;Initialize( pSource, GUID_WICPixelFormat32bppPBGRA, WICBitmapDitherTypeNone, NULL, 0.0f, WICBitmapPaletteTypeMedianCut );
      if( !SUCCEEDED(errmsg) )
      {
          printf("LoadBitmapFromResource::Initialize() error: %x\r\n", errmsg );
          return errmsg;
      }
  
      errmsg = pRT-&gt;CreateBitmapFromWicBitmap( pConverter, ppD2DBitmap );
      if( !SUCCEEDED(errmsg) )
      {
          printf("LoadBitmapFromResource::CreateBitmapFromWicBitmap() error: %x\r\n", errmsg );
          return errmsg;
      }
  
      pConverter-&gt;Release();
      pSource-&gt;Release();
      pbmpdecoder-&gt;Release();
      pStream-&gt;Release();
  
      return 0;
  }
  </code></pre>