Skip to content Skip to sidebar Skip to footer

Canvas Rotate And Drawbitmap

I have path rect and bitmap, want to add bitmap inside path, While draw on start it appears as expected, but while rotate and draw bitmap goes outside bounds. Here is my code. canv

Solution 1:

Here is the working solution with matrix.

bitmap?.let {
    val rotate = Matrix()
    rotate.setRotate(rotateAngle.toFloat(), it.width / 2.0f, it.height / 2.0f)
    rotate.postTranslate((rectF2.centerX() - it.width / 2.0f), (rectF2.centerY() - it.height / 2.0f))
    canvas!!.drawBitmap(it, rotate, mPaint)
}

Post a Comment for "Canvas Rotate And Drawbitmap"