Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to change rotation image view? #53

Open
jackyhieu1211-hn opened this issue May 12, 2020 · 1 comment
Open

How to change rotation image view? #53

jackyhieu1211-hn opened this issue May 12, 2020 · 1 comment

Comments

@jackyhieu1211-hn
Copy link

Hello admin
How to change rotation image view?
Thanks

@jackyhieu1211-hn
Copy link
Author

jackyhieu1211-hn commented May 12, 2020

Hello. Because the library does not support rotation. But if you want to rotate the image. You can do the following

I use kotlin

`

private var currentAngle = 0.0f
private fun rotateByAngle() {
    if (currentAngle == -270f) {
        currentAngle = 0f
    } else {
        currentAngle += -90f
    }
    val viewState = cropViewImage.saveState()
    cropViewImage.restoreState(viewState)
    val bitmap = cropViewImage.viewBitmap.rotate(-90f)
    cropViewImage.setImageBitmap(bitmap)
}

`

fun Bitmap.rotate(degrees: Float): Bitmap {
    val matrix = Matrix().apply { postRotate(degrees) }
    return Bitmap.createBitmap(this, 0, 0, width, height, matrix, true)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant