korlibs-archive / korim

Korim: Kotlin cORoutines IMaging, Bitmap and Vector graphics for Multiplatform Kotlin

Home Page:https://korlibs.soywiz.com/korim/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bitmap.resized

soywiz opened this issue · comments

fun Bitmap.resized(width: Int, height: Int, scale: ScaleMode, anchor: Anchor): Bitmap {
    val bmp = this
    val out = bmp.createWithThisFormat(width, height)
    out.context2d(antialiased = true) {
        val rect = Rectangle(0, 0, width, height).place(bmp.width.toDouble(), bmp.height.toDouble(), anchor, scale)
        drawImage(bmp, rect.x, rect.y, rect.width, rect.height)
    }
    return out
}