KiteImageDecoder

class KiteImageDecoder(source: ImageSource, options: Options, maxCacheableAnimationBytes: Long = Factory.DEFAULT_MAX_CACHEABLE_ANIMATION_BYTES) : Decoder

A coil3.decode.Decoder backed by KiteImage's pure-Kotlin codecs.

Register the Factory on your ImageLoader and Coil keeps doing everything it is good at (network fetch, disk + memory cache, request lifecycle) while decoding runs through KiteImage with identical behavior on every target:

ImageLoader.Builder(context)
.components { add(KiteImageDecoder.Factory()) }
.build()

The factory decides by asking KiteImage.probe whether this build can decode the bytes, so it claims exactly what the codecs handle (PNG and APNG, JPEG, GIF, BMP, lossless and animated WebP, TIFF, JP2) and declines the rest (SVG, CgBI PNGs, lossy WebP, lossless/arithmetic JPEGs). Coil's platform decoders keep everything it turns down, so nothing regresses versus a stock setup.

Static results honor the request's target size (box-filter downscale, never up) and memory-cache normally. Animated results come back as KiteAnimationImage with every frame downscaled to the target size: that is where animated memory goes: and are marked shareable (memory-cacheable) when their pixel bytes fit under Factory.maxCacheableAnimationBytes. A cancelled request (fast scroll) aborts a multi-frame decode at the next frame boundary instead of finishing the whole file.

Constructors

Link copied to clipboard
constructor(source: ImageSource, options: Options, maxCacheableAnimationBytes: Long = Factory.DEFAULT_MAX_CACHEABLE_ANIMATION_BYTES)

Types

Link copied to clipboard
class Factory(maxCacheableAnimationBytes: Long = DEFAULT_MAX_CACHEABLE_ANIMATION_BYTES) : Decoder.Factory

maxCacheableAnimationBytes: animations whose decoded pixel bytes (frames × width × height × 4) fit under this threshold are marked shareable, so Coil's memory cache keeps them and revisits skip the re-decode entirely. Animations above it stay unshareable (decode again from the disk cache on revisit) so a single huge GIF cannot evict everything else. 0 restores the old always-skip behavior; Long.MAX_VALUE caches unconditionally.

Functions

Link copied to clipboard
open suspend override fun decode(): DecodeResult