Hi All,
I'm developping a small app based on cameraEx and my intention was to adapt the size of the screen to the resolution of the camera.
It is working fine when using the back camera, but when switching to the front camera I get weird results.
For example on my Galaxy S3, simply launching the app, selecting the front camera then switching back the camera generates the bug;
- the preview seems to keep the size it had with the front camera and this generates a grey band at the bottom of the screen.
I spent a whole afternoon to check everywhere to see what happens when the camera is changed. There is just this:
and in the code of camera1_ready, I just reinitialize all parameters. (Basically the same code is for the button which handles the picture size and this one is working.)
In other words, I am a bit lost... I would be gratefull if somebody could help me to find my bug. (the full project is joined)
Thanks
Alain
I'm developping a small app based on cameraEx and my intention was to adapt the size of the screen to the resolution of the camera.
It is working fine when using the back camera, but when switching to the front camera I get weird results.
For example on my Galaxy S3, simply launching the app, selecting the front camera then switching back the camera generates the bug;
- the preview seems to keep the size it had with the front camera and this generates a grey band at the bottom of the screen.
I spent a whole afternoon to check everywhere to see what happens when the camera is changed. There is just this:
B4X:
camEx.Release
frontCamera = Not(frontCamera)
InitializeCamera
and in the code of camera1_ready, I just reinitialize all parameters. (Basically the same code is for the button which handles the picture size and this one is working.)
B4X:
Sub Camera1_Ready (Success As Boolean)
If Success Then
ClearLvs
camEx.SetJpegQuality(90)
camEx.CommitParameters
'camEx.StartPreview
'Log(camEx.GetPreviewSize)
' set the maximum picture size
Dim pictureSizes() As CameraSize = camEx.GetSupportedPicturesSizes
Dim imax As Int
Dim psmax As Int = 0
For i = 0 To pictureSizes.Length-1 ' boucle recherche taille max
If pictureSizes(i).Width + pictureSizes(i).Height > psmax Then
psmax = pictureSizes(i).Width + pictureSizes(i).Height
imax = i
End If
Next
camEx.StopPreview
camEx.CommitParameters
camEx.SetPictureSize(pictureSizes(imax).Width , pictureSizes(imax).Height)
camEx.SetPreviewSize(pictureSizes(imax).Width , pictureSizes(imax).Height)
camEx.CommitParameters
' set the button EV initial value
btnEV.Text = "+/-" & CRLF & "0"
' adapt the display to the image resolution
Dim ratio As Float
ratio = pictureSizes(imax).Height /pictureSizes(imax).Width
btnPictureSize.Text = pictureSizes(imax).width&"x"& pictureSizes(imax).Height
If ratio < (100%x / 100%y) Then 'crop largeur de panel (ratio = 3/4 et y = 5 x =3 env)
Panel1.Width = 100%y / ratio
Panel1.Height = 100%y
Panel1.left = Abs((100%x - Panel1.width)/2)
Else
Panel1.Width = 100%x
Panel1.Height = 100%x / ratio
Panel1.top = Abs((100%y - Panel1.height)/2)
End If
camEx.StartPreview
camEx.CommitParameters
Log(camEx.GetPreviewSize)
Else
ToastMessageShow("Cannot open camera.", True)
End If
End Sub
In other words, I am a bit lost... I would be gratefull if somebody could help me to find my bug. (the full project is joined)
Thanks
Alain