Not sure if this is the best way as I don't use B4Xthingy very much but it seems to do what you want.
You need to add the JFX library and XUI library
B4X:
Sub Process_Globals
Dim xu As XUI
Dim fx As JFX
End Sub
Sub AppStart (Args() As String)
Dim bm As B4XBitmap = xu.LoadBitmap("c:/temp" , "hannah.jpg")
bm = bm.Rotate(90)
bm.WriteToStream(File.OpenOutput("c:/temp","hannahRotated90.jpg",False),100,"JPEG")
End Sub
Thanks!
It works to rotate the image, but the EXIF information lost GPS data among other such data! I haven't check all the EXIF values!
The same happens unfortunately with the B4A code!
I guess you need to extract the EXIF Informations from the Source image and add them to the Resultimage. The EXIF Informations get lost when you read the jpeg into an (B4X)Bitmap.
What does BM. Rotate (90) do?
Does BM. Rotate (x) execute only changes to the EXIF values of the orientation and is then updated in the image's EXIF data
or are new x/Y values calculated on the image pixels to rotate the image
or both of those processes?
I use ABMaterial to view the images and ABMaterial does not read the EXIF data for the orientation but only the geometry. This indicates that geomytry data is not changed with the bm.Rotate(x)?
Which is not logical as the EXIF information is lost!
Therefore, it makes no sense for me to change the EXIF data either!
Strange and confusing!
After further investigation, it has been found that if I convert the image to .bmp and rotate it in the photo program (GIMP2) and convert it back to .jpg so finally the image is displayed in the ABMaterial with the correct orientation. If I rotate it again with
then it is not rotated correctly in ABMaterial! However, I see in the icon in the folder and if I open it with foroprogrammet then it is rotated correct.
Bm.Rotate and the photo programs do not do the same rotation-procedure!
Interesting!
Seems impossible to solve the problem of this!