Commit 7ecbbb6 1 parent ea167b1 commit 7ecbbb6 Copy full SHA for 7ecbbb6
File tree 1 file changed +24
-1
lines changed
app/src/main/java/app/grapheneos/camera/ktx
1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -7,19 +7,42 @@ import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
7
7
8
8
fun SubsamplingScaleImageView.fixOrientationForImage (imageUri : Uri ) {
9
9
val exifOrientation = getImageOrientationFromUri(context, imageUri)
10
- orientation = SubsamplingScaleImageView .ORIENTATION_USE_EXIF
11
10
when (exifOrientation) {
12
11
ExifInterface .ORIENTATION_FLIP_HORIZONTAL -> {
13
12
scaleX = - 1f
13
+ orientation = SubsamplingScaleImageView .ORIENTATION_0
14
14
}
15
+
15
16
ExifInterface .ORIENTATION_FLIP_VERTICAL -> {
16
17
scaleY = - 1f
18
+ orientation = SubsamplingScaleImageView .ORIENTATION_0
17
19
}
20
+
18
21
ExifInterface .ORIENTATION_TRANSVERSE -> {
19
22
scaleX = - 1f
23
+ orientation = SubsamplingScaleImageView .ORIENTATION_270
20
24
}
25
+
21
26
ExifInterface .ORIENTATION_TRANSPOSE -> {
22
27
scaleX = - 1f
28
+ orientation = SubsamplingScaleImageView .ORIENTATION_90
29
+ }
30
+
31
+ ExifInterface .ORIENTATION_ROTATE_90 -> {
32
+ orientation = SubsamplingScaleImageView .ORIENTATION_90
23
33
}
34
+
35
+ ExifInterface .ORIENTATION_ROTATE_180 -> {
36
+ orientation = SubsamplingScaleImageView .ORIENTATION_180
37
+ }
38
+
39
+ ExifInterface .ORIENTATION_ROTATE_270 -> {
40
+ orientation = SubsamplingScaleImageView .ORIENTATION_270
41
+ }
42
+
43
+ // ExifInterface.ORIENTATION_NORMAL and ExifInterface.ORIENTATION_UNDEFINED
44
+ // don't need any handling as the image would be as expected (or the orientation
45
+ // would be unknown which is unlikely since all the images displayed in our in-app
46
+ // gallery are generated by our camera app)
24
47
}
25
48
}
You can’t perform that action at this time.
0 commit comments