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. viewing and updating bitmaps

viewing and updating bitmaps

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsquestion
7 Posts 4 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.
  • K Offline
    K Offline
    kitty5
    wrote on last edited by
    #1

    I've created an MDI application where when I open one dialog it shows a bitmap from my C:/ by: void Image::showPicture(BYTE bfr[], DWORD size) { HBITMAP m_bitmap = NULL; CImage image; CJpeg2kDecoder imDec; image = imDec.Open(bfr, size); m_bitmap = (HBITMAP)image; m_nCam1img.SetBitmap(m_bitmap); if (m_bitmap) DeleteObject(m_bitmap); However, when I open another dialog to do commanding (this dialog will partially cover the bitmap dialog) then go back to view my bitmap the portion of the bitmap dialog covered up by the commanding dialog is GONE! What do i need to do so that when I go back to view the bitmap dialog that the whole picture will still be displayed? Thanks!

    Kitty5

    C H M 3 Replies Last reply
    0
    • K kitty5

      I've created an MDI application where when I open one dialog it shows a bitmap from my C:/ by: void Image::showPicture(BYTE bfr[], DWORD size) { HBITMAP m_bitmap = NULL; CImage image; CJpeg2kDecoder imDec; image = imDec.Open(bfr, size); m_bitmap = (HBITMAP)image; m_nCam1img.SetBitmap(m_bitmap); if (m_bitmap) DeleteObject(m_bitmap); However, when I open another dialog to do commanding (this dialog will partially cover the bitmap dialog) then go back to view my bitmap the portion of the bitmap dialog covered up by the commanding dialog is GONE! What do i need to do so that when I go back to view the bitmap dialog that the whole picture will still be displayed? Thanks!

      Kitty5

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      What is m_nCam1img ? You're deleting the bitmap, why, when it's in use ?

      Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

      K 1 Reply Last reply
      0
      • K kitty5

        I've created an MDI application where when I open one dialog it shows a bitmap from my C:/ by: void Image::showPicture(BYTE bfr[], DWORD size) { HBITMAP m_bitmap = NULL; CImage image; CJpeg2kDecoder imDec; image = imDec.Open(bfr, size); m_bitmap = (HBITMAP)image; m_nCam1img.SetBitmap(m_bitmap); if (m_bitmap) DeleteObject(m_bitmap); However, when I open another dialog to do commanding (this dialog will partially cover the bitmap dialog) then go back to view my bitmap the portion of the bitmap dialog covered up by the commanding dialog is GONE! What do i need to do so that when I go back to view the bitmap dialog that the whole picture will still be displayed? Thanks!

        Kitty5

        H Offline
        H Offline
        Hamid Taebi
        wrote on last edited by
        #3

        What happens if you delete this line if (m_bitmap) DeleteObject(m_bitmap);


        WhiteSky


        K 1 Reply Last reply
        0
        • C Christian Graus

          What is m_nCam1img ? You're deleting the bitmap, why, when it's in use ?

          Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

          K Offline
          K Offline
          kitty5
          wrote on last edited by
          #4

          m_nCam1img is the variable for the picture control. the if (m_bitmap) DeleteObject(m_bitmap); I thought that that was what you needed to do. I did some research on how to view bmps and all the sample code had that....

          Kitty5

          C 1 Reply Last reply
          0
          • H Hamid Taebi

            What happens if you delete this line if (m_bitmap) DeleteObject(m_bitmap);


            WhiteSky


            K Offline
            K Offline
            kitty5
            wrote on last edited by
            #5

            ok so I deleted the line: if (m_bitmap) DeleteObject(m_bitmap); but i still have the same problem. is there an update function for the window when the mouse clicks back to view the picture dialog box after the command dialog box was on top of it?

            Kitty5

            1 Reply Last reply
            0
            • K kitty5

              m_nCam1img is the variable for the picture control. the if (m_bitmap) DeleteObject(m_bitmap); I thought that that was what you needed to do. I did some research on how to view bmps and all the sample code had that....

              Kitty5

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              Try removing it.  You do need to call it, but after you're not using the bitmap anymore.  I don't think a picture control makes a copy.

              Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

              1 Reply Last reply
              0
              • K kitty5

                I've created an MDI application where when I open one dialog it shows a bitmap from my C:/ by: void Image::showPicture(BYTE bfr[], DWORD size) { HBITMAP m_bitmap = NULL; CImage image; CJpeg2kDecoder imDec; image = imDec.Open(bfr, size); m_bitmap = (HBITMAP)image; m_nCam1img.SetBitmap(m_bitmap); if (m_bitmap) DeleteObject(m_bitmap); However, when I open another dialog to do commanding (this dialog will partially cover the bitmap dialog) then go back to view my bitmap the portion of the bitmap dialog covered up by the commanding dialog is GONE! What do i need to do so that when I go back to view the bitmap dialog that the whole picture will still be displayed? Thanks!

                Kitty5

                M Offline
                M Offline
                Mark Salsbery
                wrote on last edited by
                #7

                Your CImage object goes out of scope at the end of the function so it probably destroys the HBITMAP via its destructor. Instead of m_bitmap = (HBITMAP)image; try m_bitmap = image.Detach(); and remove this line: if (m_bitmap) DeleteObject(m_bitmap); Mark

                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