title: WIC Direct2D CreateBitmapFromMemory: limitations on width and height?
body: <p>CreateBitmapFromMemory executes successfully when <strong>_nWidth</strong> is <strong>equal to or less than 644.</strong>
  If the value exceeds this value, the HRESULT value is -2003292276</p>
  
  <p>Do limits exist on the width and height?</p>
  
  <pre><code>#include &lt;d2d1.h&gt;
  #include &lt;d2d1helper.h&gt;
  
  #include &lt;wincodecsdk.h&gt; // Use this for WIC Direct2D functions
  
  
  void test() 
  {
      IWICImagingFactory     *m_pIWICFactory;   
      ID2D1Factory           *m_pD2DFactory;
      IWICBitmap             *m_pEmbeddedBitmap;
      ID2D1Bitmap            *m_pD2DBitmap;
  
      unsigned char *pImageBuffer = new unsigned char[1024*1024];
  
      HRESULT hr = S_OK;
  
      int _nHeight = 300;
      int _nWidth =  644;
  </code></pre>
  
  <p>If nWidth exceeds 644, CreateBitmapFromMemory returns an Error.</p>
  
  <pre><code>    //_nWidth =  648;
  
  
      if (m_pIWICFactory == 0 )
      {
          hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
  
          // Create WIC factory
          hr = CoCreateInstance(
              CLSID_WICImagingFactory,
              NULL,
              CLSCTX_INPROC_SERVER,
              IID_PPV_ARGS(&amp;m_pIWICFactory)
              );
  
          if (SUCCEEDED(hr))
          {
              // Create D2D factory
              hr = D2D1CreateFactory( D2D1_FACTORY_TYPE_SINGLE_THREADED, &amp;m_pD2DFactory );
          }
      }
  
       hr = m_pIWICFactory-&gt;CreateBitmapFromMemory(
          _nHeight,   // height
          _nWidth,  // width
          GUID_WICPixelFormat24bppRGB, // pixel format of the NEW bitmap
          _nWidth*3,  // calculated from width and bpp information
          1024*1024, // height x width
          pImageBuffer, // name of the .c array
          &amp;m_pEmbeddedBitmap  // pointer to pointer to whatever an IWICBitmap is.
          ); 
  
      if (!SUCCEEDED(hr)) {
          char *buffer = "Error in CreateBitmapFromMemory\n";
      }
  }
  </code></pre>