Dim new_image as imgdes ' Image descriptor
Dim rcode as long ' Return code
rcode = TWscanimage(hWnd, new_image)
And it is just as easy to scan an image without displaying the user interface . . .
Dim srect as RECT
Dim gsimage as imgdes
Dim showUI as long
Dim rcode as long
srect.left = 0 ' Scan bed coordinates in 1000th inch
srect.top = 0
srect.right = 3000 ' 3 inches wide
srect.bottom = 1000 ' 1 inch high
showUI = 0 ' Don't show User Interface
rcode = TWscanimageex(hWnd, gsimage, srect, showUI)
Then to save the image in a TIFF file . . .
rcode = savetif("newimage.tif", new_image, 0)
In addition to being easy, the Victor Library control of the TWAIN device is also powerful. You can hide the user interface, control the scan conditions, and capture multiple images. For sample code demonstrating complete control visit "Control a TWAIN device with Visual Basic."
The example shown here sets capture area, sets the user interface to be hidden, then scans the image from the TWAIN device. The image is then saved to a TIFF file.
' ........... Defines and declarations ........... ' ................................................ ' Image descriptor Type imgdes ibuff As Long stx As Long sty As Long endx As Long endy As Long buffwidth As Long palette As Long colors As Long imgtype As Long bmh As Long hBitmap As Long End Type Type RECT left As Long top As Long right As Long bottom As Long End Type ' ................................................ Declare Sub freeimage Lib "VIC32.DLL" (image As imgdes) Declare Function TWscanimageex Lib "VICTW32.DLL" (ByVal hWnd As Long, ByRef desimg As imgdes, pRect As RECT, ByVal showIU As Long) As Long ' .................. Function ........................ Private Sub mnuScan_Click() Dim srect As RECT Dim gsimage As imgdes Dim showUI As Long Dim rcode As Long srect.left = 0 ' Scan bed coordinates in 1000th inch srect.top = 0 srect.right = 3000 ' 3 inches wide srect.bottom = 1000 ' 1 inch high showUI = 0 ' Don't show User Interface ' To hide the user interface and capture a single image rcode = TWscanimageex(hWnd, gsimage, srect, showUI) ' To save the image . . . rcode = savetif("scan1.tif", gsimage, 0) ' To release the memory when done . . . freeimage gsimage End Sub ' ................................................
Victor Image Processing Library homepage | Victor Product Summary | more source code