Victor Image Processing Library How-to Tips

Scan an Image without Displaying the User Interface -- Visual Basic

The Victor Library TWAIN Support Module is very easy to use from Visual Basic. The simplest implementation is to scan a single image using the device's user interface . . .
     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.

Capture an Image without the User Interface - the Source Code for VB

Requires Victor Image Processing Library for 32-bit Windows v 5.1 or higher. Copy the VIC32.DLL and VICTW32.DLL into your directory where vb5.exe or vb6.exe resides.
' ........... 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

Victor Image Processing Library homepage | Victor Product Summary | more source code




Copyright © 2001 Catenary Systems Inc. All rights reserved. Victor Image Processing Library is a trademark of Catenary Systems.