I writing a VB6 application (we are migrating to .NET) to scann images for ID barcodes and roughly 1 out of 10 images gives either the above error or "-2147467261 Attempted to read or write protected memory. Possibly indicated corrupted memory..."
Call IsLocked(RasterSupportType_Barcodes1D)
Set m_oBarCodeEngine = New BarcodeEngine
' Initialize linear barcodes
Call m_oBarCodeEngine.Startup(BarcodeMajorTypeFlags_Barcodes1d)
Set m_oImage = m_RASCodecs.Load_12(sFilename)
If m_oBarCodeEngine Is Nothing Then
Err.Raise 1001, "", "Barcode engine has not been initialised yet"
End If
Set oBarCode1D = New Barcode1d
Set oBarCodePDF = New BarcodeReadPdf
Set oBarColor = New BarcodeColor
Set oRect = New Rectangle
oRect.Height = 0
oRect.Width = 0
oRect.X = 0
oRect.Y = 0
oBarCode1D.Direction = BarcodeDirectionFlags_LeftToRight Or BarcodeDirectionFlags_Horizontal Or BarcodeDirectionFlags_TopToBottom Or BarcodeDirectionFlags_BottomToTop
oBarCode1D.ErrorCheck = True
oBarCode1D.Granularity = 9
oBarCode1D.WhiteLines = 3
oBarCode1D.MinimumLength = 1
oBarCode1D.MaximumLength = 255
oBarCode1D.StandardFlags = Barcode1dStandardFlags_Barcode1dNormal
m_oBarCodeEngine.ReadBarcode1dSearchType = Barcode1dSearchTypeFlags_Barcode1dReadAnyType
Call m_oBarCodeEngine.Read(m_oImage, oRect, _
BarcodeUnit_ScanlinesPerPixels, _
BarcodeReadFlags_None, _
10, oBarCode1D, oBarCodePDF, oBarColor)
Set oBarcodes = New Collection
For X = 1 To m_oBarCodeEngine.BarcodeDataCount
Set oBarCode = New cBarcode
Set oBarCodeData = m_oBarCodeEngine.BarcodeData.Item(X - 1)
sBarCode = ""
For Y = 1 To oBarCodeData.DataCount
sBarCode = sBarCode & Chr(oBarCodeData.data.Item(Y - 1))
Next Y
oBarCode.BarcodeType = CStr(oBarCodeData.SearchType)
oBarCode.BarcodeData = sBarCode
Call oBarcodes.Add(oBarCode, CStr(X))
Next X
Call m_oImage.Dispose
Set m_oImage = Nothing