Reading and Writing GIF files

M

masud

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.
 
A

Allan Bruce

masud said:
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 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
 
C

Chris Theis

masud said:
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
 
C

Carl Muller

masud said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top