detect document size after scanning

Questions, comments and suggestions concerning VintaSoft Twain .NET SDK.

Moderator: Alex

Post Reply
placentiusz
Posts: 2
Joined: Wed Jul 29, 2009 10:26 pm

detect document size after scanning

Post by placentiusz »

It is possible to detect document size after scanning or durring scan?
I use microtek ScanMaker 5950 Twain 1.9 scanner.
Alex
Site Admin
Posts: 2305
Joined: Thu Jul 10, 2008 2:21 pm

Re: detect document size after scanning

Post by Alex »

Hello,

What do you mean as "detect document size after scanning"? Do you want to detect document border automatically? If yes, you can use the DetectImageBorder method.

Here is a snippet of code:

Code: Select all

Imports VintaSoft.Twain
...
Private Sub ProcessImageButton_Click(ByVal sender As System.Object, _
                 ByVal e As System.EventArgs) Handles BProcessImage.Click
    ...
    Try
        VSTwain1.DespeckleImage(imageNum, 8, 25, 30, 400)
        VSTwain1.DeskewImage(imageNum,BorderColor.AutoDetect, 5, 5)
        VSTwain1.DetectImageBorder(imageNum, 5, 5, 5)
        If Not PictureBox1.Image Is Nothing Then
            PictureBox1.Image.Dispose()
            PictureBox1.Image = Nothing
        End If
        LabelImageNum.Text = "Image " + CStr(imageNum) + _
                         " (" + CStr(VSTwain1.GetImageWidth(imageNum)) + _
                         " x " + CStr(VSTwain1.GetImageHeight(imageNum)) + _
                         " x " + CStr(VSTwain1.GetImageBPP(imageNum)) + " bpp)"
        PictureBox1.Image = VSTwain1.GetImage(imageNum)
    Catch ex As ImagingException
        MsgBox ex.Message
    End Try
    ...
End Sub

Private Sub VSTwain1_ProgressChanged(ByVal sender As Object, _
                       ByVal e As VintaSoft.Twain.ProgressChangedEventArgs) _
                       Handles VSTwain1.ProgressChanged
    Select Case e.Action
        Case Action.Deskew
            txtAction.Text = "Deskewing..."
        Case Action.Despecle
             txtAction.Text = "Despeckling..."
        Case Action.BorderDetection
            txtAction.Text = "Border detecting..."
        Case Action.Rotation
            txtAction.Text = "Rotating..."
        Case Action.ImageScan
            txtAction.Text = "Image scan..."
    End Select
    progressBar1.Value = e.PercentComplete
    e.Interrupt = bFinishFlag
End Sub
...
Please read more info in the documentation.

Best regards, Alexander
Post Reply