All Downloads are FREE. Search and download functionalities are using the official Maven repository.

skiaMain.com.seiko.imageloader.component.decoder.SkiaImageDecoder.kt Maven / Gradle / Ivy

package com.seiko.imageloader.component.decoder

import com.seiko.imageloader.option.Options
import okio.BufferedSource
import okio.use
import org.jetbrains.skia.Bitmap
import org.jetbrains.skia.Image

class SkiaImageDecoder private constructor(
    private val source: BufferedSource,
) : Decoder {

    override suspend fun decode(): DecodeResult {
        val image = source.use {
            Image.makeFromEncoded(it.readByteArray())
        }
        return DecodeResult.Bitmap(
            bitmap = Bitmap.makeFromImage(image),
        )
    }

    class Factory : Decoder.Factory {
        override suspend fun create(source: DecodeSource, options: Options): Decoder {
            return SkiaImageDecoder(source.source)
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy