Setting Twain features fails

Discussions about TWAIN & WIA scanning in GdPicture.NET using GdPictureImaging.
Post Reply
gsmyly
Posts: 14
Joined: Wed Sep 30, 2009 10:50 pm

Setting Twain features fails

Post by gsmyly » Wed Sep 30, 2009 11:00 pm

I'm using the newest toolkit (just downloaded Sept 30) and I have code that checks, after opening the source, TwainIsAutomaticDiscardBlankPageAvailable and, if True, sets it to False. I then recheck the value and see that it is still True. I checked the Twain log file and see that there's a return of TWCC_BADVALUE. I've also tried Deskew and a few others (the scanner settings screen for the scanner fi-5120c shows all of these) and see the same results.

Is there some additional call that I should be making?

Thanks,
George

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

Re: Setting Twain features fails

Post by Loïc » Thu Oct 01, 2009 12:07 pm

Hi George,

I think you are making confusion between TwainIsAutomaticDiscardBlankPagesAvailable() & TwainIsAutomaticDiscardBlankPagesEnabled()


TwainIsAutomaticDiscardBlankPagesAvailable():
Asks to the opened source if she can support the Automatic discard blank images capability

TwainIsAutomaticDiscardBlankPagesEnabled():
Asks to the opened source if the Automatic discard blank images capability is enabled or not.
Kind regards,

Loïc

gsmyly
Posts: 14
Joined: Wed Sep 30, 2009 10:50 pm

Re: Setting Twain features fails

Post by gsmyly » Thu Oct 01, 2009 4:31 pm

Sorry, I wasn't specific enough... I am using the IsAvailable item to see if the Twain source says it support the feature. I then use IsEnabled to see if it is on or not (True or False), then I try to change the state using the Set for the feature and recheck the IsEnabled value and that is when I see that it is not set.

Thanks!

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

Re: Setting Twain features fails

Post by Loïc » Thu Oct 01, 2009 4:56 pm

OK.

So what is the return value of:

TwainIsAutomaticDiscardBlankPagesAvailable()
TwainIsAutomaticDiscardBlankPagesEnabled()
TwainSetAutomaticDiscardBlankPages()
Kind regards,

Loïc

gsmyly
Posts: 14
Joined: Wed Sep 30, 2009 10:50 pm

Re: Setting Twain features fails

Post by gsmyly » Fri Oct 02, 2009 4:01 pm

When I check TwainIsAutomaticDiscardBlankPagesAvailable() I get True, when I check TwainIsAutomaticDiscardBlankPagesEnabled() I get True and if I call TwainSetAutomaticDiscardBlankPages(False) I get the BADVALUE return. I've noticed that the return for TwainIsAutomaticDiscardBlankPagesEnabled() doesn't seem to correlate with the on-screen setting the scanner settings screen for the source. Should it?

Thanks

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

Re: Setting Twain features fails

Post by Loïc » Fri Oct 02, 2009 4:04 pm

Hi,

We fixed a bug with this feature.

Please, download the latest edition and tell us if the problem persists.

Kind regards,

Loïc

gsmyly
Posts: 14
Joined: Wed Sep 30, 2009 10:50 pm

Re: Setting Twain features fails

Post by gsmyly » Mon Oct 05, 2009 4:09 pm

Thanks! Will let you know if the problem is still there with the new version.

gsmyly
Posts: 14
Joined: Wed Sep 30, 2009 10:50 pm

Re: Setting Twain features fails

Post by gsmyly » Mon Oct 05, 2009 5:09 pm

I'm still seeing inconsistent results... if I use the code

Code: Select all

           oGdPictureImaging.TwainLogStart("C:\working\testset.log")
            If oGdPictureImaging.TwainIsAutomaticDiscardBlankPagesAvailable Then
                LogFile("BPD is currently " + oGdPictureImaging.TwainIsAutomaticDiscardBlankPagesEnabled.ToString)
                oGdPictureImaging.TwainSetAutomaticDiscardBlankPages(False)
                LogFile("BPD is now set to " + oGdPictureImaging.TwainIsAutomaticDiscardBlankPagesEnabled.ToString)

            End If

            oGdPictureImaging.TwainLogStop()
what I see at the first call to TwainIsAutomaticDiscardBlankPagesEnabled is True (even though the source settings screen shows the option as off). After the TwainSetAutomaticDiscardBlankPages(False)
call the second check still shows True but the scan process acts if it is off (blank pages are kept). If I change to TwainSetAutomaticDiscardBlankPages(True) then the interface still shows off but the program responds as if it is Off (blank pages are dropped).

The log file shows SUCCESS codes all around now.

Thanks!

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

Re: Setting Twain features fails

Post by Loïc » Mon Oct 05, 2009 6:00 pm

Hi,

I checked our source code and we are meeting the TWAIN specifications regarding ICAP_AUTODISCARDBLANKPAGES capability.

Therefore, I suspect your scanner to deal with this capability by another way...

To investigate, give us the returned value of this call:

Code: Select all

        Dim CapVal As Double = 0
        oGdPictureImaging.TwainGetCapCurrentNumeric(TwainCapabilities.ICAP_AUTODISCARDBLANKPAGES, CapVal)
        MsgBox(CapVal)
And this one:

Code: Select all

        For i As Integer = 1 To oGdPictureImaging.TwainGetAvailableCapValuesCount(TwainCapabilities.ICAP_AUTODISCARDBLANKPAGES)
            MsgBox(oGdPictureImaging.TwainGetAvailableCapValueNoNumeric(TwainCapabilities.ICAP_AUTODISCARDBLANKPAGES, i))
        Next

Kind regards,

Loïc

gsmyly
Posts: 14
Joined: Wed Sep 30, 2009 10:50 pm

Re: Setting Twain features fails

Post by gsmyly » Mon Oct 05, 2009 8:09 pm

The values are:

Value for TwainCapabilities.ICAP_AUTODISCARDBLANKPAGES 4294967294 at 10/5/2009 1:02:57 PM
entry 1 has a value of 4294967294 at 10/5/2009 1:02:57 PM
entry 2 has a value of 4294967295 at 10/5/2009 1:02:57 PM

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

Re: Setting Twain features fails

Post by Loïc » Mon Oct 05, 2009 8:46 pm

OK I understood.

Please use these function for your scanner. Let me know if it is working.

Code: Select all

Public Function TwainSetAutomaticDiscardBlankPages(ByVal AutoDiscard As Boolean) As Boolean
    Return oGdPictureImaging.TwainSetCapCurrentNumeric(TwainCapabilities.ICAP_AUTODISCARDBLANKPAGES, oGdPictureImaging.TwainGetCapItemType(TwainCapabilities.ICAP_AUTODISCARDBLANKPAGES), CInt(IIf(AutoDiscard, 4294967295 , 4294967294)))
End Function



Public Function TwainIsAutomaticDiscardBlankPagesEnabled() As Boolean
   Dim bEnabled As Boolean = False
   Dim nDiscardBlankPage As Double

   If oGdPictureImaging.TwainGetCapCurrentNumeric(TwainCapabilities.ICAP_AUTODISCARDBLANKPAGES, nDiscardBlankPage) Then bEnabled = (nDiscardBlankPage = 4294967295)

   Return bEnabled
End Function
Kind regards,

Loïc

gsmyly
Posts: 14
Joined: Wed Sep 30, 2009 10:50 pm

Re: Setting Twain features fails

Post by gsmyly » Tue Oct 06, 2009 4:02 pm

I tried the code that you sent but when I make a call to the TwainSetAutomaticDiscardBlankPages function it crashes the program in such a way that I have to reboot to be able to use the Twain source again. I'm going to have to drop research of this for a bit while I work on another project but will return to it shortly.

Thanks.

dcanelas
Posts: 8
Joined: Fri Jan 07, 2011 5:17 pm

Re: Setting Twain features fails

Post by dcanelas » Thu Sep 13, 2012 4:27 pm

I'm having this same problem with one of my scanners. My original code (C#):

Code: Select all

if(oGdPictureImaging.TwainIsAutomaticDiscardBlankPagesAvailable())
{
    if(!oGdPictureImaging.TwainSetAutomaticDiscardBlankPages(_bAutomaticDiscardBlankPages))
    { new ScanningException(Constants.ErrorCode.Twain_ErrorEnablingAutomaticDiscardBlankPages); }
}
Worked fine in the Fujitsu fi-4340C but it didn't in a Fujitsu fi-6130. It doesn't throw any errors, just doesn't work.
So, using the code from the previous posts, I built this new one, based also on the twain specs:

Code: Select all

if(oGdPictureImaging.TwainIsAutomaticDiscardBlankPagesAvailable())
{
    double selectValue = _bAutomaticDiscardBlankPages ? (double) -1 : (double) -2;
    if(!oGdPictureImaging.TwainSetCapCurrentNumeric(TwainCapabilities.ICAP_AUTODISCARDBLANKPAGES, Controler.Imaging.TwainGetCapItemType(TwainCapabilities.ICAP_AUTODISCARDBLANKPAGES), selectValue))
    { new ScanningException(Constants.ErrorCode.Twain_ErrorEnablingAutomaticDiscardBlankPages); }
}
This new code also works with the Fujitsu fi-4340C but it doesn't with the Fujitsu fi-6130.
When using the values 4294967295 and 4294967294 (values returned by TwainGetAvailableCapValuesCount(TwainCapabilities.ICAP_AUTODISCARDBLANKPAGES)) for both scanners, it throws the exception: {"Arithmetic operation resulted in an overflow."}.

Any ideias how to solve this? When using the driver's UI, the option is available and works fine.

Twain specs used:
ICAP_AUTODISCARDBLANKPAGES
Constant Numeric ID
------------- -----------
TWBP_DISABLE -2
TWBP_AUTO -1

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

Re: Setting Twain features fails

Post by Loïc » Fri Sep 14, 2012 11:16 am

Hello,

We've have been able to reproduce and fix the problem. The next 9.2.1 release will include the fix.

With best regards,

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest