I'm a bit of a newbie at this so any help is very much appreciated!
We are noticing that some AutoDocFeeder scanners using our .NET application in conjunction with the GdPicture.net dll are not converting the images properly. Our pages appear cutoff. Please see attached output. Each doc occurs at the specified resolution in the filename. When we scan independently of our application (excluding gdpicture.net) it scans properly.
Can you please review the code below and let me know if I am missing something? We are using GDPicture.NET version 6.7.0.4 with target .Net Framework 3.5. We also purchased a barcode scanning license (which is working fine).
Thank you!
Code: Select all
iPageCount = 0
m_oGdPictureImaging.TwainOpenDefaultSource(Me.Handle)
m_oGdPictureImaging.TwainSetHideUI(True)
m_oGdPictureImaging.TwainSetAutoFeed(True) 'Set AutoFeed Enabled
m_oGdPictureImaging.TwainSetAutoScan(True) 'To achieve the maximum scanning rate
sDPI = modMain_Parsed(PODScanDPIRec, FM, 2)
sImageFormat = modMain_Parsed(PODScanDPIRec, FM, 4)
If sDPI <> "" And IsNumeric(sDPI) Then
m_oGdPictureImaging.TwainSetResolution(Convert.ToInt16(sDPI))
Else
m_oGdPictureImaging.TwainSetResolution(150)
End If
Select Case sImageFormat.ToUpper
Case "JPEG"
sFileExt = ".jpg"
Case "TIFF", "TIF"
sFileExt = ".tiff"
End Select
m_oGdPictureImaging.TwainSetPixelType(TwainPixelType.TWPT_BW)
m_oGdPictureImaging.TwainSetBitDepth(1)
Do
UpdateStatus("Scanning Page " & (iPageCount + 1).ToString & vbCrLf)
ImageID = m_oGdPictureImaging.TwainAcquireToGdPictureImage(Me.Handle)
If ImageID <> 0 Then
If Not Directory.Exists(PATH_TEMP_DIRECTORY) Then Directory.CreateDirectory(PATH_TEMP_DIRECTORY)
sFileName = PATH_TEMP_DIRECTORY & FileNameSeed & Trim(Str(iImageCount)) & sFileExt
Do While File.Exists(sFileName)
iImageCount = iImageCount + 1
sFileName = PATH_TEMP_DIRECTORY & FileNameSeed & Trim(Str(iImageCount)) & sFileExt
Loop
iImageCount = iImageCount + 1
If sImageFormat.ToUpper = "JPEG" Or sImageFormat.ToUpper = "JPG" Then Call m_oGdPictureImaging.SaveAsJPEG(ImageID, sFileName, 75)
If Mid(sImageFormat.ToUpper, 1, 3) = "TIF" Then Call m_oGdPictureImaging.SaveAsTIFF(ImageID, sFileName, 75)
Call m_oGdPictureImaging.ReleaseGdPictureImage(ImageID)
End If
iPageCount = iPageCount + 1
Loop While m_oGdPictureImaging.TwainGetState > TwainStatus.TWAIN_SOURCE_ENABLED
Call m_oGdPictureImaging.TwainCloseSource()
UpdateStatus("Scanning of documents completed." & vbCrLf)[attachment=0]150dpiscan.jpg[/attachment][attachment=1]300dpiscan.jpg[/attachment]