Skip to content

Commit 710e7d3

Browse files
committed
avoid rotating images by 0 degrees
1 parent 1c60320 commit 710e7d3

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

app/src/main/kotlin/com/simplemobiletools/camera/PhotoProcessor.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class PhotoProcessor(val activity: MainActivity, val uri: Uri?, val currCameraId
7575
else -> 0
7676
}
7777

78-
image = rotate(image, imageRot + deviceRot + previewRot) ?: return ""
78+
image = rotate(image, (imageRot + deviceRot + previewRot) % 360) ?: return ""
7979
image.compress(Bitmap.CompressFormat.JPEG, 80, fos)
8080
fos?.close()
8181
return photoFile.absolutePath
@@ -93,11 +93,14 @@ class PhotoProcessor(val activity: MainActivity, val uri: Uri?, val currCameraId
9393
}
9494

9595
private fun rotate(bitmap: Bitmap, degree: Int): Bitmap? {
96+
if (degree == 0)
97+
return bitmap
98+
9699
val width = bitmap.width
97100
val height = bitmap.height
98101

99102
val matrix = Matrix()
100-
matrix.setRotate((degree % 360).toFloat())
103+
matrix.setRotate(degree.toFloat())
101104
try {
102105
return Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true)
103106
} catch (e: OutOfMemoryError) {

0 commit comments

Comments
 (0)