Copy CView contents to a bitmap
Posted on 2011-10-17
I'd like to create a bitmap copy of the current contents of my CView, which may or may not be currently visible on the screen. Here is the code I've added to my OnDraw function:
... normal processing ...
// Copy the view contents to a bitmap.
dc.CreateCompatibleDC( pDC );
if ( m_pBitmap != NULL )
m_pBitmap = new CBitmap();
m_pBitmap->CreateCompatibleBitmap( &dc, szView.cx, szView.cy );
CBitmap* pOld = ( CBitmap* )dc.SelectObject( m_pBitmap );
dc.BitBlt( 0, 0, szView.cx, szView.cy, pDC, 0, 0, SRCCOPY );
dc.SelectObject( pOld );
But now when I examine the bitmap I can see that there is only 1 bit per pixel. I'm sure I'm missing something, can anyone help?