Android Question CameraEx stretching preview

yiankos1

Well-Known Member
Licensed User
Longtime User
Hello my friends,
I use my front camera at my app using CameraEx class, but as i see at some devices camera preview stretches (i think camera preview vertically). As i read here, there are many developer have same problem as me. They use
getOptimalPreviewSize, in order to get ratio and use the optimal preview size. Any idea to use that code at b4a or in-line java?
Thank you for your time.
 
Last edited:

strat

Active Member
Licensed User
Longtime User
This code is in my program. I use CameraExClass too and there is SetpreviewSize Sub in my CameraExClass.

B4X:
Sub Camera1_Ready (Success As Boolean)

    Dim previewSizes() As CameraSize = camEx.GetSupportedPreviewSizes
    Dim current As CameraSize = camEx.GetPreviewSize
    For i = 0 To previewSizes.Length - 1
        If previewSizes(i).Width = current.Width And previewSizes(i).Height = current.Height Then Exit
    Next
    Dim ps As CameraSize = previewSizes((i + 1) Mod previewSizes.Length)
    camEx.SetpreviewSize(ps.Width, ps.Height)
    camEx.CommitParameters       
    If Success Then
        camEx.JpegQuality=90
        camEx.CommitParameters
        camEx.StartPreview
        FocusSupported = False
        If api >= 14 Then
            If camEx.GetMaxNumFocusAreas <> 0 Then FocusSupported = True
        End If
    Else
        ToastMessageShow("Cannot open camera.", True)
    End If
   
End Sub
 
Upvote 0

Urishev

Member
Licensed User
Longtime User
Such components (GetSupportedPreviewSizes, GetPreviewSize, SetpreviewSize) do not exist in my CameraExClass.
Can I use the old CameraExClass? Old library Camera v2.20?
 
Upvote 0

strat

Active Member
Licensed User
Longtime User
Such components (GetSupportedPreviewSizes, GetPreviewSize, SetpreviewSize) do not exist in my CameraExClass.
Can I use the old CameraExClass? Old library Camera v2.20?

Erel can say the best answer but I think you can use old library without preview settings.

Below commands may not work when you set parameters (w,h) wrong numbers, so you have to get dimension to use camEx.GetPreviewSize or camEx.GetPictureSize.
camEx.SetPictureSize(w,h)
camEx.SetPreviewSize(w,h)
 
Upvote 0

Urishev

Member
Licensed User
Longtime User
Thanks for the help. I understand. I use an old CameraExClass.
Can you download me your CameraExClass.bas
 
Upvote 0

Urishev

Member
Licensed User
Longtime User
Well, will observe the rules of etiquette. Thanks for the tip.
Found in forum and downloaded the new CameraExClass.
But a new problem arose. My application does not work with the new CameraExClass. Directs "www.b4x.com for updates".
 
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
Well, will observe the rules of etiquette.
For me, it's not a quetion of etiquette, but it's a question to find first by yourself a solution in the forum, and then, if you didn't find a solution, post a question.
 
Upvote 0
Top