From 58cb8de3ff68924d34251d1d4b02f0347f7d651f Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 9 Jan 2024 08:49:20 +0100 Subject: [PATCH] Handle `ExifInterface.ORIENTATION_TRANSPOSE` and `ExifInterface.ORIENTATION_TRANSVERSE` --- .../eu/steffo/twom/create/ImageHandler.kt | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/steffo/twom/create/ImageHandler.kt b/app/src/main/java/eu/steffo/twom/create/ImageHandler.kt index 585b4fa..a3fb606 100644 --- a/app/src/main/java/eu/steffo/twom/create/ImageHandler.kt +++ b/app/src/main/java/eu/steffo/twom/create/ImageHandler.kt @@ -51,7 +51,6 @@ class ImageHandler { // Create a transformation matrix to rotate the bitmap based on the orientation val transformationMatrix = Matrix() - // TODO: Make sure all these transformations are valid when (orientation) { ExifInterface.ORIENTATION_FLIP_HORIZONTAL -> { transformationMatrix.postScale(-1f, 1f) @@ -66,7 +65,14 @@ class ImageHandler { } ExifInterface.ORIENTATION_TRANSPOSE -> { - /* TODO: Transpose the image Matrix */ + // Untested. + transformationMatrix.setValues(FloatArray(16) { + if (it == 0 || it == 6 || it == 9 || it == 15) { + 1f + } else { + 0f + } + }) } ExifInterface.ORIENTATION_ROTATE_90 -> { @@ -74,7 +80,14 @@ class ImageHandler { } ExifInterface.ORIENTATION_TRANSVERSE -> { - /* TODO: Flip horizontally the image Matrix, then transpose it */ + // Untested. + transformationMatrix.setValues(FloatArray(16) { + if (it == 3 || it == 5 || it == 10 || it == 12) { + 1f + } else { + 0f + } + }) } ExifInterface.ORIENTATION_ROTATE_270 -> {