Private exif As ExifData 'from JpegUtils lib
.
.
.
'result arrives here
Sub ion_Event (MethodName As String, Args() As Object) As Object
If Args(0) = -1 Then
Try
Dim in As Intent = Args(1)
If File.Exists(imageFolder, PhotoFileName) Then
Photo = LoadBitmap(imageFolder, PhotoFileName)
exif.Initialize(imageFolder, PhotoFileName)
Log("exif.TAG_ORIENTATION=" & exif.getAttribute(exif.TAG_ORIENTATION)) '1 = portrait, always under Android 4.2; Android7: 6 - portrait, 1 - left-landscape, 3 - right landscape
Dim test As String = exif.getAttribute(exif.TAG_ORIENTATION)
If test <> "" Then
Dim Orientation As Int = test 'GetOrientation
If Photo.Width > Photo.Height And Orientation = 1 Then
'landscape to left - no need to rotate
else if Photo.Width > Photo.Height And Orientation = 6 Then
Photo = RotateBitmap90(Photo, 90) 'Android7: 6 - portrait
Log("RotateBitmap90")
else if Photo.Width > Photo.Height And Orientation = 3 Then
Photo = RotateBitmap90(Photo, 180) 'landscape to right
Log("RotateBitmap180")
End If
End If
Else If in.HasExtra("data") Then 'try to get thumbnail instead
Dim jo As JavaObject = in
Photo = jo.RunMethodJO("getExtras", Null).RunMethod("get", Array("data"))
End If
Catch
Log(LastException)
End Try
End If
If Photo.IsInitialized Then
Activity.SetBackgroundImage(Photo)
Else
ToastMessageShow("Wrong photo", False)
End If
ProgressDialogHide
Return Null
End Sub