Crash when scanning in grayscale

Discussions about TWAIN & WIA scanning in GdPicture.NET using GdPictureImaging.
Post Reply
andypl
Posts: 15
Joined: Fri Nov 13, 2009 5:10 pm

Crash when scanning in grayscale

Post by andypl » Fri Dec 11, 2009 6:49 am

I've had no problem scanning in grayscale with two different scanners personally, but a customer had my application crash during a grayscale scan. Black and white hasn't been a problem for him.

Here is the code I use to configure the scanner. I am offering three scan types for the customer to choose from (identified by the enum - B&W, Grayscale, and Color).

Perhaps I'm doing something incorrect?

Code: Select all

  Private Sub Configure(ByVal settings As Settings)
        m_gd.TwainSetHideUI(True)
        m_gd.TwainSetAutoBrightness(True)
        m_gd.TwainSetAutoFeed(settings.useADF)
        m_gd.TwainEnableDuplex(settings.duplexScanning)
        m_gd.TwainSetResolution(settings.dpi)
        If (settings.paperSize <> GdPicture.TwainPaperSize.NONE) Then
            m_gd.TwainSetAutoSize(False)
            m_gd.TwainSetPaperSize(settings.paperSize)
        Else
            m_gd.TwainSetAutoSize(True)
        End If
        Select Case CType(settings.scanType, RGSettings.ScanningColorDefault)
            Case RGSettings.ScanningColorDefault.BW
                m_gd.TwainSetPixelType(TwainPixelType.TWPT_BW)
                m_gd.TwainSetBitDepth(1)
            Case RGSettings.ScanningColorDefault.Grayscale
                m_gd.TwainSetPixelType(TwainPixelType.TWPT_GRAY)
                m_gd.TwainSetBitDepth(1)
            Case RGSettings.ScanningColorDefault.Color
                m_gd.TwainSetPixelType(TwainPixelType.TWPT_RGB)
                m_gd.TwainSetBitDepth(24)
            Case RGSettings.ScanningColorDefault.Unknown
                m_gd.TwainSetPixelType(TwainPixelType.TWPT_GRAY)
                m_gd.TwainSetBitDepth(1)
        End Select
    End Sub

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

Re: Crash when scanning in grayscale

Post by Loïc » Fri Dec 11, 2009 9:42 am

Hi,

I need some other information. Please have a look on this thread: viewtopic.php?t=1486

Kind regards,

Loïc

andypl
Posts: 15
Joined: Fri Nov 13, 2009 5:10 pm

Re: Crash when scanning in grayscale

Post by andypl » Fri Dec 11, 2009 3:11 pm

Thanks Loic, I'll get you the info you need on the crash.

But just to confirm... nothing was obviously wrong with my configuration setup?

What do you recommend for the bit/pixel depth if I want to offer the user three simple choices: BW, Grayscale, and Color?

Thanks
Andy

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

Re: Crash when scanning in grayscale

Post by Loïc » Fri Dec 11, 2009 3:25 pm

Hi,

You should use 8 for TWPT_GRAY bitdepth.

Else, all seem OK.

Kind regards,

Loïc

andypl
Posts: 15
Joined: Fri Nov 13, 2009 5:10 pm

Re: Crash when scanning in grayscale

Post by andypl » Sat Dec 12, 2009 4:05 pm

Interestingly, setting the bits/pixel to 8 with grayscale fixed the problem... so perhaps the driver was not able to handle that setting.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest