https://kotlinlang.org logo
Title
d

Dominaezzz

12/06/2020, 1:23 AM
Can skiko/skija be used to scale an image? (Not drawing it but creating another image of a different size)
t

Timo Drick

12/06/2020, 12:10 PM
In therory it can but the api is not exposed but you can do it in this way:
fun scaleUsingSurface(image: Image, width: Int, height: Int): Image {
    val surface = Surface.makeRasterN32Premul(width, height)
    val canvas = surface.canvas
    val paint = Paint().apply {
        filterQuality = FilterQuality.HIGH
    }
    canvas.drawImageRect(image, Rect(0f, 0f, width.toFloat(), height.toFloat()), paint)
    return surface.makeImageSnapshot()
}
👍 1
d

Dominaezzz

12/06/2020, 12:34 PM
Thanks!