title: Direct2D ID2D1RenderTarget::CreateBitmapFromWicBitmap fails with no error
body: <p>I just try to add LoadBitmapFromFile function from sample (from SDK) to my MFC project. So my app fails during runtime on line, no errors, no warnings.  </p>
  
  <pre><code>hr = pRenderTarget-&gt;CreateBitmapFromWicBitmap(pConverter, NULL, ppBitmap);  
  </code></pre>
  
  <p>When I debugging it and goes over this line I receive empty window and debug session stops. How to find out what the error is? What could be the cause?</p>
  
  <pre><code>HRESULT DemoApp::LoadBitmapFromFile(
  ID2D1RenderTarget *pRenderTarget,
  IWICImagingFactory *pIWICFactory,
  PCWSTR uri,
  UINT destinationWidth,
  UINT destinationHeight,
  ID2D1Bitmap **ppBitmap)
  {
  HRESULT hr = S_OK;
  
  IWICBitmapDecoder *pDecoder = NULL;
  IWICBitmapFrameDecode *pSource = NULL;
  IWICStream *pStream = NULL;
  IWICFormatConverter *pConverter = NULL;
  IWICBitmapScaler *pScaler = NULL;
  
  hr = pIWICFactory-&gt;CreateDecoderFromFilename(
      uri,
      NULL,
      GENERIC_READ,
      WICDecodeMetadataCacheOnLoad,
      &amp;pDecoder
      );
  if (SUCCEEDED(hr))
  {
  
      // Create the initial frame.
      hr = pDecoder-&gt;GetFrame(0, &amp;pSource);
  }
  
  if (SUCCEEDED(hr))
  {
      // Convert the image format to 32bppPBGRA
      // (DXGI_FORMAT_B8G8R8A8_UNORM + D2D1_ALPHA_MODE_PREMULTIPLIED).
      hr = pIWICFactory-&gt;CreateFormatConverter(&amp;pConverter);
  }
  if (SUCCEEDED(hr))
  {
      // If a new width or height was specified, create an
      // IWICBitmapScaler and use it to resize the image.
      if (destinationWidth != 0 || destinationHeight != 0)
      {
          UINT originalWidth, originalHeight;
          hr = pSource-&gt;GetSize(&amp;originalWidth, &amp;originalHeight);
          if (SUCCEEDED(hr))
          {
              if (destinationWidth == 0)
              {
                  FLOAT scalar = static_cast&lt;FLOAT&gt;(destinationHeight) / static_cast&lt;FLOAT&gt;(originalHeight);
                  destinationWidth = static_cast&lt;UINT&gt;(scalar * static_cast&lt;FLOAT&gt;(originalWidth));
              }
              else if (destinationHeight == 0)
              {
                  FLOAT scalar = static_cast&lt;FLOAT&gt;(destinationWidth) / static_cast&lt;FLOAT&gt;(originalWidth);
                  destinationHeight = static_cast&lt;UINT&gt;(scalar * static_cast&lt;FLOAT&gt;(originalHeight));
              }
  
              hr = pIWICFactory-&gt;CreateBitmapScaler(&amp;pScaler);
              if (SUCCEEDED(hr))
              {
                  hr = pScaler-&gt;Initialize(
                          pSource,
                          destinationWidth,
                          destinationHeight,
                          WICBitmapInterpolationModeCubic
                          );
              }
              if (SUCCEEDED(hr))
              {
                  hr = pConverter-&gt;Initialize(
                      pScaler,
                      GUID_WICPixelFormat32bppPBGRA,
                      WICBitmapDitherTypeNone,
                      NULL,
                      0.f,
                      WICBitmapPaletteTypeMedianCut
                      );
              }
          }
      }
      else // Don't scale the image.
      {
          hr = pConverter-&gt;Initialize(
              pSource,
              GUID_WICPixelFormat32bppPBGRA,
              WICBitmapDitherTypeNone,
              NULL,
              0.f,
              WICBitmapPaletteTypeMedianCut
              );
      }
  }
  if (SUCCEEDED(hr))
  {
      // Create a Direct2D bitmap from the WIC bitmap.
      hr = pRenderTarget-&gt;CreateBitmapFromWicBitmap(pConverter, NULL, ppBitmap);
  }
  
  SafeRelease(&amp;pDecoder);
  SafeRelease(&amp;pSource);
  SafeRelease(&amp;pStream);
  SafeRelease(&amp;pConverter);
  SafeRelease(&amp;pScaler);
  
  return hr;
  </code></pre>
  
  <p>}</p>