coil icon indicating copy to clipboard operation
coil copied to clipboard

ContentScale.FillBounds does not work with GIFs

Open Citrussss opened this issue 3 years ago • 4 comments

Describe the bug 当我在Compose中使用Gif加载图片时,Image属性设置的Scale.FillBounds(拉伸),如果使用 ImageDecoderDecoder 来加载Gif,图片不能正常缩放,预期效果应该是拉伸,使用GifDecoder就可以正常工作。 When I use GIF to load pictures in compose, the image attribute is set to scale. Fillbound (like FitXY). If I use imagedecoder to load GIF, the picture cannot be showing normally. The expected effect should be stretching. Using gifdecoder can work normally.

Expected behavior The expected effect should be stretching.

To Reproduce class DefaultImageLoaderFactory(val context: Context) : ImageLoaderFactory { private val sourceLoader = Coil.imageLoader(context) override fun newImageLoader(): ImageLoader { return sourceLoader.newBuilder() .componentRegistry { if (Build.VERSION.SDK_INT >= 28) { add(ImageDecoderDecoder(context)) } else { add(GifDecoder()) } } .build() } }

Coil.setImageLoader(DefaultImageLoaderFactory(context))

Image( modifier = Modifier.fillMaxSize(), painter = rememberImagePainter( data = ads.resourceUrl, builder = { placeholder(R.drawable.placeholder) }, ), contentDescription = null, contentScale = ContentScale.FillBounds ) Logs/Screenshots if need ,tell me.

Version What library version are you using? Does this occur on a specific API level or Android device? implementation("io.coil-kt:coil-gif:1.3.2")

Citrussss avatar Aug 23 '21 10:08 Citrussss

ContentScale.FillBounds still doesn't work with 2.2.2

Should look like this: But it looks like this:
image image

Original: giphy

valeriyo avatar Oct 12 '22 19:10 valeriyo

Can you please provide any alternative solution? Ref to this issue: https://github.com/coil-kt/coil/issues/1844

jimmytrivediuser avatar Aug 16 '23 07:08 jimmytrivediuser

@jimmytrivediuser You may be able to work around this by only using GifDecoder.Factory() and not ImageDecoderDecoder.Factory(). Alternatively you could submit a fix to ImageDecoderDecoder and resolve the issue.

colinrtwhite avatar Aug 16 '23 19:08 colinrtwhite

@jimmytrivediuser You may be able to work around this by only using GifDecoder.Factory() and not ImageDecoderDecoder.Factory(). Alternatively you could submit a fix to ImageDecoderDecoder and resolve the issue.

Using gifdecoder cannot work correctly.

xing634325131 avatar Oct 08 '23 07:10 xing634325131