This event is generated after an image is scanned with the scan device.

[Visual Basic]Public Event AfterScan As AfterScanEventHandler
[C#]public event AfterScanEventHandler AfterScan;

Event Data

The event handler receives arguments of type AfterScanEventArgs

Explanation

The AfterScanevent is generated after an image is scanned with the scan device. Information about the actual image data transfered in this event can be referenced through the AfterScanEventArgs arguments.

When the Dispose arguement is true, the scanned image data (Bitmap1 and Bitmap2) is disposed after this event fires so if you want to use this image data in any way, you must make a copy of the scanned image in the memory or save it in an image file. When the Dispose argument is false the scanned image data (Bitmap1 and Bitmap2) will not be disposed.

(1) When using native transfer or when using memory transfer without compression:

If the scanned image is 1, 4, 8, or 24 bits then the image is set in Bitmap1 and Bitmap2 will be null (Nothing in Visual Basic). If the scanned image is 12, 14, or 16 bit grayscale or 36, 42, or 48 bit color then the image will be set in Bitmap2 and the Bitmap2 image data will be converted to 8 bit grayscale or 24 bit color and that will be set in Bitmap1. In this case, if the Bitmap1 memory cannot be allocated it will be null (Nothing in Visual Basic)

(2) When using memory transfer with compression:

The scanned image is set into RawData. Both Bitmap1 and Bitmap2 will be null (Nothing in Visual Basic)

(3) When using file transfer:

Both Bitmap1 and Bitmap2 will be null (Nothing in Visual Basic). The file will be saved in the location specified by FileName

When Scan.UserInterface property is set to Suppress and the Scan.Unit property is Pixel, there are cases in which the resolution of Bitmap1 and Bitmap2 will be 1. To cancel scanning set the Cancel property to True.

Example

The following code displays the image scanned.

[Visual Basic.NET]
Private Scan As Newtone.ImageKit.Scan

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Scan = New Newtone.ImageKit.Scan
    ' Events
    AddHandler Scan.BeforeScan, AddressOf Scan_BeforeScan
    AddHandler Scan.Scanning, AddressOf Scan_Scanning
    AddHandler Scan.AfterScan, AddressOf Scan_AfterScan
    ' Initialization
    Scan.Initialize(Me.Handle, 1, 0, "ImageKit.NET Sample", "NEWTONE Corp.", "ImageKit", "ImageKit.NET")
End Sub

Private Sub Scan_AfterScan(ByVal sender As Object, ByVal e As Newtone.ImageKit.AfterScanEventArgs)
    If e.Bitmap1 Is Nothing Then Exit Sub

    If Not (pictureBox1.Image Is Nothing) Then
         PictureBox1.Image.Dispose()
    End If
    PictureBox1.Image = e.Bitmap1.Clone()
End Sub

[Visual C#.NET]
private Newtone.ImageKit.Scan scan;

private void Form1_Load(object sender, System.EventArgs e)
{
    scan = new Newtone.ImageKit.Scan();
    // Events
    scan.BeforeScan += new Newtone.ImageKit.BeforeScanEventHandler(scan_BeforeScan);
    scan.Scanning += new Newtone.ImageKit.ProgressEventHandler(scan_Scanning);
    scan.AfterScan += new Newtone.ImageKit.AfterScanEventHandler(scan_AfterScan);
    // Initialization
    scan.Initialize(this.Handle, 1, 0, "ImageKit.NET Sample", "NEWTONE Corp.", "ImageKit", "ImageKit.NET");
}

private void scan_AfterScan(object sender, Newtone.ImageKit.AfterScanEventArgs e)
{
    if (e.Bitmap1 == null) return;

    if (pictureBox1.Image != null)
        pictureBox1.Image.Dispose();

    pictureBox1.Image = (Image)e.Bitmap1.Clone();
}

See Also

Scan Class | Scan Members


The ImageKit.NET3 is created by Newtone Corporation