Click here to Skip to main content
15,880,543 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

C#
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!
Posted

Should go something like this:

VB
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
 
Share this answer
 
v2
Hi John, i tried your solution but the debug says this error:

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

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


VB
Argument not specified for parameter 'e' of 'Private Sub CaptureDone(e As System.Drawing.Bitmap)'.
 
Share this answer
 
Comments
trying2programme 8-Apr-11 1:51am    
Hi there,

Did you manage to work this out? I am converting exactly the same code and am getting the same error.

Many thanks
This could help:
RemoveHandler Me.capture.FrameEvent2, New Capture.HeFrame(AddressOf Captura_Realizada)
 
Share this answer
 
Comments
CHill60 11-Jan-14 11:05am    
3 years ago it might have done

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900