Sub Activity_Resume
FirstInit = True
InitializeCamera
End Sub
Private Sub ReInitializeCamera
FirstInit = False
camEx.Release
InitializeCamera
End Sub
Sub Camera1_Ready (Success As Boolean)
If FirstInit = True Then
Dim size As CameraSize = camEx.GetPreviewSize
If Activity.Width < Activity.Height Then
Dim t As Int = size.Width
size.Width = size.Height
size.Height = t
End If
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)
CallSubDelayed(Me, "ReInitializeCamera")
Return
End If
If Success Then
camEx.SetJpegQuality(90)
camEx.SetContinuousAutoFocus
camEx.CommitParameters
camEx.StartPreview
Log(camEx.GetPreviewSize)
Else
ToastMessageShow("Cannot open camera.", True)
End If
End Sub