Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Store two images in one file

Reply
Thread Tools

Store two images in one file

 
 
Ben
Guest
Posts: n/a
 
      12-12-2005
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?

 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      12-12-2005
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
 
Reply With Quote
 
 
 
 
Ben
Guest
Posts: n/a
 
      12-12-2005
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?

 
Reply With Quote
 
Ben
Guest
Posts: n/a
 
      12-12-2005
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?

 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      12-12-2005
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
 
Reply With Quote
 
Ben
Guest
Posts: n/a
 
      12-12-2005
****

 
Reply With Quote
 
Ben
Guest
Posts: n/a
 
      12-12-2005
The code is above.

 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      12-12-2005
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
 
Reply With Quote
 
michaelkatsilis@yahoo.com
Guest
Posts: n/a
 
      12-12-2005
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

 
Reply With Quote
 
Earl Purple
Guest
Posts: n/a
 
      12-13-2005

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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to read parse data from two file to generate one one file Asif Iqbal Ruby 0 08-06-2009 04:47 PM
Corrupted images after attempting to store PNG images as BLOBs inMySQL? Keith Hughitt Python 6 08-14-2008 01:47 AM
placing two images one in front and one behind Nospam HTML 6 03-23-2007 12:47 AM
to store or not to store an image =?Utf-8?B?UnVkeQ==?= ASP .Net 6 03-30-2005 05:51 AM
CSS aligning two things on one line with one left and one right news.frontiernet.net HTML 6 04-16-2004 02:44 AM



Advertisments