title: CImage::Load() from memory without using CreateStreamOnHGlobal
body: <p>I am displaying a live view video from camera. Every frame I download into a byte array (pImageData) which I have to allocate.</p>
  
  <p>Now, to display, I am using a CImage (MFC). 
  However, all samples I find are based on using GlobalAlloc, yet another memcpy and CreateStreamOnHGlobal.</p>
  
  <p>I'd like to avoid doing another allocation/deallocation and memory copy. Each frame is over 2mb and I am pushing 30 fps!</p>
  
  <p>Is it possible to create an IStream on non-HGLOBAL based memory?
  OR
  Is it somehow possible to coerce Image::Load() to work with byte array?</p>
  
  <p>Here is the code:</p>
  
  <pre><code>// pImageData is an array with bytes, size is the sizeOfThatArray
  
  CComPtr&lt;IStream&gt; stream;
  
  HGLOBAL hMem = ::GlobalAlloc(GHND, size);
  LPVOID pBuff = ::GlobalLock(hMem);
  
  memcpy(pBuff, pImageData, size); // &lt;-- would like to avoid this
  
  ::GlobalUnlock(hMem);
  
  CreateStreamOnHGlobal(hMem, TRUE, &amp;stream); // &lt;-- or create stream on non-hglobal memory
  
  CImage image;
  image.Load(stream); // &lt;-- Or load directly from pImageData
  
  // .. display image
  
  image.Destroy();
  
  ::GlobalFree(hMem);
  </code></pre>