Unable to detect barcodes the second time....

Barcode SDK/ActiveX related topics

Unable to detect barcodes the second time....

Postby snackboy » Wed Jul 20, 2005 1:43 pm


I am using the "trial" version of the BlackIce Barcode SDK, and having a problem when attempting to detect barcodes on a second page, or the same page after successfully detecting the barcodes the first time thru the code.

A listbox contains a list of tif file names. When the user clicks on the item, the barcode information (if available) is processed. When I click the first time, barcode information (2 barcodes) is processed perfectly. The second time I click on the image, the system tells me there is only 1 barcode to process, but then the message displays that it is unable to process the code. The third time I click on the same image, No barcodes are found.

I am probably doing something fundementally wrong, but I am following the example application. Anyone's help would be greatly appreciated. [see code below]


Update: I believe the issue is with the way the DIB is stored in DIBDisp object. The object seems to be retaining the first hDIB number even after explicitly setting it to zero. How do I set this value to 0?

Private Sub lstScannedPages_Click()
Dim blkTiff As Object
Dim strFilename As String
Dim intBitMap As Long
Dim intReturn As Long
Dim intRetValue As Integer
Dim intBarcodeCount As Integer
Dim intErrCode As Integer
Dim intloop As Integer
Dim blnOK As Boolean
Dim intTopX As Integer
Dim intTopY As Integer
Dim intBottomX As Integer
Dim intBottomY As Integer
Dim dblOrientation As Double
Dim intBarNumber As Integer
Dim strValue As String
Dim strType As String
Dim sngScore As Single

intTopX = 0
intTopY = 0
intBottomX = 0
intBottomY = 0
intBitMap = 0

bidImage.hDib = 0
bidImage.DropDIB bidImage.hDib

If lstScannedPages.ListIndex > -1 Then
strFilename = "c:\admissions\" + lstScannedPages.List(lstScannedPages.ListIndex)
Set blkTiff = CreateObject("BITIFF.BITiffCtrl.1")
intBitMap = blkTiff.LoadTiffIntoDIB(strFilename, 0, False)
Set blkTiff = Nothing
bidImage.hDib = intBitMap

intReturn = bibBarCodeDetect.DetectBarCodePositions(intBitMap, 3, 10, 2.5, 3.8, 10, 20, intBarcodeCount, intErrCode)
If intBarcodeCount > 0 Then
lblBarCodeCount.Caption = "Found " + Format(intBarcodeCount) + IIf(intBarcodeCount = 1, " barcode", " barcodes")
For intloop = 0 To intBarcodeCount - 1
blnOK = bibBarCodeDetect.GetBarCodePositionStructValues(intReturn, intloop, intTopX, intTopY, intBottomX, intBottomY, dblOrientation, intBarNumber)
If blnOK Then
bibBarCodeDetect.RectLeftTopX = intTopX
bibBarCodeDetect.RectLeftTopY = intTopY
bibBarCodeDetect.RectHorizontalSize = intBottomX - intTopX + 1
bibBarCodeDetect.RectVerticalSize = intBottomY - intTopY + 1

intRetValue = bibBarCodeDetect.AutomaticReadHorVerBarCode(intBitMap, strType, strValue, sngScore)
If intRetValue = 0 Then
MsgBox Format(intloop) + ".:" + vbCrLf + "Decoded barcode type : " + strType + vbCrLf + "Decoded barcode value : " + strValue + vbCrLf
MsgBox "Cannot detect barcode type, or an error occured!", vbOKOnly + vbExclamation, "Barcode Sample"
End If
MsgBox "Cannot get barcode properties from ActiveX control!", vbOKOnly + vbExclamation, "Barcode Sample"
End If
Next intloop
bibBarCodeDetect.FreeBarCodePositionStruct (intReturn)
bidImage.DropDIB bidImage.hDib
bidImage.hDib = 0
lblBarCodeCount.Caption = "No barcodes were found."
End If

End If

End Sub
Posts: 7
Joined: Wed Jul 20, 2005 1:31 pm
Location: Dickinson College

In the dark....

Postby snackboy » Wed Jul 20, 2005 2:26 pm

LoadTiffIntoDIB(FileName,0,False) always returns the same value after the first time thru.

Posts: 7
Joined: Wed Jul 20, 2005 1:31 pm
Location: Dickinson College

Figured it out....

Postby snackboy » Wed Jul 20, 2005 3:46 pm

I needed to reset the .Rect....properties on the barcode control. After a read, they retain there values (?) thus the second time around the search rectangle was already a barcode. Makes sense now that I think about it.

Posts: 7
Joined: Wed Jul 20, 2005 1:31 pm
Location: Dickinson College

Return to Barcode SDK/ActiveX

Who is online

Users browsing this forum: No registered users and 0 guests