Acquire an image using TWAIN and VB.NET
A sample application using TwainControlX
This example shows a simple VB.NET application to acquire an image from a TWAIN device (scanner or webcam) and display the image. The demo files are included with the installer for the trial version of TwainControlX, available here:
After installing TwainControlX the demo is available from the Windows Start Menu. The demo consists of a single form as shown below:
Some useful points to note when using this demo:
- The device to be used is selected from a ComboBox. This is populated with the names of all installed devices when the project is first run.
- VB.NET cannot directly recognise indexed properties of ActiveX controls, such as the DeviceName property of TwainControlX. To access such properties, prefix the name of the property with 'get_' or 'set_' as shown in Sub Form1_Load.
- A CheckBox can be used to choose whether or not to display the default user interface of the device.
- If the user interface is not to be displayed, the resolution, pixel type, and size of the image can be set by the user.
- Both 32-bit and 64-bit versions of TwainControlX are available. This demo project has the target platform set to 'Any CPU' and so should automatically select the correct version of the OCX file.
- The 'About' button displays information about TwainControlX. This can be used to confirm the version currently in use.
- Images saved using the 'Save Image' button will be saved in the working directory of the VB project. A full path to the file can be specified to save to any other location.
Note that the demo has been prepared using the 2010 version of VB. For a copy of the demo compatible with older versions of VB.NET download the following ZIP file: