&& Acquire multiples images from twain device to 1 Bpp CCITT4 multipage tif with visual basic and GdTwain ActiveX
&& Download the last version of GdTwain ActiveX at http://www.gdpicture.com/download/download-gdtwain.php
Dim nImageCount As Long
Dim nImageID As Long
Dim twain As Object
Set oTwain = CreateObject("gdtwain2.twain")
oTwain.SetLicenseNumber ("0012345678910111213141516") 'Demo code version
If oTwain.TwainOpenDefaultSource() Then
nImageCount = 0
oTwain.TwainSetHideUI(True)
oTwain.TwainSetAutoFeed (True) 'Set AutoFeed Enabled
oTwain.TwainSetAutoScan (True) 'To achieve the maximum scanning rate
oTwain.TwainSetCurrentResolution (200)
oTwain.TwainSetCurrentPixelType (TWPT_BW) 'BW
oTwain.TwainSetCurrentBitDepth (1) ' 1 bpp
While oTwain.TwainAcquireToGdPictureImage(Me.hWnd) <> 0
nImageID = oTwain.GetNativeImage
nImageCount = nImageCount + 1
If nImageCount = 1 Then
Call oTwain.TiffSaveAsNativeMultiPage(App.Path & "\multipage.tif", 4)
Else
oTwain.TiffAddToNativeMultipage (nImageID)
oTwain.CloseImage (nImageID)
End If
Wend
oTwain.TiffCloseNativeMultiPage
oTwain.TwainCloseSource
MsgBox "Done !"
Else
MsgBox "can't open default source, twain state is: " & Trim(Str(oTwain.TwainGetState))
End If