Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Wednesday, March 15, 2006 5:48:50 PM(UTC)

STech  
STech

Groups: Registered
Posts: 6


Hi

I have encountered some difficulties when querying the capability of the scanner resolution. Actually I need to get the minimum, maximum, current, default and stepsize value of the scanner. I am using the code below to get the values but return values is not correct compare to the values I get from using the TWAIN Toolkit (Twack_32.exe, see the attached picture.bmp). The value in the CapRange is all set to 1.

CapRange.RangeCurrentValue.FloatValue = 1
CapRange.RangeDefaultValue.FloatValue = 1
CapRange.MaximumValue.FloatValue = 1
CapRange.MinimumValue.FloatValue = 1
CapRange.RangeStepSize.FloatValue = 1

Anyone know what's wrong with the code?

 

Sample Code:

Dim iret As Integer 
Dim oTwainCap As New LEADTwainCapability
        
oTwainCap.EnableMethodErrors = False
oTwainCap.CapInfo.ConType = L_TWON_DONTCARE16
oTwainCap.CapInfo.Capability = L_ICAP_XRESOLUTION
iret = RasterTwain2.GetCapability2(oTwainCap, L_LTWAIN_CAPABILITY_GETVALUES)
If iret <> 0 Then
    MsgBox "Error Getting Capability!!!"
Else
    ' Do something here...
End If

 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Wednesday, March 15, 2006 5:53:42 PM(UTC)

STech  
STech

Groups: Registered
Posts: 6


Hi

here is the attached picture.jpg captured from TWAIN toolkit (Twack_32.exe)

STech attached the following image(s):
picture.jpg
 
#3 Posted : Monday, March 20, 2006 3:29:57 AM(UTC)
ewintermyer

Groups: Registered
Posts: 8


Here is the code I use to get a list of supported resolutions using VB6:

Public Sub RetrieveSupportedDensities(combo As ComboBox)
    Dim strNullArray(0, 0) As String
   
    strNullArray(0, 0) = vbNull
   
    Set TwainCap = New LEADTwainCapability
    TwainCap.CapInfo.ConType = L_TWON_DONTCARE16
    TwainCap.CapInfo.Capability = L_ICAP_XRESOLUTION
    intRet = RasterTwain.GetCapability2(TwainCap, L_LTWAIN_CAPABILITY_GETVALUES)
    If intRet = 0 Then
        TwainFillComboBox combo, strNullArray, False
        combo.ListIndex = FindItemByName(combo, CLng(gintResolution))
    End If
End Sub

I didn't attach the TwainFillComboBox function, but Lead has it in one of their Twain samples.

You call the GetCapability function again with L_LTWAIN_CAPABILITY_GETCURRENT and L_LTWAIN_CAPABILITY_GETDEFAULT to get those values.

I know this doesn't entirely answer your question, but I hope it points you in the right direction.

 
#4 Posted : Wednesday, March 22, 2006 10:53:09 AM(UTC)

Travis  
Travis

Groups: Registered, Tech Support
Posts: 207

Was thanked: 3 time(s) in 3 post(s)

Were you able to resolve this issue with the code provided in the previous post?
Travis Montgomery
Senior Sales Engineer
LEAD Logo
 
#5 Posted : Wednesday, May 31, 2006 12:06:07 PM(UTC)
gofarrell

Groups: Registered
Posts: 11


Does this capability exist on all twain scanners?  I am trying to get the available dpi values for scanners.  On some scanners it seems to work but I get errors on other scanners.
 
#6 Posted : Wednesday, May 31, 2006 12:24:52 PM(UTC)

Travis  
Travis

Groups: Registered, Tech Support
Posts: 207

Was thanked: 3 time(s) in 3 post(s)

According to the twain.h header file from the 1.9 specification, these are the only required capabilities:

/* all data sources are REQUIRED to support these caps */
CAP_XFERCOUNT

/* image data sources are REQUIRED to support these caps */
ICAP_COMPRESSION
ICAP_PIXELTYPE
ICAP_UNITS
ICAP_XFERMECH

Travis Montgomery
Senior Sales Engineer
LEAD Logo
 
#7 Posted : Wednesday, May 31, 2006 1:11:41 PM(UTC)
jljamison

Groups: Registered
Posts: 19




Isn't the question why he is getting the values he is getting, when
twacker clearly presents a valid response...I have noticed this myself getting XRESOLUTION from my Canon flatbed scanner.

The VB code provided just kind of reiterates what he is trying to get.


I noticed in the TwainDemo C++ code that though the GetCapabilities is
called with the twCap container type set to TWON_ENUMERATION, after the
call to GetCapabilities the container type is later checked to see
whether it is an enumeration or a onevalue (template.cpp, line
129).  Don't know if the driver can override the requested
container type, or whether this is boilerplate code copied & pasted for speed of development.

-John Jamison
 
#8 Posted : Thursday, June 1, 2006 3:24:01 AM(UTC)
gofarrell

Groups: Registered
Posts: 11


I guess then my question is how can I get the valid DPI values a Twain scanner will accept?  I want to load into my user interface the valid values.  Is there a way to do this?  I have code that seems to work on some scanners but not others.
 
#9 Posted : Thursday, June 1, 2006 4:43:23 AM(UTC)

Travis  
Travis

Groups: Registered, Tech Support
Posts: 207

Was thanked: 3 time(s) in 3 post(s)

You say you have code that works on some scanners but not others.  How is this code not working? Are you getting an error returned from GetCapability2?  Or is this function returning successfully, but you are not getting valid values?  Please explain with greater detail how your code is not working.
Travis Montgomery
Senior Sales Engineer
LEAD Logo
 
#10 Posted : Thursday, June 1, 2006 5:58:59 AM(UTC)
gofarrell

Groups: Registered
Posts: 11


On some scanners I get the error message "Method 'CapEnum' of object 'ILEADTwainCapability_D' failed.

On one brand new scanner (HP Officejet 4315 All-In-One), it works with the driver WIA-HP Officejet 3100 1.0 (32-32) but not with HP Officejet4300 Twain 1.0 (32-32).

Is there another way to get the DPI settings that would work on all Twain scanners?

 

 

I am using the following code.

 

Private Sub UpdateDPISettings()
    On Error GoTo UDPI_err
   
    Dim CapValue As Variant
    Dim CapValX As New LEADRasterVariant
    Dim CapValY As New LEADRasterVariant
    Dim sztext As String
    Dim nCount As Integer
    Dim TwainCap As New LEADTwainCapability_D
    Dim nRet As Integer
    Dim sLine As String
    Dim iRetInitTwain As Integer ' for init session only

    Set RasterTwain = New LEADRasterTwain_D
   
    RasterTwain.EnableMethodErrors = False
   
    If (RasterTwain.IsAvailable(hwnd) = True) Then
        iRetInitTwain = RasterTwain.InitSession(hwnd)
        If (iRetInitTwain <> 0) Then
            MsgBox "frmScan UpdateDPI Settings - Error Initializing Twain " & iRetInitTwain, vbExclamation
            GoTo UDPI_exit
        End If
        mbEnableTwain = True
    End If
   
    TwainCap.CapInfo.ConType = L_TWON_DONTCARE16
   
    TwainCap.CapInfo.Capability = L_ICAP_XRESOLUTION

    nRet = RasterTwain.GetCapability2(TwainCap, L_LTWAIN_CAPABILITY_GETVALUES)
   
    If nRet > 0 Then
        MsgBox "Get Capability Error " & TwainCap.CapOneValue.OneValCapValue.LongValue & " " & msVer
    Else
        nCount = TwainCap.CapEnum.EnumNumOfItems
        cboDPI.Clear
        If nCount > 0 Then
            For nCount = 0 To nCount - 1 Step 1
                sztext = TwainCap.CapEnum.EnumCapValue(nCount).FloatValue
                If Val(sztext) < 600 Then
                    cboDPI.AddItem sztext, nCount
                End If
            Next nCount
            cboDPI.ListIndex = 0
        End If
    End If
   
 
UDPI_exit:
   
    If iRetInitTwain = 0 Then
        MsgBox ("frmScan UpdateDPISettings End Session")
        RasterTwain.EndSession
    End If
    MsgBox ("frmScan UpdateDPISettings Exit Sub")
    Exit Sub
 
   
UDPI_err:

   Call ShowError("frmScan UpdateDPI Settings line=" & sLine)
   Resume Next
   GoTo UDPI_exit
End Sub

 
#11 Posted : Thursday, June 1, 2006 1:47:40 PM(UTC)

Travis  
Travis

Groups: Registered, Tech Support
Posts: 207

Was thanked: 3 time(s) in 3 post(s)

The error you are getting makes sense because you are assuming the capability will always be given as an Enumeration container.  This is not a correct assumption to make.  If you look in the Twain 1.9 specification (found at www.twain.org | Downloads) in chapter nine under ICAP_XRESOLUTION you'll see that Twain Spec allows for this capability to be returned as a TWON_ENUMERATION, TWON_RANGE, or TWON_ONEVALUE container.  You must check the TwainCap.CapInfo.ConType to determine what container the Twain Driver gave you.  Then access the appropriate container to retrieve the values. 
Travis Montgomery
Senior Sales Engineer
LEAD Logo
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.149 seconds.