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 : Tuesday, August 8, 2006 11:44:19 AM(UTC)
deweyshuburte

Groups: Registered
Posts: 1


Hello,

We have an app written in VB 6 and LT 14. We can scan, set X & Y resolution, Show UI, tell if its a feeder or flatbed scanner. How can we tell if the device is a camera or a scanner? We do not want to check for X/Y resolution or feeder/flatbed capabilities if it is a camera.

Also, we do not understand the RasterTwain.QueryCapabilty command. Could you enclose a code snippet that demonstrates that function? We could not tell from the help file how it works.
Thanks!
 

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 : Thursday, August 10, 2006 12:19:15 PM(UTC)

Amin  
Amin

Groups: Manager, Tech Support
Posts: 367

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

Although scanners and cameras are the most common types of Twain devices, they are not necessarily the only types. Furthermore, the capabilities present in both types of devices overlap, meaning there could be many capabilities common to both.
You could make use of the fact that ICAP_UNITS is required by all types of sources, and that cameras almost always support only the PIXELS unit, while most if not all scanners support the INCHES unit.

I tried the following code with 4 different Twain drivers (1 camera and 3 scanners) and it worked. However, there's no guarantee it will always work, because you can never know how different vendors write their Twain drivers.

Sub CheckTwainDeviceType()
   Dim var As New LEADRasterVariant
   Dim TwainCap As New LEADTwainCapability_D ' or LEADTwainCapability
   Set RasTwain = New LEADRasterTwain_D ' or LEADRasterTwain
   RasTwain.InitSession Me.hWnd
   
   RasTwain.SelectSource
   TwainCap.CapInfo.ConType = L_TWON_ONEVALUE
   TwainCap.CapInfo.Capability = L_ICAP_UNITS
   TwainCap.EnableMethodErrors = False
   
   var.Type = VALUE_USHORT
   var.LongValue = L_TWUN_INCHES
   TwainCap.CapOneValue.OneValItemType = L_TWTY_UINT16
   TwainCap.CapOneValue.OneValCapValue = var
   RasTwain.EnableMethodErrors = False
   Dim nRet As Integer
   nRet = RasTwain.SetCapability2(TwainCap, L_LTWAIN_CAPABILITY_SET)
   If 0 = nRet Then 'success
      MsgBox "Most likely a scanner"
   Else
      MsgBox "Most likely a camera"
   End If
   Set TwainCap = Nothing
   Set var = Nothing
   RasTwain.EndSession
End Sub


About the Query Capability method, here's a code sample that uses it. If you want to perform the same check using it, the camera will have TwainCap.CapEnum.EnumNumOfItems equal to 1, and TwainCap.CapEnum.EnumCapValue(0).LongValue equal to 5 (L_TWUN_PIXELS):

Sub TwainQueryCap()
   Dim var As New LEADRasterVariant
   Dim TwainCap As New LEADTwainCapability_D ' or LEADTwainCapability
   Set RasTwain = New LEADRasterTwain_D ' or LEADRasterTwain
   RasTwain.InitSession Me.hWnd
   
   RasTwain.SelectSource
   TwainCap.CapInfo.ConType = L_TWON_ENUMERATION
   TwainCap.CapInfo.Capability = L_ICAP_UNITS
   TwainCap.EnableMethodErrors = False
   
   RasTwain.EnableMethodErrors = False
   Dim nRet As Integer
   nRet = RasTwain.QueryCapability2(TwainCap)
   Dim msg As String, i As Integer
   If 0 = nRet Then 'success
      msg = "Num of values = " & TwainCap.CapEnum.EnumNumOfItems & vbCrLf
      For i = 0 To TwainCap.CapEnum.EnumNumOfItems - 1
         msg = msg & "value " & i & " is " & TwainCap.CapEnum.EnumCapValue(i).LongValue & vbCrLf
      Next
      MsgBox msg
   End If
   Set TwainCap = Nothing
   Set var = Nothing
   RasTwain.EndSession
End Sub

Amin Dodin

Senior Support Engineer
LEAD Technologies, Inc.
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.129 seconds.