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