Store two images in one file

Discussion in 'C++' started by Ben, Dec 12, 2005.

  1. Ben

    Ben Guest

    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?
     
    Ben, Dec 12, 2005
    #1
    1. Advertising

  2. 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
     
    Victor Bazarov, Dec 12, 2005
    #2
    1. Advertising

  3. Ben

    Ben Guest

    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?
     
    Ben, Dec 12, 2005
    #3
  4. Ben

    Ben Guest

    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?
     
    Ben, Dec 12, 2005
    #4
  5. 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
     
    Victor Bazarov, Dec 12, 2005
    #5
  6. Ben

    Ben Guest

    Twat
     
    Ben, Dec 12, 2005
    #6
  7. Ben

    Ben Guest

    The code is above.
     
    Ben, Dec 12, 2005
    #7
  8. 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
     
    Victor Bazarov, Dec 12, 2005
    #8
  9. Ben

    Guest

    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, 2005
    #9
  10. Ben

    Earl Purple Guest

    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.
     
    Earl Purple, Dec 13, 2005
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UnVkeQ==?=

    to store or not to store an image

    =?Utf-8?B?UnVkeQ==?=, Mar 29, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    655
    =?Utf-8?B?UnVkeQ==?=
    Mar 30, 2005
  2. news.frontiernet.net
    Replies:
    6
    Views:
    1,141
    news.frontiernet.net
    Apr 16, 2004
  3. Nospam
    Replies:
    6
    Views:
    478
    Bergamot
    Mar 23, 2007
  4. Keith Hughitt
    Replies:
    6
    Views:
    1,080
  5. Asif Iqbal
    Replies:
    0
    Views:
    163
    Asif Iqbal
    Aug 6, 2009
Loading...

Share This Page