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. Bitmap Serialisation

Bitmap Serialisation

Scheduled Pinned Locked Moved C / C++ / MFC
graphicstutorial
7 Posts 3 Posters 1 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.
  • C Offline
    C Offline
    Chambers
    wrote on last edited by
    #1

    Hi all, I`ve managed to load a bitmap as a DIBSection and have kept the HBITMAP structure (I haven`t attached it to a CBitmap). However, now I want to serialize the bitmap in the widely used bitmap format. Currently I create a CFile object to the location I want to save, with the flags modeCreate | modeWrite, I then create a CArchive and set it to ::Store using this newly created file. I then attach my HBITMAP to a CBitmap object and call the serialize function. The "bitmap" is created in the location specified but its 0 bytes big, so I don`t think the CBitmap serialize is working, any ideas on how to solve this would be much appreciated, Cheers Guys, Alan. "When I left you I was but the learner, now I am the Master" - Darth Vader:mad:

    C C 2 Replies Last reply
    0
    • C Chambers

      Hi all, I`ve managed to load a bitmap as a DIBSection and have kept the HBITMAP structure (I haven`t attached it to a CBitmap). However, now I want to serialize the bitmap in the widely used bitmap format. Currently I create a CFile object to the location I want to save, with the flags modeCreate | modeWrite, I then create a CArchive and set it to ::Store using this newly created file. I then attach my HBITMAP to a CBitmap object and call the serialize function. The "bitmap" is created in the location specified but its 0 bytes big, so I don`t think the CBitmap serialize is working, any ideas on how to solve this would be much appreciated, Cheers Guys, Alan. "When I left you I was but the learner, now I am the Master" - Darth Vader:mad:

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

      Bitmaps do not support serialisation. Look at the bitmap section on Code Project for several classes to save bitmaps, also my GDI+ articles, and the FAQ lists several other options Only a master of evil, Darth - Obi Wan Kenobi Christian After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001

      Sonork ID 100.10002:MeanManOz

      I live in Bob's HungOut now

      C 1 Reply Last reply
      0
      • C Christian Graus

        Bitmaps do not support serialisation. Look at the bitmap section on Code Project for several classes to save bitmaps, also my GDI+ articles, and the FAQ lists several other options Only a master of evil, Darth - Obi Wan Kenobi Christian After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001

        Sonork ID 100.10002:MeanManOz

        I live in Bob's HungOut now

        C Offline
        C Offline
        Chambers
        wrote on last edited by
        #3

        Thanks Christian, I thought this question would be right up your alley! I like the return quote too, it humoured me quite a bit.:-D Cheers again Christian, Alan. "When I left you I was but the learner, now I am the Master" - Darth Vader:mad:

        1 Reply Last reply
        0
        • C Chambers

          Hi all, I`ve managed to load a bitmap as a DIBSection and have kept the HBITMAP structure (I haven`t attached it to a CBitmap). However, now I want to serialize the bitmap in the widely used bitmap format. Currently I create a CFile object to the location I want to save, with the flags modeCreate | modeWrite, I then create a CArchive and set it to ::Store using this newly created file. I then attach my HBITMAP to a CBitmap object and call the serialize function. The "bitmap" is created in the location specified but its 0 bytes big, so I don`t think the CBitmap serialize is working, any ideas on how to solve this would be much appreciated, Cheers Guys, Alan. "When I left you I was but the learner, now I am the Master" - Darth Vader:mad:

          C Offline
          C Offline
          Chambers
          wrote on last edited by
          #4

          I`ve checked the codeproject web-site and found a CxImage wrapper, which does serialisation amongst many other stuff. However I find it incredibly difficult to read (as its a multi-project thing with passwords etc.), but its too complex. It uses a FILE structure (of which I know nothin about) and fwrite. I was wanting to use CArchive's << operators (I know a tincy wincy thing about them), but I need to know which order to iterate through each member variable, does anyone know this? or can someone advise on a better approach (I just need a little kick in the right direction, cos I`m not sure what I`m doing at the moment:confused: ) Is GDI+ the way to go Christian? Thanks guys, Alan. "When I left you I was but the learner, now I am the Master" - Darth Vader:mad:

          G C 2 Replies Last reply
          0
          • C Chambers

            I`ve checked the codeproject web-site and found a CxImage wrapper, which does serialisation amongst many other stuff. However I find it incredibly difficult to read (as its a multi-project thing with passwords etc.), but its too complex. It uses a FILE structure (of which I know nothin about) and fwrite. I was wanting to use CArchive's << operators (I know a tincy wincy thing about them), but I need to know which order to iterate through each member variable, does anyone know this? or can someone advise on a better approach (I just need a little kick in the right direction, cos I`m not sure what I`m doing at the moment:confused: ) Is GDI+ the way to go Christian? Thanks guys, Alan. "When I left you I was but the learner, now I am the Master" - Darth Vader:mad:

            G Offline
            G Offline
            Ganesh Ramaswamy
            wrote on last edited by
            #5

            is that u have a proper HBITMAP and u want to persist this bitmap, if so refer MSDN Platform for storing bitmaps and it has a sample code. copy and paste ( if u dont wnat to understand ) and u r done ( ofcourse u have rename the variables ) Ganesh Ramaswamy

            1 Reply Last reply
            0
            • C Chambers

              I`ve checked the codeproject web-site and found a CxImage wrapper, which does serialisation amongst many other stuff. However I find it incredibly difficult to read (as its a multi-project thing with passwords etc.), but its too complex. It uses a FILE structure (of which I know nothin about) and fwrite. I was wanting to use CArchive's << operators (I know a tincy wincy thing about them), but I need to know which order to iterate through each member variable, does anyone know this? or can someone advise on a better approach (I just need a little kick in the right direction, cos I`m not sure what I`m doing at the moment:confused: ) Is GDI+ the way to go Christian? Thanks guys, Alan. "When I left you I was but the learner, now I am the Master" - Darth Vader:mad:

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

              Yes, GDI+ makes all of this incredibly easy. The only catch is it doesn't support W95. Christian After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001

              Sonork ID 100.10002:MeanManOz

              I live in Bob's HungOut now

              C 1 Reply Last reply
              0
              • C Christian Graus

                Yes, GDI+ makes all of this incredibly easy. The only catch is it doesn't support W95. Christian After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001

                Sonork ID 100.10002:MeanManOz

                I live in Bob's HungOut now

                C Offline
                C Offline
                Chambers
                wrote on last edited by
                #7

                Hi all, OK I`ve managed to get it going, and am just seeking a little reassurance. What I`ve done is created a (fully filled out) BITMAPINFO structure, and a (filled it out manually) BITMAPFILEHEADER structure. I`ve then used

                ar.Write(theBITMAPFILEHEADER, sizeof(BITMAPFILEHEADER));
                ar.Write(theBITMAPINFO, sizeof(BITMAPINFO));
                ar.Write(pBits, theBITMAPINFO->bmiHeader.biSizeImage);

                Now, I seek reassurance cos when I compare an image that exists on my HD, to an identical copy that I saved using my app, the newly saved image is 2 bytes shorter (in at least one case). I`ve tried re-loading the new image in paint, everything seems fine, do I just leave it? Or is this a problem that could potentially send my computer kaput? Cheers all for your responses, Alan.:-D "When I left you I was but the learner, now I am the Master" - Darth Vader:mad:

                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