?
Solved

Writing various data & bitmaps to one file

Posted on 1998-09-09
4
Medium Priority
?
154 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 400 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

743 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