Home | About us | Overview | Software - Download | Evaluate | Order | Support | Contact | F.A.Q. | Documentations | Blog | Newsletter
Loading...

Acquire image from TWAIN device and read barcodes

Example requests & Code samples for GdPicture.NET.

Acquire image from TWAIN device and read barcodes

Postby Loïc » Tue May 05, 2009 2:14 pm

Note: This sample demonstrate a way to use the barcode detection capability of a TWAIN scanner. To work, your scanner must implement a built-in barcode recognition engine.

To your scanner doesn't have barcode engine, we suggest to use our GdPicture 1D Barcode Recognition Plugin: http://www.gdpicture.com/products/plugi ... nition.php



Code: Select all
   Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command4.Click
        Dim ImageID As Integer
        Dim oGdPictureImaging As New GdPicture.GdPictureImaging

        oGdPictureImaging.SetLicenseNumber("XXX") 'Replace XXX by a valid demo or commercial license KEY
        If oGdPictureImaging.TwainOpenDefaultSource(Me.Handle) Then
            If oGdPictureImaging.TwainIsBarcodeDetectionAvailable Then
                oGdPictureImaging.TwainSetBarcodeDetection(True)
                ImageID = oGdPictureImaging.TwainAcquireToGdPictureImage(Me.Handle)
                If ImageID <> 0 Then
                    Dim BarCodeCount As Integer = oGdPictureImaging.TwainBarCodeGetCount

                    MsgBox(Str(BarCodeCount) + " barcode have been found in the scanned image")

                    For i As Integer = 1 To BarCodeCount
                        MsgBox("Type of barcode " + Str(i) + " is: " + oGdPictureImaging.TwainBarCodeGetType(i).ToString)
                        MsgBox("Value of barcode " + Str(i) + " is: " + oGdPictureImaging.TwainBarCodeGetValue(i))
                    Next

                    Call oGdPictureImaging.ReleaseGdPictureImage(ImageID)
                End If
            Else
                MsgBox("Error: Barcode detection is not available on this scanner")
            End If

            Call oGdPictureImaging.TwainCloseSource()
            MsgBox("Done !")
        Else
            MsgBox("can't open default source, twain state is: " & oGdPictureImaging.TwainGetState.ToString)
        End If
    End Sub
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4230
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Return to Example requests & Code samples

Who is online

Users browsing this forum: No registered users and 0 guests