Sign in to follow this  
Evil Steve

GIF decoding

Recommended Posts

Evil Steve    2017
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Michalson    1657
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.

Share this post


Link to post
Share on other sites
Evil Steve    2017
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Evil Steve    2017
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)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
chollida1    532
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

Share this post


Link to post
Share on other sites
Evil Steve    2017
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])

Share this post


Link to post
Share on other sites
ChaosEngine    5185
Quote:
Original post by Evil Steve
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])


I used GDI+ a few projects back. From what I remember, it was really easy to use, and the MSDN references on it were pretty good. If you know GDI at all you should have no trouble.

(sorry I know that's what you want, but basically here should be enough to get you going.

Share this post


Link to post
Share on other sites
Evil Steve    2017
Wow... GDI+ rocks... I just got it all working perfectly, with a total of 47 lines of code, including error handling.

Thanks for all the replies guys.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this