Solved

Writing various data & bitmaps to one file

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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
no14 challenge 14 76
NotAlone Challenge 20 92
changeXy challenge 13 96
how do you get these � Marks in your text? 9 114
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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…
Suggested Courses

739 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