Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Module scanning
- Public Function scanImage() As Byte()
- Dim fileScanned As Integer = 0
- Dim filepath As String = String.Format("{0}\RXImage.png", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData))
- EZTwain.SetAppTitle("Script Assist 9")
- Call EZTwain.SetVendorKey("RS Software", -469019609)
- Call EZTwain.SetHideUI(False)
- Call EZTwain.SetFileAppendFlag(False)
- Call EZTwain.SetMultiTransfer(False)
- If EZTwain.OpenDefaultSource() Then
- Call EZTwain.SetBlankPageMode(False)
- fileScanned = EZTwain.AcquireToFilename(System.IntPtr.Zero, filepath)
- If EZTwain.LastErrorCode <> 0 Then
- If EZTwain.LastErrorCode = EZTwain.EZTEC_USER_CANCEL Then
- Throw New Exception("Scan Was Cancelled")
- End If
- End If
- End If
- Call EZTwain.ReportLastError("While trying to scan")
- Call EZTwain.CloseSource()
- 'EZTwain returns 0 on filescan success
- If fileScanned = 0 Then
- Try
- Using fs As System.IO.FileStream = New System.IO.FileStream(filepath, IO.FileMode.Open, IO.FileAccess.Read)
- Dim imagedata(fs.Length) As Byte
- fs.Read(imagedata, 0, System.Convert.ToInt32(fs.Length))
- fs.Close()
- Return imagedata
- End Using
- Catch ex As Exception
- DevExpress.XtraEditors.XtraMessageBox.Show("There was an error with converting the image for the database")
- Clipboard.SetText(ex.ToString)
- Return Nothing
- End Try
- Else
- Return Nothing
- End If
- End Function
- End Module
Add Comment
Please, Sign In to add comment