Android Question CameraEx: it saves picture rotated 90o CCW

achtrade

Active Member
Licensed User
Longtime User
in the preview the image is ok but when it saved it's rotated 90o CCW.

How to fix it ?

thanks.

B4X:
Private Sub InitializeCamera
    camEx.Initialize(Panel1, frontCamera, Me, "Camera1")
    frontCamera = camEx.Front
End Sub

Sub Camera1_Ready (Success As Boolean)
    Dim lSizes() As CameraSize
    Dim iMean As Int
    If Success Then
        camEx.SetJpegQuality(90)
        camEx.SetContinuousAutoFocus
        lSizes = camEx.GetSupportedPicturesSizes
        iMean = Floor(lSizes.Length / 2)
        camEx.SetPictureSize(lSizes(iMean).Width, lSizes(iMean).Height)
        camEx.CommitParameters
        camEx.StartPreview
        Log(camEx.GetPreviewSize)
    Else
        ToastMessageShow("Cannot open camera.", True)
    End If
End Sub


Sub Camera1_PictureTaken (Data() As Byte)
    Private filename As String = "file.jpg"
   
    Dim dir As String = File.DirRootExternal
   
    camEx.SavePictureToFile(Data, dir, filename)
    camEx.StartPreview 'restart preview


Dim Phone As Phone
    Dim i As Intent
    i.Initialize("android.intent.action.MEDIA_SCANNER_SCAN_FILE", _
        "file://" & File.Combine(dir, filename))
    Phone.SendBroadcastIntent(i)
    ToastMessageShow("Picture saved." & CRLF  & "File name: " & filename, True)
end sub
 
Top