Good morning everyone.
I am trying to do a job that requires the use of the camera, but in this work I need the front camera to be 100% on the screen. (camex)
this is what i need
is a 100%x and 100%y panel and the image is correct, the panel is not stretching the image.
i tryed make a example like this and here is the results
RESULT 1
the panel is 100% but the image is stretching.
here is another try, with erel example posted here
https://www.b4x.com/android/forum/threads/cameraex-stretching-preview.62462/#post-394473
RESULT 2
here the image is correct, is not stretching the panel and image, but is not 100% of screen.
how can i make this panel 100% on the screen and not stretching the image?
i m not good with Calculations(math)
Could someone help me with this?
thank you all.
Ps: the guns on the wall are airsoft and pellet, not real guns.
I am trying to do a job that requires the use of the camera, but in this work I need the front camera to be 100% on the screen. (camex)
this is what i need
is a 100%x and 100%y panel and the image is correct, the panel is not stretching the image.
i tryed make a example like this and here is the results
B4X:
Sub Camera1_Ready (Success As Boolean)
If Success Then
Dim csz() As CameraSize
csz = camEx.GetSupportedPreviewSizes
Dim Maxr As Int = 0
Dim mp As Map
mp.Initialize
For Each cs As CameraSize In csz
mp.Put(cs.width, cs.height)
Maxr = Max(Maxr, cs.width)
Next
If mp.ContainsKey(641) Then
camEx.SetPreviewSize(640,mp.Get(640))
camEx.SetPictureSize(640,mp.Get(640))
Else if mp.ContainsKey(721) Then
camEx.SetPreviewSize(720,mp.Get(720))
camEx.SetPictureSize(720,mp.Get(720))
Else
camEx.SetPreviewSize(Maxr, mp.Get(Maxr))
camEx.SetPictureSize(Maxr, mp.Get(Maxr))
End If
camEx.SetJpegQuality(100)
camEx.SetContinuousAutoFocus
camEx.CommitParameters
camEx.StartPreview
Else
ToastMessageShow("Cannot open camera, please try close and open the app again", True)
End If
End Sub
RESULT 1
the panel is 100% but the image is stretching.
here is another try, with erel example posted here
https://www.b4x.com/android/forum/threads/cameraex-stretching-preview.62462/#post-394473
B4X:
Dim size As CameraSize = camEx.GetPreviewSize
Dim ratio As Double = size.Width / size.Height
Dim pw, ph As Int
If 100%y * ratio > 100%x Then
pw = 100%x
ph = pw / ratio
Else
ph = 100%y
pw = ph * ratio
End If
Panel1.SetLayout(50%x - pw / 2, 50%y - ph / 2, pw, ph)
RESULT 2
here the image is correct, is not stretching the panel and image, but is not 100% of screen.
how can i make this panel 100% on the screen and not stretching the image?
i m not good with Calculations(math)
Could someone help me with this?
thank you all.
Ps: the guns on the wall are airsoft and pellet, not real guns.
Last edited: