skiaMain.com.seiko.imageloader.component.decoder.SkiaImageDecoder.kt Maven / Gradle / Ivy
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