Copying CBitmaps

I'd like to copy a bitmap or a portion of one from one CBitmap object to another CBitmap object:
m_bmTheBitmap -> bmTemp

Is this procedure right/wrong/right but not best/etc..

// create dcs
dcScreen.CreateDC("DISPLAY", NULL, NULL, NULL);
dcMem.CreateCompatibleDC(&dcScreen);
dcMem2.CreateCompatibleDC(&dcScreen);

// create bitmap
bmTemp.CreateCompatibleBitmap(&dcScreen, 70, 70);

// Get picture into bmTemp
dcMem.SelectObject(&m_bmTheBitmap);
dcMem2.SelectObject(&bmTemp);
dcMem2.BitBlt(0, 0,
   70, 70, &dcMem,
   0, 0,
   SRCCOPY);
LVL 1
mjswartAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
chensuConnect With a Mentor Commented:
It is right. You might want to take a look at the CopyBitmap and CropBitmap functions of the ShowDIB sample that comes with Visual C++ or the Platform SDK, which uses exactly the same technique.
0
 
mjswartAuthor Commented:
Edited text of question.
0
 
mjswartAuthor Commented:
Yes this is the proper way to do the copying,
However, it's important to remember to call CDC::DeleteDC() if you want to do the same thing soon after in invoked functions.
Thanks for your help.
0
All Courses

From novice to tech pro — start learning today.