Memory Device context+Createcompatible Bitmap related query
-
In a function i am doing following things Function starts
// m_Analyser is object of class CAnalyser and having a member // CBitmap i.e. CBitmap m_WFRBitmap; // GetWFRBitmap() returns that Bitmap i.e. // CBitmap *GetWFRBitmap() { return &m_WFRBitmap; } CBitmap *pWFRBitmap = pDoc->m_Analyzer.GetWFRBitmap(); pWFRBitmap->CreateCompatibleBitmap(&ClientDC, 860, 1100); ClientDC.SetMapMode(MM_LOENGLISH); CDC MemDC; MemDC.CreateCompatibleDC(&ClientDC); MemDC.SelectObject(pWFRBitmap); MemDC.SetMapMode(MM_TEXT); //********** // Draw to the Memory device context //************* MemDC.SetMapMode(MM_LOENGLISH);
Function ENds 1.0 What exactly will happen. To the bitmap in CAnalyser and MemDC. Will the content of MemDC will be written to CBitmap which is attached to MemDC. 2.0 What will happen if every thing remains same and i make CDC MemDC global? 3.0 I want to make another function in CAnalyser like SetBitmap and want to assign the content of the CDC MemDC (global) to assigned to that CBitmap member of CAnalyser m_WFRBitmap so that i can draw the bitmap again whenever my screen get redrawn instead of carrying out complete drawing process again and again. How to do this? :rose: Leave your mark wherever you go -
In a function i am doing following things Function starts
// m_Analyser is object of class CAnalyser and having a member // CBitmap i.e. CBitmap m_WFRBitmap; // GetWFRBitmap() returns that Bitmap i.e. // CBitmap *GetWFRBitmap() { return &m_WFRBitmap; } CBitmap *pWFRBitmap = pDoc->m_Analyzer.GetWFRBitmap(); pWFRBitmap->CreateCompatibleBitmap(&ClientDC, 860, 1100); ClientDC.SetMapMode(MM_LOENGLISH); CDC MemDC; MemDC.CreateCompatibleDC(&ClientDC); MemDC.SelectObject(pWFRBitmap); MemDC.SetMapMode(MM_TEXT); //********** // Draw to the Memory device context //************* MemDC.SetMapMode(MM_LOENGLISH);
Function ENds 1.0 What exactly will happen. To the bitmap in CAnalyser and MemDC. Will the content of MemDC will be written to CBitmap which is attached to MemDC. 2.0 What will happen if every thing remains same and i make CDC MemDC global? 3.0 I want to make another function in CAnalyser like SetBitmap and want to assign the content of the CDC MemDC (global) to assigned to that CBitmap member of CAnalyser m_WFRBitmap so that i can draw the bitmap again whenever my screen get redrawn instead of carrying out complete drawing process again and again. How to do this? :rose: Leave your mark wherever you go1.0 Yes! Because MemDC contains your bitmap and therefore is draw on your bitmap. Before calling CreateCompatibleBitmap() make sure that the bitmap does not already exist or you will have problems. DO NOT for get to restore the origanal bitmap to the MemDC after drawing to it. 2.0 & 3.0 The only reason for making MemDC global is so you will not have to call CreateCompatibleDC() more than once. You will still need to clean it up after evey usage though. That is call SelectObject(pOldBitmap) after drawing to bitmap or using MemDC to blit the image to the client area. Lookup CDC::CreateCompatibleDC() in the MSDN library (there is sample code there) INTP