iPhone developer: decoding an animated GIF image in Obj-C
iPhone  maandag, 13 april 2009 19:09
...of misschien: UIImage-NSData?
ImageThe iPhone OS cannot and will not display animated GIF images properly. The UIImage object cannot be used for this.

Even though it supports GIF images, any animation will be discarded and only the first frame will be shown.

So, if you need to display an animated GIF inside an iPhone app, you're screwed. Code needs to be written.

I've been looking on the web to find some example code on how to display and animate GIF images on the iPhone, but to no avail.

I only found this PHP example which uses this PHP GIF decoder class from L?°szl?? Zsidi.

Crudely and quick-and-dirtily, I have converted that very PHP code to Obj-C so you can now decode the frames from animated GIF images in an iPhone app.

After decoding, you end up with an NSArray of NSData objects containing each frame of the animated GIF image. Another NSArray of NSNumbers contains the time delay for each frame.

Now you are on your own to save the frames to *.gif files and then animating them using an NSTimer or whatever pleases you.

Please enjoy my rubbish code and optimize and improve at will.

Download code and example (.zip 3kb)

Dit artikel is meer dan een jaar oud en daarom gearchiveerd.
- Reacties op dit artikel worden niet meer getoond.

Zoeken
 
In / uitloggen
Gebruiker

Wachtwoord
Onthoud
Wachtwoord kwijt
Registreer gratis
 
Laatste reacties
Pliep
De wet zegt dat het niet VEREIST is om US sta...
the_one
Als Obama-fan moet ik eerlijk toegeven dat je...
jeelhaus
Lees toevallig net dat de wet niet voor US st...
jeelhaus
Scherp gezien. De timing van de verlosser Oba...
Astolkers
Goed dat je ondanks de ontevredenheid wel kan...
Sjon Hompiestompie
Gast, Petje Lulmaarraak is kapot moeilijk.
Deskman
Duidelijk dus: Apple én T-Mobile werken samen...
Billy
Ze zijn niet allemaal zo. Op appleweetjes had...
hsl
één nadeel,.. als de ontvanger geen 3G of wif...
sandman
Ik word daar ook een beetje moe van. Samsung ...
 
Pliep leest
RSS Feed
© 2006-2008 P-Edge media | Martin van Spanje