Solved

Writing various data & bitmaps to one file

Posted on 1998-09-09
4
151 Views
Last Modified: 2013-12-03
I am trying to read and write to a file that will consist of  text, integers, and bitmaps.
Is there anyone who can help me with this problem?
Is there a way to save all the data, including the bitmap(not the name of the bitmap,but the actual bitmap),  into one file?
Thank you in advance.
0
Comment
Question by:mpereira
[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
  • 2
  • 2
4 Comments
 

Author Comment

by:mpereira
ID: 1321974
Edited text of question
0
 
LVL 2

Accepted Solution

by:
prasanth earned 200 total points
ID: 1321975
Consider using CArchive. You can write out all sorts of data types and as long as they are read back in the same order, everything works great.
0
 

Author Comment

by:mpereira
ID: 1321976
Will this create a file containing the bitmap or will i still need the actual bitmap too.
I'm trying to create an application that will create files containing data and bitmaps, so that all I need to reload the data and bitmaps,  is a file,  even if the bitmaps are no longer on my computer.
Thank you.
0
 
LVL 2

Expert Comment

by:prasanth
ID: 1321977
You will need to write out the bitmap to the file. I think there is a function like GetDIBBits() or something that gets the bits of any bitmap into a byte array. Using that you can then write out the byte array to the CArchive file.

something like this to write out:

HBITMAP hbm;
BYTE barray[((height*width)/bitsperpixel)/8]
GetDibBits(hbm, &barray); // this may not be what the function is actually named. but there is something similar to it
archive << height;
archive << width;
archive << bitsperpixel;
archive.Write(barray, ((height*width)/bitsperpixel)/8);

and to read in:

archive >> height;
archive >> width
archive >> bitsperpixel;
BYTE* pbarray = new BYTE[((height*width)/bitsperpixel)/8];
archive.Read(pbarray, ((height*width)/bitsperpixel)/8);
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Doc'in system (example?) BA 7 120
tripleUp challenge 7 93
EvenOdd challenge 10 146
Making an alias 7 113
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

749 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