koral-- / android-gif-drawable

Views and Drawable for displaying animated GIFs on Android
Other
9.56k stars 1.78k forks source link

Unsupported still image #830

Closed hgourvest closed 1 year ago

hgourvest commented 1 year ago

this file is not decoded, it's a gif image with a single frame ga840101

hgourvest commented 1 year ago

After investigating, it is an expected behaviour, I would like to know why.

hgourvest commented 1 year ago

I removed the limitation commenting code in seekToFrame jni method and it works as expected. I am missing something ?

koral-- commented 1 year ago

What does "not decoded" mean? Share a reproducer project and describe the desired behavior.

hgourvest commented 1 year ago

I only use GifDecoder class. The bitmap stay black when there is only one frame.

try (final FileInputStream stream = new FileInputStream(cache)) { BufferedInputStream buffStream = new BufferedInputStream(stream); GifDecoder decoder = new GifDecoder(new InputSource.InputStreamSource(buffStream)); int framesCount = decoder.getNumberOfFrames(); if (framesCount > 0) { bmp = Bitmap.createBitmap(decoder.getWidth(), decoder.getHeight(), Bitmap.Config.ARGB_8888); for (int i = 0; i < framesCount; i++) { decoder.seekToFrame(i, bmp); } bmp.recycle(); } }

The problem is here

koral-- commented 1 year ago

Thanks, now I get it. AFAIK that check was one of optimizations for GifDrawable as it naturally always points to some frame and seeking in still images is no-op there. Use case like yours was not anticipated. I'll check that and update the code soon.

hgourvest commented 1 year ago

Thanks