⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.vb

📁 视频卡的测试程序
💻 VB
📖 第 1 页 / 共 2 页
字号:
        Me.Combo2.Items.AddRange(New Object() {"0", "1", "2", "3"})
        Me.Combo2.Location = New System.Drawing.Point(38, 13)
        Me.Combo2.Name = "Combo2"
        Me.Combo2.Size = New System.Drawing.Size(146, 20)
        Me.Combo2.TabIndex = 2
        Me.Combo2.Text = "ComboBox2"
        '
        'Button3
        '
        Me.Button3.Location = New System.Drawing.Point(632, 240)
        Me.Button3.Name = "Button3"
        Me.Button3.Size = New System.Drawing.Size(144, 22)
        Me.Button3.TabIndex = 13
        Me.Button3.Text = "One Shot"
        '
        'Folder1
        '
        Me.Folder1.RootFolder = System.Environment.SpecialFolder.MyComputer
        Me.Folder1.SelectedPath = "D:\"
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(640, 408)
        Me.Label2.Name = "Label2"
        Me.Label2.TabIndex = 14
        Me.Label2.Text = "save path:"
        '
        'PathName
        '
        Me.PathName.Location = New System.Drawing.Point(632, 440)
        Me.PathName.Name = "PathName"
        Me.PathName.Size = New System.Drawing.Size(112, 21)
        Me.PathName.TabIndex = 15
        Me.PathName.Text = "D:\"
        '
        'Button4
        '
        Me.Button4.Location = New System.Drawing.Point(752, 440)
        Me.Button4.Name = "Button4"
        Me.Button4.Size = New System.Drawing.Size(48, 23)
        Me.Button4.TabIndex = 16
        Me.Button4.Text = "Browse"
        '
        'Bon_Save
        '
        Me.Bon_Save.Location = New System.Drawing.Point(624, 472)
        Me.Bon_Save.Name = "Bon_Save"
        Me.Bon_Save.Size = New System.Drawing.Size(96, 23)
        Me.Bon_Save.TabIndex = 17
        Me.Bon_Save.Text = "save picture"
        '
        'Timer1
        '
        Me.Timer1.Interval = 10000
        '
        'form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(872, 509)
        Me.Controls.Add(Me.Bon_Save)
        Me.Controls.Add(Me.Button4)
        Me.Controls.Add(Me.PathName)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Button3)
        Me.Controls.Add(Me.GroupBox4)
        Me.Controls.Add(Me.GroupBox3)
        Me.Controls.Add(Me.GroupBox2)
        Me.Controls.Add(Me.GroupBox1)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.TextBox1)
        Me.Controls.Add(Me.PictureBox1)
        Me.Controls.Add(Me.Button2)
        Me.Controls.Add(Me.Button1)
        Me.Name = "form1"
        Me.Text = "Form1"
        Me.GroupBox1.ResumeLayout(False)
        Me.GroupBox2.ResumeLayout(False)
        Me.GroupBox3.ResumeLayout(False)
        Me.GroupBox4.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region
    Dim newBitmap As Bitmap = Nothing
    Dim Start_address As IntPtr
    Dim AngeloThread As System.Threading.Thread = Nothing
    Dim VideoFormat As Short
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Combo1.SelectedIndex = 0
        Combo2.SelectedIndex = 0
        Combo3.SelectedIndex = 3
        Combo4.SelectedIndex = 0
        VideoFormat = 2
        gwidth = 320
        gheight = 240
        Byte_Pixel = 3
        continue_thread = True

        For portno = 0 To 3
            Result = AngeloRTV_Initial(portno) ' initial channel 0
        Next
        Lb_Save = False
        Bon_Save.Text = "Save Picture"
        portno = 0

    End Sub

    Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        frame_NO = &HFFFFFFFF
        start_capture()

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        frame_NO = 1
        start_capture()
    End Sub

    Private Sub start_capture()

        continue_thread = False

        Interrupt_Count = 0
        portno = Combo1.SelectedIndex
        VideoFormat = Combo3.SelectedIndex
        multiplex = 2 ^ Combo2.SelectedIndex

        Select Case (Combo4.SelectedIndex)
            Case 0
                Byte_Pixel = 2
            Case 1
                Byte_Pixel = 3
        End Select

        AngeloRTV_Set_Int_Factor(portno, &H3)
        Result = AngeloRTV_Set_Color_Format(portno, Byte_Pixel)
        Result = AngeloRTV_Set_Video_Format(portno, VideoFormat)
        Result = AngeloRTV_Select_Channel(portno, multiplex)

        continue_thread = True
        AngeloThread = New System.Threading.Thread(AddressOf lpthread)
        AngeloThread.Start()

    End Sub



    Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        Button2_Click(sender, e)

        For portno = 0 To 3
            Result = AngeloRTV_Close(portno) ' initial channel 0
        Next

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        continue_thread = False
    End Sub


    Sub lpthread()
        Dim intstatus As Integer
        Do While (continue_thread = True)
            AngeloRTV_Sync_Grab(portno, Start_address, gwidth, gheight, size_byte)
            Interrupt_Count = Interrupt_Count + 1
            TextBox1.Text = Interrupt_Count
            Select Case (Combo4.SelectedIndex)
                Case 0
                    newBitmap = New System.Drawing.Bitmap(gwidth, gheight, gwidth * Byte_Pixel, Imaging.PixelFormat.Format16bppRgb555, Start_address)

                Case 1
                    newBitmap = New System.Drawing.Bitmap(gwidth, gheight, gwidth * Byte_Pixel, Imaging.PixelFormat.Format24bppRgb, Start_address)

            End Select
            PictureBox1.Image = newBitmap

            If frame_NO = 1 Then 'single shot
                continue_thread = False
            End If
        Loop
        AngeloRTV_Capture_Stop(portno)
    End Sub


    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub ComboBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub Folder1_HelpRequest(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Folder1.HelpRequest

    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Folder1.ShowDialog()
        PathName.Text = Folder1.SelectedPath
    End Sub


    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bon_Save.Click
        If Lb_Save = True Then
            Lb_Save = True
            Timer1.Enabled = False
            Bon_Save.Text = "Save Picture"
        Else
            Lb_Save = False
            Bon_Save.Text = "Stop"
            Timer1.Enabled = True
        End If


    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim Ls_Path As String

        Ls_Path = Trim(PathName.Text) + "\" + Format(Now, "yyyyMMddhh")
        If IO.Directory.Exists(Ls_Path) = False Then
            IO.Directory.CreateDirectory(Ls_Path)
        End If

        Ls_Path = Ls_Path + "\" + Format(Now, "yyyyMMddhhmmss") + ".bmp"
        PictureBox1.Image.Save(Ls_Path, Imaging.ImageFormat.Bmp)
    End Sub
End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -