Acquire image from TWAIN device and read barcodes

Example requests & Code samples for GdPicture Toolkits.
Post Reply
User avatar
Site Admin
Posts: 5642
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Acquire image from TWAIN device and read barcodes

Post by 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: ... 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
                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))

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

            Call oGdPictureImaging.TwainCloseSource()
            MsgBox("Done !")
            MsgBox("can't open default source, twain state is: " & oGdPictureImaging.TwainGetState.ToString)
        End If
    End Sub

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests