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

There is a newer version: 1.9.0
Show newest version
package com.seiko.imageloader.component.decoder

import com.seiko.imageloader.request.Options
import com.seiko.imageloader.request.SourceResult
import okio.BufferedSource
import org.jetbrains.skia.Bitmap
import org.jetbrains.skia.Image

class SkiaImageDecoder(
    private val channel: BufferedSource,
) : Decoder {

    // add this if jvm ./gradlew failed
    // @Suppress("TYPE_MISMATCH")
    override suspend fun decode(): DecoderResult {
        val image = Image.makeFromEncoded(channel.readByteArray())
        return DecodeImageResult(
            image = Bitmap.makeFromImage(image),
        )
    }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy