Android Question CameraExClass Saved Image orientation different then Preview image

incendio

Well-Known Member
Licensed User
Longtime User
Hi guys,

I have a problem with image orientation taking with CameraEx Class.

Here are the problems :
1) on camera preview, image orientation is portrait
2) when picture taken and save to file with these codes
B4X:
Sub Camera_PictureTaken (Data() As Byte)
    Private filename As String = "1.jpg"
    camEx.SavePictureToFile(Data, File.DirRootExternal, filename)
End Sub
when saved picture load into ImageView, orientation changed to landscape.

For preview only in ImageView, I manage to rotate the image using codes from :
https://www.b4x.com/android/forum/t...ibrary-functionality.23801/page-4#post-151317, post 79.

But that codes works for preview only, actual image still in landscape mode.
I have to save again to file in order to made actual image in portrait mode with these :
B4X:
Sub DisplayImg(Data() As Byte)
    Private Bmp As Bitmap  
    Private Out As OutputStream
    Bmp = LoadbitmapSample2(File.DirRootExternal,"1.jpg",imgVw.Width,imgVw.Height,True)  
    imgVw.Bitmap = Bmp  
    Out = File.OpenOutput(File.DirRootExternal,"1.jpg",False)
    Bmp.WriteToStream(Out,100,"JPEG")
End Sub

Is that possible to set image orientation same with preview camera mode (portrait/landscape) without needed to save it first to file?
 
Top