Store two images in one file

B

Ben

Hi

Please Help?!

I have created a file which contains some app settings, plus two
images. I used the code below to read the contents of the image, then
save it with my app settings:

ifstream reader1(image1Path, ios::in | ios::binary);
ifstream reader2(image1Path, ios::in | ios::binary);

ofstream writer(myAppSettingsPath, ios::app | ios::binary);

writer << reader1.rdbuf();
writer << reader2.rdbuf();

reader1.close();
reader2.close();
writer.close();

I need some help retrieving the two image files from the file i've
created into a bitmap object - can anyone help?
 
V

Victor Bazarov

Ben said:
I have created a file which contains some app settings, plus two
images. I used the code below to read the contents of the image, then
save it with my app settings:

ifstream reader1(image1Path, ios::in | ios::binary);
ifstream reader2(image1Path, ios::in | ios::binary);

ofstream writer(myAppSettingsPath, ios::app | ios::binary);

writer << reader1.rdbuf();
writer << reader2.rdbuf();

reader1.close();
reader2.close();
writer.close();

I need some help retrieving the two image files from the file i've
created into a bitmap object - can anyone help?

I am not sure what kind of help you're expecting. There are "image" or
"bitmap" AFA C++ is concerned. Those things are what you make of them,
they are not language constructs. So, from the language point of view,
there is nothing we can do for you. That said, what particular _C++_
language problem do you have? Spell it out, we'll be happy to assist you
there.

V
 
B

Ben

Thanks for your reply. I am using MS VC++.

I understand that images are nothing to do with the language itself.
My problem is that I do not know how to extract the image data from my
file once I have combined it with some settings. How would you do this
using vc++?

btw, If there is a better place to post this message please let me know?
 
B

Ben

Thanks for your reply. I am using MS VC++.

I understand that images are nothing to do with the language itself.
My problem is that I do not know how to extract the image data from my
file once I have combined it with some settings. How would you do this
using vc++?

btw, If there is a better place to post this message please let me know?
 
V

Victor Bazarov

Ben said:
Thanks for your reply. I am using MS VC++.

'comp.lang.c++' is compiler-neutral. In almost any case it does not
matter what compiler you're using.
I understand that images are nothing to do with the language itself.

Then you must understand that there is no _language_ solution we can
offer, except perhaps something you already know, most likely. You do
know about 'read' or 'get' members of file stream classes, don't you?
My problem is that I do not know how to extract the image data from my
file once I have combined it with some settings.

It depends _entirely_ on the way you used to "combine" them. Since
neither "image data" nor "some settings" are language-related, how can
we help you and still stay on topic of this newsgroup?
> How would you do this
using vc++?

I have no idea. You didn't provide enough information (not that I want
you to).
btw, If there is a better place to post this message please let me know?

I have no idea about this either. It all depends on how you "combined"
your "settings" and "images". Of course, there is always the newsgroup
'microsoft.public.vc.language', but again, the technique to "extract
images" has nothing to do with the compiler or with the programming
language you used, but on the ways you stuff those images in a file in
the first place.

If you would like us to help you read some information from a file, tell
us how the information is stored. At least, post the code that you used
to write that information to the file.

V
 
V

Victor Bazarov

Ben said:
The code is above.

Ben, to extract the data you wrote using 'write', use 'read'. It's
unknown from what point you need to read because you use the append
mode. It is unknown how many bytes to read because you lose that
information (you don't seem to store it anywhere). Without knowing
how far to offset (if you know, use 'seekg'), and how much to read,
how would _anybody_ be able to read those images from the file? Any
file you create is essentially a collection of bytes, unrelated to
each other and really unrelated to the origin. You need to supply
some "business logic" to apply some meaning to those bytes you have
in the file. Think about it.

V
 
M

michaelkatsilis

Ben,

Victor has answered some of your question. However, it looks like you
need to put more thought into the detail of the design and format of
the file you're creating. Do you need to store two image files and
application information in the same file? If so, then one method is to
have a section of blocks to store some of this info so it's accessable.


FYI. This question is not related to the C++ language itself, it's a
design issue. The only help I can offer at this stage is to go back to
the drawing board and complete your design before posting vague
questions that will result in no real help to yourself (not meaning
disrespect here), or maybe provide clear info and some code with
specific problems that we can help you with.

Also, the subject of this post "Store two images in one file" doesn't
hint to any problem, as you've stated that you've done this.

Regard,

Michael
 
E

Earl Purple

Ben said:
Hi

Please Help?!

I have created a file which contains some app settings, plus two
images. I used the code below to read the contents of the image, then
save it with my app settings:

ifstream reader1(image1Path, ios::in | ios::binary);
ifstream reader2(image1Path, ios::in | ios::binary);

ofstream writer(myAppSettingsPath, ios::app | ios::binary);

writer << reader1.rdbuf();
writer << reader2.rdbuf();

reader1.close();
reader2.close();
writer.close();

I need some help retrieving the two image files from the file i've
created into a bitmap object - can anyone help?

If what you are trying to do is split your merged file back into two
files, then there is no way of doing this unless you know somehow where
one ends and the next one begins, and you can only do that if you know
exactly how the files are structured, eg. is there any header info or
terminating sequence to tell you where the first one ends.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top