Solved

Writing various data & bitmaps to one file

Posted on 1998-09-09
4
147 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
  • 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now