Save scanned images to multipage tiff files
IMPORTANT:
On a 64 bit operating system, make sure your TWAIN scan driver
supports 64 bit when using a target platform of AnyCpu or x64!
The following explains how to save scanned images into multipag tiff format. When using an automatic document feeder (ADF) to continuously scan images, each scanned image can be saved in separate tiff images or saved as separate pages in single multipage tiff image.
Example Code
ADF scanned images are continuously added to the last page of a multipage tiff file and saved in G4 format.
Note: In order to make these examples easier to understand, only a minimum amount of code is used. For more robust scan applications, please refer to the Scan Interface properties and methods and also refer to the various scan sample projects included in the directory where the ImageKit X is installed.
[Visual Basic.NET]
'Click Button1 to execute
scan
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
'Suppress
the manufacturer's UI and scan from the ADF
(single-sided)
ImageKit1.Scan.UserInterface =
Newtone.ImageKit.ScanUserInterface.Suppress
ImageKit1.Scan.Mode =
Newtone.ImageKit.ScanMode.ADFOneSide
'Because
we are saving in G4 compression, the scanned images must be 1 bit
color
ImageKit1.Scan.PixelType =
Newtone.ImageKit.ScanPixelType.BW
ImageKit1.Scan.BitDepth = 1
'Tiff
filename
'If the
file already exists, the pages will be appended to the end of the
existing file.
ImageKit1.File.FileName =
"multi_tiff.tif"
Dim ret As Boolean =
ImageKit1.Scan.Execute()
If Not ret Then
MessageBox.Show("The
scan failed. ErrorStatus = " +
ImageKit1.ErrorStatus.ToString())
End If
End Sub
'In the AfterScan event of the
ImageKit control, add the captured image to the final page and save
it.
Private Sub ImageKit1_AfterScan(ByVal sender As Object, ByVal e As
Newtone.ImageKit.AfterScanEventArgs) Handles
ImageKit1.AfterScan
ImageKit1.Image = e.Bitmap1
'Save as
multipage tiff
ImageKit1.File.AppendTiffImage(SaveFileType.SaveTIFFGroup4,
Nothing)
End Sub
[Visual C#.NET]
//Click
Button1 to execute scan
private void button1_Click(object sender, EventArgs e)
{
//Suppress the
manufacturer's UI and scan from the ADF (single-sided)
ImageKit1.Scan.UserInterface =
Newtone.ImageKit.ScanUserInterface.Suppress;lType.BW;
ImageKit1.Scan.Mode =
Newtone.ImageKit.ScanMode.ADFOneSide;
//Because we are
saving in G4 compression, the scanned images must be 1 bit
color
ImageKit1.Scan.PixelType =
Newtone.ImageKit.ScanPixelType.BW;
ImageKit1.Scan.BitDepth = 1;
//Tiff
filename
//If the file
already exists, the pages will be appended to the end of the
existing file.
ImageKit1.File.FileName =
"multi_tiff.tif"
bool ret =
ImageKit1.Scan.Execute();
if (!ret)
{
MessageBox.Show("The
scan failed. ErrorStauts = " +
ImageKit1.ErrorStatus.ToString());
}
}
//In the AfterScan event of the ImageKit
control, add the captured image to the final page and save
it.
private void imageKit1_AfterScan(object sender,
Newtone.ImageKit.AfterScanEventArgs e)
{
ImageKit1.Image = e.Bitmap1;
//Save as
multipage tiff
ImageKit1.File.AppendTiffImage(SaveFileType.SaveTIFFGroup4,
null);
}
Relevant Properties
ImageKit.Scan.UserInterface
ImageKit.Scan.Mode
ImageKit.Scan.PixelType
ImageKit.Scan.BitDepth
Relevant Methods
ImageKit.Scan.Execute
ImageKit.File.AppendTiffImage
Relevant Events
For other scan-related settings, see the other scan properties
below and refer to the scan sample projects
ImageKit.Scan
Members