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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. moving bitmap using Cbitmap and CDC

moving bitmap using Cbitmap and CDC

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsalgorithmstutorial
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.
  • A Offline
    A Offline
    Arif Liminto
    wrote on last edited by
    #1

    Hi, I got some difficulity how to move bitmap image in my application basically, the algorithm is like this, I've got CDC as m_MapDC and it already being created and DrawPoint basically use for draw truck in the mapDC but the result is there is no truck in the map However, If I use CPen class instead of using CBitmap, I can see the line is moving from one point to other point. Any body have suggestions void Ctrainc::DrawPoint() { CBitmap btruck; CBitmap *pbtruck = NULL; pbtruck = (CBitmap*)m_MapDC.selectObject(&btruck); m_MapDC.MoveTo(m_PrevTruckPoint.m_iX,m_PrevTruckPoint.m_iY); //move to the new pos m_MapDC.LineTo(m_CurrTruckPoint.m_iX,m_CurrTruckPoint.m_iY); m_MapDC.SelectObject(pOrbtruck); btruck.DeleteObject(); } Regards, Arif Liminto

    CPalliniC 1 Reply Last reply
    0
    • A Arif Liminto

      Hi, I got some difficulity how to move bitmap image in my application basically, the algorithm is like this, I've got CDC as m_MapDC and it already being created and DrawPoint basically use for draw truck in the mapDC but the result is there is no truck in the map However, If I use CPen class instead of using CBitmap, I can see the line is moving from one point to other point. Any body have suggestions void Ctrainc::DrawPoint() { CBitmap btruck; CBitmap *pbtruck = NULL; pbtruck = (CBitmap*)m_MapDC.selectObject(&btruck); m_MapDC.MoveTo(m_PrevTruckPoint.m_iX,m_PrevTruckPoint.m_iY); //move to the new pos m_MapDC.LineTo(m_CurrTruckPoint.m_iX,m_CurrTruckPoint.m_iY); m_MapDC.SelectObject(pOrbtruck); btruck.DeleteObject(); } Regards, Arif Liminto

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      To draw a bitmap on (x,y) position you need to: (1) Create a memory DC, via CDC::CreateCompatibleDC. (2) Select the bitmap into the memory DC. (3) Use the CDC::BitBlt method. See here [^] for a code sample. :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      In testa che avete, signor di Ceprano?

      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