From 18019315e26a99ebbd0bf58b9f5b12cd77718ba4 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 9 Apr 2017 13:13:56 +0200 Subject: [PATCH] make sure the imported bitmap is centered --- app/src/main/kotlin/com/simplemobiletools/draw/MyCanvas.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/draw/MyCanvas.kt b/app/src/main/kotlin/com/simplemobiletools/draw/MyCanvas.kt index c2269dc..4ca4674 100644 --- a/app/src/main/kotlin/com/simplemobiletools/draw/MyCanvas.kt +++ b/app/src/main/kotlin/com/simplemobiletools/draw/MyCanvas.kt @@ -116,7 +116,9 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) { super.onDraw(canvas) if (mBackgroundBitmap != null) { - canvas.drawBitmap(mBackgroundBitmap, 0f, 0f, null) + val left = (width - mBackgroundBitmap!!.width) / 2 + val top = (height - mBackgroundBitmap!!.height) / 2 + canvas.drawBitmap(mBackgroundBitmap, left.toFloat(), top.toFloat(), null) } for ((key, value) in mPaths) {