Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Memory Device context+Createcompatible Bitmap related query

Memory Device context+Createcompatible Bitmap related query

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsdatabaseperformancetutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JHAKAS
    wrote on last edited by
    #1

    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

    J 1 Reply Last reply
    0
    • J JHAKAS

      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

      J Offline
      J Offline
      John R Shaw
      wrote on last edited by
      #2

      1.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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups