We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


saving figures

Abbas071098 asked
Medium Priority
Last Modified: 2013-11-19
I want to save a file which contains certain fiures, both regular and random. I want to save the regular figures by saving their pattern but the random figures cannot be saved in this manner, they have to be saved by some other method say using bitmaps. But a single file can contain both regular as well as random figures and I want to save these figures as a single file. What can be done?
Watch Question

well assuming you know how to change your random figures in to bitmaps...saving is a snap.  Since The CBitmap object is inherited from CObject you can just use its serialize function.  Also Assuming all you data is in the document you just need to override the document's serialze function:

void CMyDocDoc::Serialize(CArchive& ar)
      if (ar.IsStoring())

      CMyRegularListofPoints.Serialize(ar);///assuming some sort of list or you could use the braces up above in Isstoringex:  ar<<point1<<point2....ect or in the else...ar>>point1>>point2


if you need more detail comment here


bfwizard, the solution that you told me, will it save the two types of figures in two different files. And if in the the same file what will be the file format. My problem is I don't want to save the regular figure as the bitmap but as a metafile. But there should be only one file as output (saved) file.

Why not create a special header that has a flag for bitmap follows or not.

in the header if a bitmap follows, you just set the flag.
if a bitmap doesn't follow you don't set the flag.

Then in the header you store the length of the 'object'

When writing you make a header, append header to file, then append data to file.

When reading, you read a header,
   if its a bitmap you load it as a bitmap.
   if its not a bitmap, you load it and then do your processing.

You can use the fread and fwrite to accomplish this task....  with these functions you can load from a file directly into a structure and store from a structure directly to a file.


I want different types of figures to be stored in the same file sorry I am not getting the correct answer so I am gonna delete the question

The answer I gave you would have permitted you to store different types of figures in the same file.  It allowed multiple objects within a file with each object having its own header.

Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.