' Utilizzare periferiche di acquisizione da codice Visual Basic - Listato 3
  '==========================================================================

  Friend Class NativeMethods

    'Acquisisce un'immagine in una DIB.
    'Al termine,rilasciare le risorse con TWAIN_FreeNative
    <DllImport("EZTW32.DLL")> _
    Friend Shared Function TWAIN_AcquireNative _
              (ByVal hwndApp As Integer, ByVal wPixTypes As Integer) As Integer
    End Function
 
    'Rilascia le risorse al termine dell'acquisizione
    <DllImport("EZTW32.DLL")> _
    Friend Shared Sub TWAIN_FreeNative(ByVal hDib As Integer)
    End Sub

    'Restituisce 1 se ok, 0 in caso di errore
    <DllImport("EZTW32.DLL")> _
    Friend Shared Function TWAIN_AcquireToClipboard _
               (ByVal hwndApp As Integer, ByVal wPixTypes As Integer) As Integer
    End Function

    'Scrive il riferimento di una DIB in un file .bmp
    'Restituisce 0 se OK, -1 se errore o annullamento dell'utente
    '-2 errore di apertura del file, -3 errore di creazione della DIB
    '-4 errore di creazione del file (disco probabilmente pieno)
    <DllImport("EZTW32.DLL")> _
    Friend Shared Function TWAIN_WriteNativeToFilename _
                       (ByVal hDib As Integer, ByVal sFIle As String) As Integer
    End Function

    'Scrive una DIB in un file .bmp
    'Restituisce gli stessi valori della precedente
    <DllImport("EZTW32.DLL")> _
    Friend Shared Function TWAIN_WriteNativeToFile _
                      (ByVal hdib As Integer, ByVal hFile As Integer) As Integer
    End Function

    'Restituisce 0 se OK, -1 se errore o annullamento dell'utente
    '-2 errore di apertura del file, -3 errore di creazione della DIB
    '-4 errore di creazione del file (disco probabilmente pieno)
    <DllImport("EZTW32.DLL")> _
    Friend Shared Function TWAIN_AcquireToFilename _
                    (ByVal hwndApp As Integer, ByVal sFIle As String) As Integer
    End Function

    'Restituisce 1 se OK, 0 in caso di errore
    <DllImport("EZTW32.DLL")> _
    Friend Shared Function TWAIN_SelectImageSource _
                                              (ByVal hWnd As Integer) As Integer
    End Function

    'Restituisce 1 se OK, 0 in caso di errore
    <DllImport("EZTW32.DLL")> _
    Friend Shared Function TWAIN_IsAvailable() As Integer
    End Function

    'Restituisce il numero della versione moltiplicato per 100
    <DllImport("EZTW32.DLL")> _
    Friend Shared Function TWAIN_EasyVersion() As Integer
    End Function

    'Ottiene la profondità in bit che può dipendere dal valore di PixelType
    'Si considera in bit per canale, ad es. a 24-bit RGB corrisponde 8
    'Restituisce 0 in caso di errore.
    <DllImport("EZTW32.DLL")> _
    Friend Shared Function TWAIN_GetBitDepth() As Integer
    End Function

    'Imposta la profondità dell'immagine
    <DllImport("EZTW32.DLL")> _
    Friend Shared Function TWAIN_SetBitDepth(ByVal nBits As Integer) As Integer
    End Function

    'Richiede alla sorgente il tipo di pixel attuale
    'Restituisce 0 in caso di errore
    <DllImport("EZTW32.DLL")> _
    Friend Shared Function TWAIN_GetPixelType() As Integer
    End Function

    'Cerca di impostare il tipo di pixel per l'acquisizione
    'Restituisce 0 in caso di errore
    <DllImport("EZTW32.DLL")> _
    Friend Shared Function TWAIN_SetCurrentPixelType _
                                          (ByVal nPixType As Integer) As Integer
    End Function

    'Ottiene la risoluzione orizzontale in DPI
    'Restituisce 0 in caso di errore
    <DllImport("EZTW32.DLL")> _
    Friend Shared Function TWAIN_GetCurrentResolution() As Double
    End Function

    'Imposta la risoluzione in DPI
    'Restituisce 0 in caso di errore
    <DllImport("EZTW32.DLL")> _
    Friend Shared Function TWAIN_SetCurrentResolution _
                                              (ByVal dRes As Double) As Integer
    End Function

    'Imposta il contrasto
    'Il valore accettato varia tra -1000 e 1000
    <DllImport("EZTW32.DLL")> _
    Friend Shared Function TWAIN_SetContrast(ByVal dCon As Double) As Integer
    End Function

    'Imposta la luminosità
    'Il valore accettato varia tra -1000 e 1000
    <DllImport("EZTW32.DLL")> _
    Friend Shared Function TWAIN_SetBrightness(ByVal dBri As Double) As Integer
    End Function

    Private Sub New()

    End Sub

  End Class