IsBlank Issue

Discussions about TWAIN & WIA scanning in GdPicture.NET using GdPictureImaging.
Post Reply
rcsingle
Posts: 10
Joined: Tue Jan 12, 2010 11:37 pm

IsBlank Issue

Post by rcsingle » Wed Oct 20, 2010 9:48 pm

I am using gdPicture 6.7 and am trying to use isBlank to exclude blank pages, but it is excluding pages that have little information as well (Word document with about three lines of text). Here is the code being used:

Code: Select all

    Private Sub InitScanConfig()
        oGdPictureImaging.TwainSetHideUI(True)
        oGdPictureImaging.TwainSetIndicators(False)
        oGdPictureImaging.TwainSetAutoBrightness(True)
        oGdPictureImaging.TwainSetContrast(0)
        oGdPictureImaging.TwainSetResolution(200)
        oGdPictureImaging.TwainSetAutoFeed(True) 'Set AutoFeed Enabled
        oGdPictureImaging.TwainSetAutoScan(True) 'To  achieve the maximum scanning rate
        oGdPictureImaging.TwainSetPixelType(TwainPixelType.TWPT_RGB) 'RGB
        oGdPictureImaging.TwainSetBitDepth(1) ' 1 bpp
    End Sub

    Private Sub ScanDocuments()
        Dim PdfID As Integer
        Dim count As Integer
        count = 0

        Try
            If oGdPictureImaging.TwainOpenDefaultSource(Me.Handle) Then

                InitScanConfig()

                GdViewer1.ZoomMode = ViewerZoomMode.ZoomModeFitToViewer

                If Me.chkLegal.Checked = True Then
                    oGdPictureImaging.TwainSetPaperSize(TwainPaperSize.USLEGAL)
                Else
                    oGdPictureImaging.TwainSetPaperSize(TwainPaperSize.USLETTER)
                End If

                If Me.rdoDoubleSided.Checked = True Then
                    oGdPictureImaging.TwainEnableDuplex(True)
                ElseIf Me.rdoSingleSided.Checked = True Then
                    oGdPictureImaging.TwainEnableDuplex(False)
                End If

                PdfID = oGdPictureImaging.TwainPdfStart(strScannedFilesPath & strFileName & ".pdf", True, "", "", "", "", "")

                Do
                    ImageID = oGdPictureImaging.TwainAcquireToGdPictureImage(Me.Handle)
                    count = count + 1
                    If count = 1 Then
                        Call oGdPictureImaging.SaveAsJPEG(ImageID, strScannedFilesPath & strFileName & ".jpg", 90)
                    End If
                    If ImageID <> 0 Then
                        If Not oGdPictureImaging.IsBlank(ImageID) Then
                            Call oGdPictureImaging.TwainAddGdPictureImageToPdf(PdfID, ImageID)
                            oGdPictureImaging.ReleaseGdPictureImage(ImageID)
                        End If
                    End If
                Loop While oGdPictureImaging.TwainGetState > TwainStatus.TWAIN_SOURCE_ENABLED
                oGdPictureImaging.TwainPdfStop(PdfID)
                CloseCurrentImage()
                Call DisplayImage(strScannedFilesPath & strFileName & ".pdf")

            Else
                oGdPictureImaging.TwainSelectSource(Me.Handle)
                Me.btnScan.Enabled = True
                Exit Sub
            End If

            Call oGdPictureImaging.TwainCloseSource()
            Call oGdPictureImaging.TwainUnloadSourceManager(Me.Handle)

        Catch ex As Exception
            ExceptionHandler(ex, "frmScanDocs_ScanDocuments")
        End Try

    End Sub
Is there a way to set the sensitivity of the isBlank function, or something?

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

Re: IsBlank Issue

Post by Loïc » Thu Oct 21, 2010 2:15 pm

Hi,

You can change the sensitivity function passing a threshold parameter to the overload method isBlank(int T). Just have a look on the reference guide !

Kind regards,

Loïc

rcsingle
Posts: 10
Joined: Tue Jan 12, 2010 11:37 pm

Re: IsBlank Issue

Post by rcsingle » Mon Oct 25, 2010 2:22 pm

Sorry, I missed that in the documentation when I looked originally.

I tried the sensitivity setting, but it is still an issue. The documentation recommends 99 for the setting, but that setting excludes the 3 or 4 lines of text document as blank. I played around with the settings and was able to get a 4 line document to be accepted with a setting of 99.3 and still exclude blank pages. However the user is having issues with a document with 1 short line of text being flagged as blank. Any setting I try above 99.3, at some point (99.4 or 99.5) accepts the short line of text as non-blank, but also accepts blank pages as non-blank. Any ideas?

Thank you for your help.

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests