Can skiko/skija be used to scale an image? (Not dr...
# compose-desktop
d
Can skiko/skija be used to scale an image? (Not drawing it but creating another image of a different size)
t
In therory it can but the api is not exposed but you can do it in this way:
Copy code
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
Thanks!
s
I created an issue asking for exposing the FilterQuality setting. https://github.com/JetBrains/skiko/issues/834 Is there any other way to do it as a workaround?
1
plus1 1