onevcat / Kingfisher

A lightweight, pure-Swift library for downloading and caching images from the web.
MIT License
23.01k stars 2.64k forks source link

Can't play GIF with .backgroundDecode option #880

Open KimiChiu opened 6 years ago

KimiChiu commented 6 years ago

Here's how I use it.

previewImage.clipsToBounds = true
previewImage.kf.indicatorType = .custom(indicator: indicator)
previewImage.kf.setImage(with: url, options: [.transition(.fade(0.2)), .backgroundDecode], progressBlock: {
    receivedSize, totalSize in

    // from cache
    if totalSize < 0 {
        indicator.level = 10000.0
    }
    else{
        indicator.level = CGFloat( (Float(receivedSize) / Float(totalSize)) * 10000.0 )
    }
})

The GIF is played well without .backgroundDecode.

JacobMao commented 6 years ago

@KimiChiu

There is AnimatedImageView that can play gif, can you use it?

KimiChiu commented 6 years ago

I tried, it worked the same as UIImage. Both of them need to remove .backgroundDecode.

jzau commented 6 years ago

@KimiChiu

From my understanding, backgroundDecode doesn't support gif for now, please see https://github.com/onevcat/Kingfisher/issues/625

recherst commented 6 years ago

@KimiChiu so at least, how did you resolve this problem, i have faced some issue with you.

xspyhack commented 5 years ago

Normally I thinks we don't need to decode GIF with .backgroundDecode option when you use AnimatedImageView to display. AnimatedImageView will preload and resize(if needsPrescaling is true, default is true) frame in a serial queue, it will decode the frame into bitmap indirectly while resizing.