Created
March 29, 2019 18:02
-
-
Save traendy/4834b057870f527ab2022cb615265767 to your computer and use it in GitHub Desktop.
Flips or rotates an Image.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun rotateImage(img: Bitmap, degree: Float): Bitmap { | |
val matrix = Matrix() | |
matrix.postRotate(degree) | |
return Bitmap.createBitmap(img, 0, 0, img.width, img.height, matrix, true) | |
} | |
private fun flip(bitmap: Bitmap, horizontal: Boolean): Bitmap { | |
val matrix = Matrix() | |
matrix.preScale((if (horizontal) -1f else 1f), (if (!horizontal) -1f else 1f)) | |
return Bitmap.createBitmap(bitmap, 0, 0, bitmap.width, bitmap.height, matrix, true) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment