Visualizzazione dei risultati da 1 a 2 su 2

Discussione: Utilizzo modulo adf

  1. #1
    Utente di HTML.it
    Registrato dal
    May 2010
    Messaggi
    1

    Utilizzo modulo adf

    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

  2. #2
    Moderatore di Programmazione L'avatar di alka
    Registrato dal
    Oct 2001
    residenza
    Reggio Emilia
    Messaggi
    24,472

    Moderazione

    C'è un Regolamento da leggere e rispettare nella partecipazione a quest'area del forum.

    In particolare, occorre indicare il linguaggio nel titolo, e formattare il codice usando l'apposito tag CODE.

    Fornisci le informazioni mancanti e provvedo a correggere, mentre per il futuro pensaci tu.
    MARCO BREVEGLIERI
    Software and Web Developer, Teacher and Consultant

    Home | Blog | Delphi Podcast | Twitch | Altro...

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.