Sto tentando di utilizzare il modulo ADF tramite WIA.
Ho trovato in internet il codice per utilizzare l'interfaccia WIA ma non gestisce il modulo adf dello scanner epson expression 1680 pro, continua sempre a utilizzare il piano.
Sono obbligato a passare all'uso dei driver twain??? Avevo tentato ma non ci capisco granchè.
Qualcuno sa come? Grazie in anticipo
codice:
'Choose Scanner
Dim class1 As New CommonDialogClass()
Dim MyDevice As Device = class1.ShowSelectDevice(WiaDeviceType.UnspecifiedDeviceType, True, False)
If MyDevice IsNot Nothing Then
Me.DeviceID = MyDevice.DeviceID
Else
'no scanner chosen
Return
End If
Dim WiaCommonDialog As WIA.CommonDialog = New CommonDialogClass()
Dim hasMorePages As Boolean = True
Dim x As Integer = 0
Dim numPages As Integer = 0
While hasMorePages
'Create DeviceManager
Dim manager As DeviceManager = New DeviceManagerClass()
Dim WiaDev As Device = Nothing
For Each info As DeviceInfo In manager.DeviceInfos
If info.DeviceID = Me.DeviceID Then
Dim infoprop As WIA.Properties = Nothing
infoprop = info.Properties
'connect to scanner
WiaDev = info.Connect()
Exit For
End If
Next
'Start Scan
Dim img As WIA.ImageFile = Nothing
Dim Item As WIA.Item = TryCast(WiaDev.Items(1), WIA.Item)
Try
img = DirectCast(WiaCommonDialog.ShowTransfer(Item, wiaFormatTIFF, False), ImageFile)
'process image:
'one would do image processing here
'
'Save to file
Dim varImageFileName As String = "c:\test" & x.ToString() & ".tiff"
If File.Exists(varImageFileName) Then
'file exists, delete it
File.Delete(varImageFileName)
End If
img.SaveFile(varImageFileName)
numPages += 1
img = Nothing
Catch ex As Exception
MessageBox.Show("Error: " & ex.Message)
Finally
Item = Nothing
'determine if there are any more pages waiting
Dim documentHandlingSelect As WIA.Property = Nothing
Dim documentHandlingStatus As WIA.Property = Nothing
For Each prop As WIA.Property In WiaDev.Properties
If prop.PropertyID = WIA_PROPERTIES.WIA_DPS_DOCUMENT_HANDLING_SELECT Then
documentHandlingSelect = prop
End If
If prop.PropertyID = WIA_PROPERTIES.WIA_DPS_DOCUMENT_HANDLING_STATUS Then
documentHandlingStatus = prop
End If
Next
hasMorePages = False
'assume there are no more pages
If documentHandlingSelect IsNot Nothing Then
'may not exist on flatbed scanner but required for feeder
'check for document feeder
'If (WIA_DPS_DOCUMENT_HANDLING_SELECT.FEEDER <> 0) Then
' hasMorePages = WIA_DPS_DOCUMENT_HANDLING_STATUS.FEED_READY
'End If
If (Convert.ToUInt32(documentHandlingSelect.Value) And WIA_DPS_DOCUMENT_HANDLING_SELECT.FEEDER) <> 0 Then
hasMorePages = ((Convert.ToUInt32(documentHandlingStatus.Value) And WIA_DPS_DOCUMENT_HANDLING_STATUS.FEED_READY) <> 0)
End If
End If
x += 1
End Try
End While