ImageDecoder

actual object ImageDecoder
expect object ImageDecoder

Platform-supplied image decoder. KitePDF's core stays pure-Kotlin-stdlib; actual JPEG / PNG / etc. decoding rides on whatever the host platform already provides — Skia on Desktop, the OS framework on Android / iOS, createImageBitmap on JS.

The actual implementations live in :kitepdf-compose's platform source sets. If a platform can't decode the bytes (corrupt JPEG, unsupported format), the actual returns null and the renderer paints a placeholder rectangle.

actual object ImageDecoder
actual object ImageDecoder
actual object ImageDecoder
actual object ImageDecoder
actual object ImageDecoder

Functions

Link copied to clipboard
actual fun decode(bytes: ByteArray): ImageBitmap?
expect fun decode(bytes: ByteArray): ImageBitmap?
actual fun decode(bytes: ByteArray): ImageBitmap?
actual fun decode(bytes: ByteArray): ImageBitmap?

Compose/JS rides on Skiko (CanvasKit), which bundles Skia's image codecs — so decoding is synchronous here too, no createImageBitmap Promise dance. Falls back to null (→ placeholder rectangle) if Skia can't parse the bytes.

actual fun decode(bytes: ByteArray): ImageBitmap?
actual fun decode(bytes: ByteArray): ImageBitmap?
actual fun decode(bytes: ByteArray): ImageBitmap?
Link copied to clipboard
actual fun decodeRaw(rgba: ByteArray, width: Int, height: Int): ImageBitmap?
expect fun decodeRaw(rgba: ByteArray, width: Int, height: Int): ImageBitmap?

Build a bitmap from already-decoded RGBA8888 pixels (R,G,B,A per pixel, row-major, width*height*4 bytes). Unlike decode this is fully synchronous on every platform — the samples are already in hand — so it works on JS too. Used for RAW (FlateDecode) PDF images.

actual fun decodeRaw(rgba: ByteArray, width: Int, height: Int): ImageBitmap?
actual fun decodeRaw(rgba: ByteArray, width: Int, height: Int): ImageBitmap?

Raw pixels are synchronous, so Skiko (which Compose/JS rides on) can build the bitmap directly.

actual fun decodeRaw(rgba: ByteArray, width: Int, height: Int): ImageBitmap?
actual fun decodeRaw(rgba: ByteArray, width: Int, height: Int): ImageBitmap?
actual fun decodeRaw(rgba: ByteArray, width: Int, height: Int): ImageBitmap?