Android Question Funny behaivor with fotos from contenchooser

TrisectDevelopment

Active Member
Licensed User
Longtime User
In my App I can choose an image from the content chooser and put the image in my ImagevIew.

When the foto app is open all images is correct rotated. The images I took myself and the ones who came with the phone.

If I choose one of the images who came with the phone it is shown correct in my ImageView.
But if I choose the one I took my self it is rotated in my ImageView, like 90 degres.

Is there any way to fix this?
Is there a way to check if it is a image I took myself?
 

thedesolatesoul

Expert
Licensed User
Longtime User
Upvote 0

TrisectDevelopment

Active Member
Licensed User
Longtime User
I found another solution.

I copy the image from the ContentChooser_Result FileName to a temp image.
The I use the exif.getAttribute(exif.TAG_ORIENTATION) to check if the temp image is rotated.
If it is rotated then I put the ContentChooser_Result FileName into my ImageView, but rotating it first with RSImageProcessing.

B4X:
Dim rbmp AsRSImageProcessing
Dim finalBitmap AsBitmap
Try
If Success Then
  File.Copy(Dir ,FileName, File.DirRootExternal ,"tempFile.jpg")
  '** Initialize exif
  exif.Initialize(File.DirRootExternal ,"tempFile.jpg")
  Dim temp AsString
  temp = exif.getAttribute(exif.TAG_ORIENTATION)
  '** Image is rotated
  If temp = "6"Then
    rbmp.Initialize
    finalBitmap = LoadBitmap(Dir, FileName)
    finalBitmap = rbmp.rotateBitmap(finalBitmap, 90)
    ivBillede.Bitmap = finalBitmap
  Else
    finalBitmap = LoadBitmap(Dir, FileName)
    ivBillede.Bitmap = finalBitmap
  EndIf
  '** Slet temp billede fil
  File.Delete(File.DirRootExternal ,"tempFile.jpg")
EndIf
Catch
  Dim errorMessage AsString
  errorMessage = LastException.Message
  Msgbox(errorMessage, "ERROR!")
EndTry
 
Upvote 0
Top