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. BitBlt problem ?????????????

BitBlt problem ?????????????

Scheduled Pinned Locked Moved C / C++ / MFC
graphicshelpquestion
6 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.
  • T Offline
    T Offline
    TooShy2Talk
    wrote on last edited by
    #1

    Hi, guyz. Hope you can help me with this one. I'm encountering a problem using BitBlt. I might implemented it wrong, please help me check it. code: .h: static CBitmap m_bitmap; OnDraw(CDC *pDC) { CDC BitmapDc; CBitmap *old_bitmap; BitmapDC.CreateCompatibleDC(pDC); old_bitmap=BitmapDC.SelectObject(&m_bitmap); // Drawing code here BitmapDc.Rectangle(top,bottom,right,bottom); ..................... .................... //****************************** // 1st CBitmap bitmap; CDC memDC; bitmap.LoadBitmap(L"START_BITMAP"); memDC.CretaeCompatibleDC(pDC); BitmapDC.BitBlt(top,left,right,bottom,&memDC,0,0,SRCCOPY); //****************************** // another drawing code for lines ................ ................. pDc->BitBlt(top,left,right,bottom,&BitmapDC,0,0,SRCCOPY); BitmapDC.SelectedObject(old_bitmap); // end of code From the above code, there's no problem work as expected. Image appears at the background of the lines. But, if i use HDC instead of the bitmap, the image were not seen and has been overlapped by a white fill. //****************************** // 2nd CDC memDC; memDC.Attach(m_hDC); BitmapDC.BitBlt(top,left,right,bottom,&memDC,0,0,SRCCOPY); //****************************** // m_hDC was returned from other class What is the difference with the 2? Why is the image were not seen using the 2nd code }

    N 1 Reply Last reply
    0
    • T TooShy2Talk

      Hi, guyz. Hope you can help me with this one. I'm encountering a problem using BitBlt. I might implemented it wrong, please help me check it. code: .h: static CBitmap m_bitmap; OnDraw(CDC *pDC) { CDC BitmapDc; CBitmap *old_bitmap; BitmapDC.CreateCompatibleDC(pDC); old_bitmap=BitmapDC.SelectObject(&m_bitmap); // Drawing code here BitmapDc.Rectangle(top,bottom,right,bottom); ..................... .................... //****************************** // 1st CBitmap bitmap; CDC memDC; bitmap.LoadBitmap(L"START_BITMAP"); memDC.CretaeCompatibleDC(pDC); BitmapDC.BitBlt(top,left,right,bottom,&memDC,0,0,SRCCOPY); //****************************** // another drawing code for lines ................ ................. pDc->BitBlt(top,left,right,bottom,&BitmapDC,0,0,SRCCOPY); BitmapDC.SelectedObject(old_bitmap); // end of code From the above code, there's no problem work as expected. Image appears at the background of the lines. But, if i use HDC instead of the bitmap, the image were not seen and has been overlapped by a white fill. //****************************** // 2nd CDC memDC; memDC.Attach(m_hDC); BitmapDC.BitBlt(top,left,right,bottom,&memDC,0,0,SRCCOPY); //****************************** // m_hDC was returned from other class What is the difference with the 2? Why is the image were not seen using the 2nd code }

      N Offline
      N Offline
      Naveen
      wrote on last edited by
      #2

      TooShy2Talk wrote:

      old_bitmap=BitmapDC.SelectObject(&m_bitmap);

      Before SelectObject(), have you created m_bitmap??? if not use CreateCompaitbleBitmap() to create the bitmap. And since the m_bitmap is a member variable, you should create it only once.

      nave [OpenedFileFinder]

      T 1 Reply Last reply
      0
      • N Naveen

        TooShy2Talk wrote:

        old_bitmap=BitmapDC.SelectObject(&m_bitmap);

        Before SelectObject(), have you created m_bitmap??? if not use CreateCompaitbleBitmap() to create the bitmap. And since the m_bitmap is a member variable, you should create it only once.

        nave [OpenedFileFinder]

        T Offline
        T Offline
        TooShy2Talk
        wrote on last edited by
        #3

        Yes, it was already initialized. Upon debugging, I noticed the effect of the BitmapDC.Rectangle(). The fill color that cover the image was somehow related to the Rectangle fill. Is it possible to create rectangle(BitmapDC.Rectangle()) without fill? But when 1st code is used this is not happening. Do you know why?

        N 1 Reply Last reply
        0
        • T TooShy2Talk

          Yes, it was already initialized. Upon debugging, I noticed the effect of the BitmapDC.Rectangle(). The fill color that cover the image was somehow related to the Rectangle fill. Is it possible to create rectangle(BitmapDC.Rectangle()) without fill? But when 1st code is used this is not happening. Do you know why?

          N Offline
          N Offline
          Naveen
          wrote on last edited by
          #4

          TooShy2Talk wrote:

          Is it possible to create rectangle

          Yes use the Draw3dRect() function for that. I thing Selecting a NULL brush to the BitmapDC and then calling the Rectangle() function will also work.

          nave [OpenedFileFinder]

          T 1 Reply Last reply
          0
          • N Naveen

            TooShy2Talk wrote:

            Is it possible to create rectangle

            Yes use the Draw3dRect() function for that. I thing Selecting a NULL brush to the BitmapDC and then calling the Rectangle() function will also work.

            nave [OpenedFileFinder]

            T Offline
            T Offline
            TooShy2Talk
            wrote on last edited by
            #5

            I have tried using BitmapDc.SelectBrush(NULL_BRUSH); before creating the rectangle BitmapDC.Rectangle(left,top,right,bottom); but then the cover fill become black. The image is still invisible.

            N 1 Reply Last reply
            0
            • T TooShy2Talk

              I have tried using BitmapDc.SelectBrush(NULL_BRUSH); before creating the rectangle BitmapDC.Rectangle(left,top,right,bottom); but then the cover fill become black. The image is still invisible.

              N Offline
              N Offline
              Naveen
              wrote on last edited by
              #6

              TooShy2Talk wrote:

              BitmapDc.SelectBrush(NULL_BRUSH);

              SelectBrush()?? Is there function like that in the CDC class? How about Draw3dRect() function?

              nave [OpenedFileFinder]

              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