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
Solved

Writing various data & bitmaps to one file

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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…
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…

839 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