Solved

saving figures

Posted on 1998-07-10
6
181 Views
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?
0
Comment
Question by:Abbas071098
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 

Expert Comment

by:bfwizard
ID: 1318978
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())
      {
                  
            
      }
      else
      {
                  
            
      }

      CMyBitMapObject.Serialize(ar);
      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
0
 

Author Comment

by:Abbas071098
ID: 1318979
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.
0
 
LVL 2

Expert Comment

by:duneram
ID: 1318980
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.



0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Abbas071098
ID: 1318981
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
0
 
LVL 2

Expert Comment

by:duneram
ID: 1318982
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.


0
 
LVL 2

Accepted Solution

by:
duneram earned 50 total points
ID: 1318983
here is an example

struct
{
    short type;
    long length;
} hdr;

Setting hdr.type to 1 would mean one thing.

setting hdr.type to 2 would be for a different type of object.

In your single file you would place these objects back to back.
like this:

hdr
obj 1
hdr
obj 2
hdr
obj 3

each hdr would have  a  specific type and you would use the method for the type to properly decode the binary information into the right format.

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ASCII Non-Printable characters/codes and their HTML equivalents 6 158
notReplace  challenge 53 152
ffmpeg - "rtsp://...... Operation not permitted" 4 92
mapAB Challlenge 35 180
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question