Reading and Writing GIF files

Discussion in 'C++' started by masud, Jul 30, 2003.

  1. masud

    masud Guest

    Hi!
    I want to know how to read a GIF file in binary mode so that i can
    seperately read each byte and alter it if i want to. After alteration
    of any bit, i want to write the whole GIF file again in a new file as
    it is. I am working on the Linux platform. Any help in this regard
    would be highly appreciated.
    Thankyou.
    Masud.

    --
    Posted via http://dbforums.com
     
    masud, Jul 30, 2003
    #1
    1. Advertising

  2. masud

    Allan Bruce Guest

    "masud" <> wrote in message
    news:...
    >
    > Hi!
    > I want to know how to read a GIF file in binary mode so that i can
    > seperately read each byte and alter it if i want to. After alteration
    > of any bit, i want to write the whole GIF file again in a new file as
    > it is. I am working on the Linux platform. Any help in this regard
    > would be highly appreciated.
    > Thankyou.
    > Masud.
    >
    > --
    > Posted via http://dbforums.com


    This is not easy to do.
    The only on-topic part of this is reading the file in binary mode, but this
    is the least of your worries. Check http://www.wotsit.org/ to see how to
    encode/decode the GIF file format.
    Allan
     
    Allan Bruce, Jul 30, 2003
    #2
    1. Advertising

  3. masud

    Chris Theis Guest

    "masud" <> wrote in message
    news:...
    >
    > Hi!
    > I want to know how to read a GIF file in binary mode so that i can
    > seperately read each byte and alter it if i want to. After alteration
    > of any bit, i want to write the whole GIF file again in a new file as
    > it is. I am working on the Linux platform. Any help in this regard
    > would be highly appreciated.
    > Thankyou.
    > Masud.
    >


    This approach is not limited to GIF files but to any binary file. Just open
    the file in binary mode and use the read method.
    For example:

    std::ifstream is( "myfile.gif", ios::binary );
    char Data;

    if( !is ) {
    cerr << "Can't open input file" << endl;
    return false;
    }

    while( is.read( (char*) &Data, sizeof(char) ) ) {
    // ... do something
    }

    To write the a file in binary mode just check out the write method of
    ofstream.

    HTH
    Chris
     
    Chris Theis, Jul 30, 2003
    #3
  4. masud

    Carl Muller Guest

    masud <> wrote in message news:<>...
    > Hi!
    > I want to know how to read a GIF file in binary mode so that i can
    > seperately read each byte and alter it if i want to. After alteration
    > of any bit, i want to write the whole GIF file again in a new file as
    > it is. I am working on the Linux platform. Any help in this regard
    > would be highly appreciated.
    > Thankyou.
    > Masud.


    Hi, that depends on where you reside, and where the program will be
    used. If you live or work in Canada, France, Italy, Germany, the
    United Kingdom, or Japan, GIF files are still patented so it is
    illegal to read or write them without permission from Unisys. If you
    are in the USA, the patent expired 20 June 2003. (
    http://burnallgifs.org/ ) The rest is a simple matter of coding :)

    This has brought new meaning to "illegal expressions" within C++... At
    least the ^ (xor) operator is still legal despite some people's
    efforts.
     
    Carl Muller, Jul 31, 2003
    #4
    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. hb
    Replies:
    6
    Views:
    9,165
  2. Vincent Vollers
    Replies:
    0
    Views:
    560
    Vincent Vollers
    May 22, 2005
  3. Beauregard T. Shagnasty

    Re: filename.gif or filename.gif.jpg?

    Beauregard T. Shagnasty, May 30, 2008, in forum: HTML
    Replies:
    1
    Views:
    777
    Jonathan N. Little
    May 30, 2008
  4. Bergamot
    Replies:
    0
    Views:
    466
    Bergamot
    May 30, 2008
  5. Replies:
    3
    Views:
    184
    Bob Barrows [MVP]
    Jan 25, 2006
Loading...

Share This Page