GIF decoding

Started by
10 comments, last by Evil Steve 19 years ago
Hey all, I'm making a program that supports downloadable avatars (think MSN), and it's all working fine now. The only thing is, I'm using D3DX to load images, and D3DX doesn't cope with GIF files. So, I thought about writing my own GIF decoder. The patent has expired, so I shouldn't need to pay to write a decoder. I only intend to support non-animated GIFs (Although animated ones would be neat if it's not a lot more work). Does anyone know of any resources for this, or even better, a pre-made decoder that I can drop into my application? I need a memory buffer as an input (BYTE* and length), and an array of 32-bit values, width and height as an output. I'm having a look through the format specifications on wotsit.org just now. Cheers, Steve
Advertisement
Im pretty sure that the source for ThumbView includes Beermap that's completly free very lightweight and modular image loading library. And it does support gif files amongst many others.
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats
Do you want to decode static gifs or static and animated gifs? The first is pretty easy, and there are lots of libraries to do it. However animated gifs are pure torture to decode, the only viable libraries I've seen are those that also want to playback the gif too using their own display (that is to say I haven't found a good library that just gives the frames and delays). Writing your own is very, very tricky, as animated gifs vary wildly (due to various extension tags). I learned this the hardway trying to make my own animated gif->collection of DirectDraw surfaces implimentation.
Don't suppose you have a link to Beerpack? Googling for "beerpack" doesn't turn anything up, and "beer image library" has pleanty of stuff on booze [smile]
Also, the ThumbView page doesn't mention GIF as a supported format with beerpack. Are you sure it supports GIF?

Thanks for the reply
Weird! seems like he's not using the newest "release" if you could call it that. There's no official site for it yet that's why I was kinda hoping it would be availble through that CVS.

If you give me a better specification on what you need for output I can take a glance over the code and see how hard it would be to accomodate it.

Sounds like it should be something like 3-4lines to get it up and running just loading the gif and converting it to a raw 16/24/32 bpp datastream.
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats
GDI+ will support both GIFs and Animated GIF's we use it to load and access the bits inside both.

Cheers
Chris
CheersChris
Quote:Original post by DigitalDelusion
Weird! seems like he's not using the newest "release" if you could call it that. There's no official site for it yet that's why I was kinda hoping it would be availble through that CVS.

If you give me a better specification on what you need for output I can take a glance over the code and see how hard it would be to accomodate it.

Sounds like it should be something like 3-4lines to get it up and running just loading the gif and converting it to a raw 16/24/32 bpp datastream.
Well, I've got D3DX outputting a 32-bit XRGB image, so something similar would be good.
I'm currently reading the DevIL source, but it's a bit of a pain, since I've never used it normally.
Any chance you could PM me a link to the source or something?

Michalson: Well, if there's going to be much more hastle (I.e. more than a few lines of code extra), then I'll just go for static gifs. Is it possible to read the first frame of an animated GIF without much extra work?

chollida1: GDI+ is C# only, isn't it? I'm using C++ (I should have said), and I'd like to support Win9x if possible (if it makes a difference)
the GDI+ route is probably a better alternative since it seems to support animated gif's to. Beermap currently only supports static gif's and that's not likely to change unless I need animated support myself :p also documentation wise it's not the strongest library in the world (read doc's are quite non-existant even though it's really easy to use).

Although making it decode from a memory stream (or anything that supports reading bytes in a streamy fashion) is a no-brainer.
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats
Quote:Original post by Evil Steve
Quote:Original post by DigitalDelusion
Weird! seems like he's not using the newest "release" if you could call it that. There's no official site for it yet that's why I was kinda hoping it would be availble through that CVS.

If you give me a better specification on what you need for output I can take a glance over the code and see how hard it would be to accomodate it.

Sounds like it should be something like 3-4lines to get it up and running just loading the gif and converting it to a raw 16/24/32 bpp datastream.
Well, I've got D3DX outputting a 32-bit XRGB image, so something similar would be good.
I'm currently reading the DevIL source, but it's a bit of a pain, since I've never used it normally.
Any chance you could PM me a link to the source or something?

Michalson: Well, if there's going to be much more hastle (I.e. more than a few lines of code extra), then I'll just go for static gifs. Is it possible to read the first frame of an animated GIF without much extra work?

chollida1: GDI+ is C# only, isn't it? I'm using C++ (I should have said), and I'd like to support Win9x if possible (if it makes a difference)


GDI+ is most definitely offered in a C++ variety, we use it for our App and we're a legacy C++ app, nothing managed here:).

Its really easy to use and offers great image quality, the performace does leave a little to be desired however:)

Cheers
Chris
CheersChris
Quote:Original post by chollida1
GDI+ is most definitely offered in a C++ variety, we use it for our App and we're a legacy C++ app, nothing managed here:).

Its really easy to use and offers great image quality, the performace does leave a little to be desired however:)
Well, performance really isn't an issue. I do the downloading and loading in a seperate thread, and the image only gets loaded once.
Do you (or anyone) have any links or tutorials on loading images with GDI+? I know absolutely nothing about it (as you may have guessed [smile])

This topic is closed to new replies.

Advertisement