saket / telephoto

Building blocks for designing media experiences in Compose UI
https://saket.github.io/telephoto/
Apache License 2.0
978 stars 32 forks source link

Gif Not Working #83

Closed kmnaseef closed 6 months ago

kmnaseef commented 6 months ago

thallu-nuna

Coil AsyncImage() can display this image, but ZoomableAsyncImage() cannot. please check. ImageDecoderDecoder.Factory() component added in both cases.

saket commented 6 months ago

I'm sorry, but I can't help you investigate the problem without any code. Can you share a reproducer? A branch with telephoto's sample app would be the best.

kmnaseef commented 6 months ago

My Application.zip Screenshot 2024-04-23 135147

issue: ZoomableAsyncImage cannot display an image that can do with Coil AsyncImage.

what I did:

  1. Created a new project
  2. added dependancy implementation("me.saket.telephoto:zoomable-image-coil:0.10.0")
  3. added an image into assets folder
  4. added a zoomableAsyncImage(green border in picture) and an asyncImage into compose(red border)
  5. .Run

Note: NOT added implementation("io.coil-kt:coil-gif:2.5.0"). there is no difference if added. AsyncImage displaying even this not added

saket commented 6 months ago

This is very interesting. thallu.gif is a single-frame GIF. telephoto is failing to display it because,

  1. Your project isn't using Coil's GIF decoder. If you use GifDecoder, the image will be shown correctly.

  2. If you use ImageDecoderDecoder, which coil suggests using on API 28+, Android will read the GIF as a bitmap instead of an animated drawable because there is no animation needed for a single frame. This is confusing for telephoto because it tries to sub-sample this bitmap and fails when BitmapRegionDecoder refuses to decode a GIF.

I'm thinking I'll have to solve this by manually checking if an image is a GIF here: https://github.com/saket/telephoto/blob/3bf32591a79caf6ce08f2c9cd00357776003066c/zoomable-image/coil/src/main/kotlin/me/saket/telephoto/zoomable/coil/subSamplingEligibility.kt#L22

saket commented 6 months ago

Please do! I'll make a release soon, but you can use 0.11.0-SNAPSHOT in the meantime.

kmnaseef commented 6 months ago

Yea, Its Working.. Thank you.