Android Question CameraEX window size

Beja

Expert
Licensed User
Longtime User
Hello all,
looking into the methods of the Camera object, I couldn't find one that can be used to define the image window size.. am I missing something or is there any workaround.
I want the image be in a small square in the middle of the screen.
 

Manuel Martinez

Member
Licensed User
Longtime User
Hello all,
looking into the methods of the Camera object, I couldn't find one that can be used to define the image window size.. am I missing something or is there any workaround.
I want the image be in a small square in the middle of the screen.

Hi Beja,

The window size is defined with de panel you use in camera.initialize

B4X:
Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim Camera As CameraExClass
   Dim pnlCamera As Panel
End Sub

Sub Activity_Create(FirstTime As Boolean)
   'Do not forget to load the layout file created with the visual designer. For example:
   'Activity.LoadLayout("Layout1")
   pnlCamera.Initialize("pnlCamera")
   Activity.AddView(pnlCamera,25%x,25%y,50%x,50%y)
   Camera.Initialize(pnlCamera,False,Me,"camera")
End Sub

Best regards
Manuel
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
Hi Manuel,
Thanks and I was asking about the cameraex example where the layout, including the panel was in the visual designer (not in code).
 
Upvote 0

Manuel Martinez

Member
Licensed User
Longtime User
Hi Beja,

You can change the size of the panel in code or in the visual designer, in the cameraex example you can si this line:

B4X:
Sub Activity_Resume
Button1.Enabled = False
camara.Initialize(Panel1, "camara")
End Sub

If you want to show a 100x100 panel centered in the screen just add the size of the panel as follow:

B4X:
Sub Activity_Resume
Button1.Enabled = False
Panel1.Height = 100dip
Panel1.Width = 100dip
Panel1.Top = 50%y - Panel1.Height / 2
Panel1.Left = 50%x - Panel1.Width / 2
camara.Initialize(Panel1, "camara")
End Sub

Best regards
Manuel
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
Hi Manuel, thanks for the followup!
In fact I want to take part of the picture in preview.. see attached.. (the eye inside the blue square)
Anyone any idea?

eyewindow.png
 
Last edited:
Upvote 0
Top