scanned image cut off

Discussions about TWAIN & WIA scanning in GdPicture.NET using GdPictureImaging.
Post Reply
lac61675
Posts: 4
Joined: Tue Feb 16, 2010 6:13 pm

scanned image cut off

Post by lac61675 » Tue Mar 08, 2011 5:33 pm

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]
Attachments
150dpiscan.jpg
150 dpi scan
300dpiscan.jpg
300 dpi scan

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: scanned image cut off

Post by Loïc » Tue Mar 08, 2011 6:31 pm

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

lac61675
Posts: 4
Joined: Tue Feb 16, 2010 6:13 pm

Re: scanned image cut off

Post by lac61675 » Tue Mar 08, 2011 7:22 pm

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?

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: scanned image cut off

Post by Loïc » Mon Apr 04, 2011 9:48 am

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

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest