如何在basic4android中自动捕获图像

时间:2015-03-20 05:15:01

标签: basic4android

您好我正在创建一个应用程序,其中相机以1秒的间隔自动捕获图像。在下面的代码中,我可以点击按钮拍摄图像。但我想要自动相机。 这是代码。请帮助我如何创建?

Sub Process_Global

End Sub

Sub Globals
    Dim camera1 As Camera
    Dim btnTakePicture As Button
    Dim Panel1 As Panel
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 Camera1_PictureTaken (Data() As Byte)
    camera1.StartPreview
    Dim t As Long
    Dim filename As String
    t = DateTime.Add(DateTime.Now,0,0,1)
    filename = t & ".jpg"
    Dim out As OutputStream
    out = File.OpenOutput(File.DirRootExternal, filename, False)
    out.WriteBytes(Data, 0, Data.Length)
    out.Close
    ToastMessageShow("Image Saved" , True)
    btnTakePicture.Enabled = True
End Sub

Sub btnTakePicture_Click
    btnTakePicture.Enabled = False
    camera1.TakePicture
End Sub

0 个答案:

没有答案