Acquire image from TWAIN device and read barcodes

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

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: 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

Gabriela
Posts: 415
Joined: Wed Nov 22, 2017 9:52 am

Re: Acquire image from TWAIN device and read barcodes

Post by Gabriela » Fri Mar 29, 2019 10:29 pm

Kind regards,

Gabriela
GdPicture Team

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest