Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Reading and Writing GIF files

Reply
Thread Tools

Reading and Writing GIF files

 
 
masud
Guest
Posts: n/a
 
      07-30-2003

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
 
Reply With Quote
 
 
 
 
Allan Bruce
Guest
Posts: n/a
 
      07-30-2003

"masud" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> 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


 
Reply With Quote
 
 
 
 
Chris Theis
Guest
Posts: n/a
 
      07-30-2003

"masud" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> 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


 
Reply With Quote
 
Carl Muller
Guest
Posts: n/a
 
      07-31-2003
masud <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> 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.
 
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
Freeware to make animated GIF (can Irfanview make an animated GIF?) Annu Pai Digital Photography 4 11-23-2009 12:52 AM
Re: filename.gif or filename.gif.jpg? Bergamot HTML 0 05-30-2008 02:56 PM
Re: filename.gif or filename.gif.jpg? Beauregard T. Shagnasty HTML 1 05-30-2008 01:23 PM
ASP/PerlScript and reading and writing files roger_owen333@earthlink.net ASP General 3 01-25-2006 08:11 PM
How to convert a base 64 encoded GIF image to a *.gif file? hb ASP .Net 6 09-28-2004 08:24 PM



Advertisments