Visual Basic and Device Independent Bitmaps

Top  Previous  Next

In the installation directory are small samples of using DTWAIN within a Visual Basic application.  Most of these examples illustrate the basic DTWAIN functions, and use the clipboard to transfer the image to a VB image object.  Since TWAIN works with Device Independent Bitmaps (DIBs) extensively, the Visual Basic programmer should be familiar with handling DIBs within a VB application.

 

Most of the examples use the Windows API clipboard functions to save the acquired DIB to the clipboard.  Since a DIB is actually a LONG variable and not a true VB object, it is easier to use the API to handle saving to the clipboard.  Once the data is saved to the clipboard, the VB clipboard object GetData method using the vbCFDIB format can be used to transfer the DIB to an image or picture object.

 

An alternative is to use the DTWAIN_AcquireToClipboard function.  This automates placing the DIB in the clipboard, and all that is necessary for the VB app is to call Clipboard.GetData using the vbCFDIB format.

 

Consult the VB documentation for more information on handling DIBs using the Clipboard object.  Also investigate using a third-party library (or develop your own code) that handles DIB's directly without using the clipboard as an intermediate object.