By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,227 Members | 1,240 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,227 IT Pros & Developers. It's quick & easy.

Store two images in one file

P: n/a
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?

Dec 12 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Ben wrote:
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
Dec 12 '05 #2

P: n/a
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?

Dec 12 '05 #3

P: n/a
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?

Dec 12 '05 #4

P: n/a
Ben wrote:
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
Dec 12 '05 #5

P: n/a
Ben
Twat

Dec 12 '05 #6

P: n/a
Ben
The code is above.

Dec 12 '05 #7

P: n/a
Ben wrote:
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
Dec 12 '05 #8

P: n/a
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

Dec 12 '05 #9

P: n/a

Ben wrote:
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.

Dec 13 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.