帧抓取,帮助代码C#到VbNET [英] Frame Grab, Help Code C# to VbNET

查看:59
本文介绍了帧抓取,帮助代码C#到VbNET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨大家好,

我正在将视频捕获项目从c#移植到vbnet,但是我有一些问题需要理解这段代码,我无法转换为VBNet。

我正在使用DirectX.Capture和DShowNET库



原始代码和示例在这里:http://www.codeproject.com/KB/audio-video/SampleGrabber.aspx [ ^ ]



任何人都可以帮我转换那些线?我无法创建FrameEvent2的句柄



Hi Guys,
I'm porting a video capture project from c# to vbnet, but i've some problem to understand this code and i can't to translate to VBNet.
I'm using DirectX.Capture and DShowNET libraries

The original code and sample is here:http://www.codeproject.com/KB/audio-video/SampleGrabber.aspx[^]

Can Anyone help me to convert those lines? I cant' to create the handle to FrameEvent2

private void button1_Click(object sender, System.EventArgs e)
{
    this.capture.FrameEvent2 += new Capture.HeFrame(this.CaptureDone);
    this.capture.GrapImg();
}
private void CaptureDone(System.Drawing.Bitmap e)
{
    this.pictureBox1.Image=e;
    // Show only the selected frame ...
    // If you want to capture all frames, then remove the next line
    this.capture.FrameEvent2 -= new Capture.HeFrame(this.CaptureDone);
}
private void button2_Click(object sender, System.EventArgs e)
{
    if( (this.pictureBox1 != null)&&
        (this.pictureBox1.Image != null)&&
        (this.imageFileName.Text.Length > 0) )
    {
        this.pictureBox1.Image.Save(this.imageFileName.Text,
            System.Drawing.Imaging.ImageFormat.Bmp);
    }
}





感谢大家!



Thanks to everyone!

推荐答案

应该是这样的:



Should go something like this:

private Sub button1_Click(object sender, System.EventArgs e) handles button1.Click
    AddHandler me.capture.FrameEvent2, Capture.HeFrame(this.CaptureDone)
    me.capture.GrapImg()
End Sub
<br />
private Sub CaptureDone(System.Drawing.Bitmap e)
    me.pictureBox1.Image = e    
    // Show only the selected frame ...    
    // If you want to capture all frames, then remove the next line
    RemoveHandler me.capture.FrameEvent2, Capture.HeFrame(this.CaptureDone)
End Sub
<br />
private Sub button2_Click(object sender, System.EventArgs e) Handles button2.Click
    if (me.pictureBox1 != null AndAlso
        me.pictureBox1.Image Not null AndAlso
        me.imageFileName.Text.Length > 0) Then
        me.pictureBox1.Image.Save(this.imageFileName.Text,
                                  System.Drawing.Imaging.ImageFormat.Bmp)    
    End If
End Sub


嗨John,我尝试了你的解决方案,但调试说这个错误:



AddHandler .CaptureInfo.FrameEvent2,AddressOf.CaptureInfo.HeFrame(Me.CaptureDone)



Hi John, i tried your solution but the debug says this error:

AddHandler .CaptureInfo.FrameEvent2, AddressOf.CaptureInfo.HeFrame(Me.CaptureDone)

'HeFrame' is a type in 'DirectX.Capture.Capture'







Argument not specified for parameter 'e' of 'Private Sub CaptureDone(e As System.Drawing.Bitmap)'.


这可能会有所帮助:

RemoveHandler Me.capture.FrameEvent2,New Capture.HeFrame(AddressOf Captura_Realizada)
This could help:
RemoveHandler Me.capture.FrameEvent2, New Capture.HeFrame(AddressOf Captura_Realizada)


这篇关于帧抓取,帮助代码C#到VbNET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆