title: Draw a bitmap directly into dialog box?
body: <p>I have the BITMAPFILEHEADER, BITMAPINFOHEADER, and the image data of a bitmap stored in variables named, say, bf, bi, and imageData, respectively.  When I output these to a .bmp file, I can open it without problem and view the image.  I can also write some code to import this bmp file and display it in my dialog box.</p>
  
  <p>My question is:  is there an easy way to cut out the middle man and take my BITMAPFILEHEADER, BITMAPINFOHEADER, and image data and directly write these data into a 24 bitmap image displayed in the dialog box, without the need of using an external file?</p>
  
  <p>For reference, here is the code I'm using now to output to a file, then input this file into the dialog box:</p>
  
  <pre><code>    //fileheader
      BITMAPFILEHEADER* bf = new BITMAPFILEHEADER;
      bf-&gt;bfType = 0x4d42;
      bf-&gt;bfSize = 6054400 + 54;
      bf-&gt;bfOffBits = 54;
  
      //infoheader
      BITMAPINFOHEADER* bi = new BITMAPINFOHEADER;
      bi-&gt;biSize = 40;
      bi-&gt;biWidth = 2752;
      bi-&gt;biHeight = -733;
      bi-&gt;biPlanes = 1;
      bi-&gt;biBitCount = 24;
      bi-&gt;biCompression = 0;
      bi-&gt;biSizeImage = 6054400;
      bi-&gt;biXPelsPerMeter = 2835;
      bi-&gt;biYPelsPerMeter = 2835;
      bi-&gt;biClrUsed = 0;
      bi-&gt;biClrImportant = 0;
  
      //image data
      unsigned char* imageData = new unsigned char[6054400];
      pFrame-&gt;GetImage(imageData);
  
  
      //////////////////////////////////////////////////////////////////////////
      //////////  Output to .bmp File   ////////////////////////////////////////
      //////////////////////////////////////////////////////////////////////////
  
  
      std::ofstream outFile;
  
      outFile.open("test.bmp", std::ios::binary|std::ios::out);
  
      outFile.write(reinterpret_cast&lt;char *&gt;(bf), sizeof(BITMAPFILEHEADER));
      outFile.write(reinterpret_cast&lt;char *&gt;(bi), sizeof(BITMAPINFOHEADER));
      outFile.write(reinterpret_cast&lt;char *&gt;(imageData), 6054400);
  
      outFile.close();
  
      //////////////////////////////////////////////////////////////////////////
      //////////  input .bmp and print to dialog box   /////////////////////////
      //////////////////////////////////////////////////////////////////////////
  
      CString szFilename ("C:/dev/NanoDev/TestApps/AVT_Testapp/test.bmp");
      HBITMAP hBmp = (HBITMAP)::LoadImage(NULL, szFilename, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION);
      CBitmap bmp;
      bmp.Attach(hBmp);
      CClientDC dc(this);
      CDC bmDC;
      bmDC.CreateCompatibleDC(&amp;dc);
      CBitmap *pOldbmp = bmDC.SelectObject(&amp;bmp);
      BITMAP  bi;
      bmp.GetBitmap(&amp;bi);
      dc.BitBlt(384,26,bi.bmWidth/3,bi.bmHeight,&amp;bmDC,0,0,SRCCOPY);
      bmDC.SelectObject(pOldbmp);
  </code></pre>