Android Code Snippet CameraExClass save picture without rotation

Hello everyone
Anyone use CameraExClass.SavePictureToFile function, the image will be saved rotated horizontally.
I changed this function to save picture as it without rotation, as the following:
B4X:
Public Sub SavePictureToFile(Data() As Byte, Dir As String, FileName As String)
    
    Dim inp As InputStream
    inp.InitializeFromBytesArray(Data,0,Data.Length)
    
    Dim B As Bitmap
    B.Initialize2(inp)
    Dim bm2 As BitmapExtended
    B=bm2.rotateBitmap(B,90)
    
    Dim out As OutputStream=File.OpenOutput(Dir, FileName, False)
    B.WriteToStream(out,100,"PNG")
    out.Close
    
End Sub
It depend on BitmapExtended library.
 

Hamied Abou Hulaikah

Well-Known Member
Licensed User
This code will not work on all phones. You need to check the orientation exif header and rotate it based on that value.

Better to simply save the image and use SMM to load it. It will load with the correct orientation.
I read somewhere here in the forum a post for you that CameraEx saves images rotated horizontally, I am right?
 
Top