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

Reading and Writing GIF files

P: n/a

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
Jul 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

"masud" <me*********@dbforums.com> wrote in message
news:31****************@dbforums.com...

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
Jul 19 '05 #2

P: n/a

"masud" <me*********@dbforums.com> wrote in message
news:31****************@dbforums.com...

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
Jul 19 '05 #3

P: n/a
masud <me*********@dbforums.com> wrote in message news:<31****************@dbforums.com>...
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.
Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.