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
}