Page 1 of 1

scanned image cut off

Posted: Tue Mar 08, 2011 5:33 pm
by lac61675
Hello,

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]

Re: scanned image cut off

Posted: Tue Mar 08, 2011 6:31 pm
by Loïc
Hi,

I never seen such behavior which is a fact of your TWAIN driver.

You should try to defines to document format using the TwainSetPaperSize method.

IE:

Code: Select all

m_oGdPictureImaging.TwainSetPaperSize(TwainPaperSize.A4)
Hope this helps !

Loïc

Re: scanned image cut off

Posted: Tue Mar 08, 2011 7:22 pm
by lac61675
Thanks for your quick response!

I tried adding the code suggested but results are no different :-(. Currently, we have this reporting on the following scanners:

TravelScan Pro600 (WIA driver selected - native driver works fine)
Dell Multifunction 2155CN (WIA driver and native driver product incorrect results as noted above)

Both problems are occuring on Windows 7 machines, and they do work outside of use of GDPicture dll.

Any other ideas you can offer?

Re: scanned image cut off

Posted: Mon Apr 04, 2011 9:48 am
by Loïc
Hi,

For this case:
TravelScan Pro600 (WIA driver selected - native driver works fine)
Just don't use WIA through TWAIN, or use native WIA calls using GdPictureImaging methods prefixed by "WIA".

For this one:
Dell Multifunction 2155CN (WIA driver and native driver product incorrect results as noted above)
I guess your scanner is configured to deliver a specific amount of pixel in vertical & horizontal resolution.
What I can suggest is to make a call to the TwainSetpaperSize method after setting the dpi.

If the problem persists, please follow & provide us information specified on this thread: viewtopic.php?t=1486

Kind regards,

Loïc