Create a New Project
Create a new WinForms project
- File -> New Project
- Templates -> Visual Basic -> Windows Forms Application
Add the Dynamic .NET TWAIN Framework
Add reference to the project
- Right click on the project root -> Add Reference
- Click Browse to add the relevant library
Add the Dynamic .NET TWAIN component to the Toolbox
- Right click on the Toolbox panel -> Choose Items
- .NET Framework component -> Click Browse to add the relevant library (DynamicDotNetTWAIN.dll)
- Check DynamicDotNetTwain
Create the User Interface
Select Webcams
1 2 3 4 5 6 7 8 9 10 11 12 13 | Try dynamicDotNetTwain1.SelectSource() ‘ select source Dim en As EnumSupportedDeviceType en = dynamicDotNetTwain1.SupportedDeviceType dynamicDotNetTwain1.IfShowUI = True dynamicDotNetTwain1.SetVideoContainer( Me .pictureBox1) ‘ display preview in PictureBox dynamicDotNetTwain1.OpenSource() ‘ make source work Catch exp As Exception MessageBox.Show(exp.Message) End Try |
Acquire Image
1 2 3 4 5 6 | Try dynamicDotNetTwain1.IfThrowException = True dynamicDotNetTwain1.EnableSource() ‘ acquire image Catch exp As Exception MessageBox.Show(exp.Message) End Try |
Remove the Image
1 | dynamicDotNetTwain1.RemoveAllImages() ‘ remove image |
Save the Image
1 2 3 4 5 6 | If dlgFileSave.ShowDialog() = Windows.Forms.DialogResult.Cancel Then ‘ call system dialog Exit Sub End If strFileName = dlgFileSave.FileName ‘ get file name from dialog dynamicDotNetTwain1.SaveAsBMP(strFileName, dynamicDotNetTwain1.CurrentImageIndexInBuffer) ‘ save image to disk |
No comments:
Post a Comment