decodeDownscaledTo

fun decodeDownscaledTo(data: ByteArray, width: Int, height: Int, applyOrientation: Boolean = false, colorTarget: ColorTarget = ColorTarget.Source, cancellationCheck: () -> Unit? = null): KiteBitmap(source)

Decode data at exactly width by height, the size decode(data, applyOrientation).downscaledTo(width, height) gives. The caller chooses the aspect ratio: use it for the size of a centre crop, computed from probe, or for a size a layout has already worked out. It reduces a JPEG, JPEG 2000 or JPEG XR, and a HEIC or AVIF grid, while decoding as decodeScaled does. colorTarget converts as for decode, and cancellationCheck runs as for decode.

Throws

if width or height is not positive or exceeds the side of the image it applies to, after the orientation when applyOrientation is set

on malformed/truncated input or unknown format

on formats recognised but not yet decodable