title: MFC - How to draw a color bitmap to the dialog DC
body: <p>I've got this snippet of code in a camera acquisition loop:</p>
  
  <pre><code>CBitmap* bmp = new CBitmap();
  CDC* pDC;
  CBitmap* old;
  CDC*  memDC = new CDC();
  
  pDC = pLiveImageDlg-&gt;GetDC();
  
  bmp-&gt;CreateCompatibleBitmap(pDC, 640, 480);
  
  memDC-&gt;CreateCompatibleDC(pDC);
  old = memDC-&gt;SelectObject(bmp);
  
  bmp-&gt;SetBitmapBits(640 * 480 * 3, frame.data);
  
  pDC-&gt;BitBlt(0, 0, 640, 480, memDC, 0, 0, SRCCOPY);
  
  memDC-&gt;SelectObject(old);
  </code></pre>
  
  <p>My issue is, when viewing the bitmap that gets drawn onto the dialog, it looks completely distorted and monochrome. Normally, an image being distorted means the pixel indexing is off (wrong color format, etc). The "frame" variable is an OpenCV Mat object, which is grabbing the image as a 24-bit RGB format (displays perfectly fine in color using <code>imshow()</code>). I have the feeling that the monochrome issue is related to the <code>CreateCompatibleDC</code> function call since by default it creates a 1x1 monochrome pixel, according to the MSDN docs ... and this monochrome issue might be causing the "pixel byte array offset" issue.</p>
  
  <p>What's the right way to go about getting a bitmap blitted to the screen as a 24-bit RGB bitmap?</p>