0% found this document useful (0 votes)
175 views3 pages

Proyecto de Digitalizacion en Visual

This document summarizes how to retrieve images from a scanner or camera using Bytescout Scan SDK for .NET in Visual Basic.NET. It demonstrates transferring images from TWAIN and WIA compatible devices by handling the TransferFinished event, which returns an array of image objects. The code samples show how to display the images in tabs by adding them to PictureBoxes and setting the tab text. It also provides an example of saving scanned images to files in a specified folder.

Uploaded by

Jasson Oliveros
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
175 views3 pages

Proyecto de Digitalizacion en Visual

This document summarizes how to retrieve images from a scanner or camera using Bytescout Scan SDK for .NET in Visual Basic.NET. It demonstrates transferring images from TWAIN and WIA compatible devices by handling the TransferFinished event, which returns an array of image objects. The code samples show how to display the images in tabs by adding them to PictureBoxes and setting the tab text. It also provides an example of saving scanned images to files in a specified folder.

Uploaded by

Jasson Oliveros
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

How to retrieve images from scanner or camera

(TWAIN or WIA compatible) with Bytescout Scan


SDK for .NET in Visual Basic.NET (VB.NET)
This sample code demonstrates how to transfer images from scanner or web-camera TWAIN
and WIA devices with Bytescout Scan SDK for .NET. Full sample code is included into the SDK.
Screenshot of VB.NET test application:

Imports
Imports
Imports
Imports

System
System.Collections
System.ComponentModel
System.Data

Imports
Imports
Imports
Imports

System.Drawing
System.Text
System.Windows.Forms
System.Drawing.Imaging

Imports Bytescout.Scan
Imports System.IO
Public Class Form1
' Starts Asynchronous scan into images. When scan is finished then
scan_TransferFinished event is called and array with images objects is
passed into this event
Private Sub btnScanToImagesAsync_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnScanToImagesAsync.Click
' create new Scan object
Dim scan As New Scan()

' set Scan object to save images into images array (will be
passed as a paramtere in scan_TransferFinished event
scan.SaveTo = SaveTo.ImageObject
AddHandler scan.TransferFinished, AddressOf
scan_TransferFinished
' set function for scan finished event to indicate when image
transfer is finished
' see scan_TransferFinished event below
' acquire images
scan.AcquireImagesAsync(Me.Handle)
End Sub
' this event captures scanned images and fills images into tabs
' you can also iterate through scannedImages array to get each
image as an Image object instead
Private Sub scan_TransferFinished(ByVal sender As Scan, ByVal
scannedImages As ArrayList)
FillTabsWithImages(scannedImages)
End Sub
' this function puts retrieved images objects into tabs on the

form

Private Sub FillTabsWithImages(ByVal images As ArrayList)


tabControl1.TabPages.Clear()
For i As Integer = 0 To images.Count - 1
Dim page As New TabPage()
Dim pb As New PictureBox()
pb.Dock = DockStyle.Fill
pb.SizeMode = PictureBoxSizeMode.Zoom
If TypeOf images(i) Is Image Then
page.Text = "Image " + (i + 1).ToString()
pb.Image = DirectCast(images(i), Image)
Else

page.Text = DirectCast(images(i), String)


pb.Image = Image.FromFile(DirectCast(images(i),

String))

End If
page.Controls.Add(pb)
tabControl1.TabPages.Add(page)

Next
End Sub

' acquire images into files automatically saved into the given
folder with given image format and filename
Private Sub btnScanToFilesAsync_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnScanToFilesAsync.Click
' create new Scan object
Dim scan As New Scan()
' set SDK to save images into files

scan.SaveTo = SaveTo.File
' scan.FileNamingTemplate = "ScannedImage_{0:D2}"; // you can
set output filename template
' set output format as JPG image format
scan.OutputFormat = OutputFormat.JPEG
AddHandler scan.TransferFinished, AddressOf
scan_TransferFinished
' you can set output folder as well, by default output folder
is the same where executable .exe is running
'scan.OutputFolder = Path.GetTempPath();
' assign the event to indicate when image transfer is finished
' acquire images
scan.AcquireImagesAsync(Me.Handle)
End Sub
' displays ready-to-use options dialog for the scan SDK
Private Sub btnOptions_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnOptions.Click
Scan.ShowOptionsDialog(New Scan())
End Sub
End Class

You might also like