Rotating Panel 90 degrees for camera app.

refsmmat

Member
Licensed User
Longtime User
Hello everyone,

I have seen discussions about rotating panels (mostly containing bitmaps). I have a problem which is similar, but not exactly the same.

I am using the camera library. When I have an aspect change (portrait to landscape) I have no problems - only I cannot rotate the panel.
Effectively, rotating the camera gives me a 90 degree rotated preview window.

I have created two "layout variants" (they switch correctly). The panel sizing works correctly when the handset switches layouts, but I cannot set a panel to display a rotated image.

1. Can I create a second panel for the layout (in portrait mode) - bearing in mind I need to set it up using "camera1.Initialize(Panel1, "Camera1")"

2. Since I can resize a panel for my two layouts, is there a way to rotate it as well?

Many thanks for your assistance.
Regards,

refsmmat


Sample code is below:
B4X:
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
 
End Sub

Sub Globals
   Dim camera1 As Camera
   Dim btnTakePicture As Button
   Dim Panel1 As Panel

   Dim Button_Quit As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("1")
End Sub
Sub Camera1_Ready (Success As Boolean)
   If Success Then
      camera1.StartPreview
      btnTakePicture.Enabled = True
   Else
      ToastMessageShow("Cannot open camera.", True)
   End If
End Sub


Sub Activity_Resume
   btnTakePicture.Enabled = False
   camera1.Initialize(Panel1, "Camera1")
End Sub

Sub Activity_Pause (UserClosed As Boolean)
   camera1.Release
End Sub


Sub Button_Quit_Click
   Activity.Finish
End Sub



Sub Camera1_PictureTaken (Data() As Byte)
   camera1.StartPreview
   Dim out As OutputStream
   out = File.OpenOutput(File.DirRootExternal, "1.jpg", False)
   out.WriteBytes(Data, 0, Data.Length)
   out.Close
   ToastMessageShow("Image saved: " & File.Combine(File.DirRootExternal, "1.jpg"), True)
   btnTakePicture.Enabled = True   
End Sub

Sub btnTakePicture_Click
   btnTakePicture.Enabled = False
   camera1.TakePicture

End Sub
 

refsmmat

Member
Licensed User
Longtime User
Hi Everyone,
As a follow-up, I have cheated a bit and fixed the problem by locking the orientation.
Regards,
Stephen
 
Upvote 0
Top