|
|
 |
|
 |
 |
|
BarcodeDecoder Methods |
|
|
AboutBox Method
Opens an About window.
Syntax
object.AboutBox()
Return Value
No return value.
|
DecodeFile Method
Decodes barcodes in the specified image file.
Syntax
object.DecodeFile(FileName)
Parameters
| FileName | A string defining the file name. |
Return Value
Integer. Returns the number of decoded barcodes.
Example
[Script]
var dec = new ActiveXObject("BarcodeReader.BarcodeDecoder");
var objBarcode;
dec.DecodeFile("c:\\barcodes.jpg");
for (var i=0; i < dec.Barcodes.length; i++)
{
objBarcode = dec.Barcodes.item(i);
alert(objBarcode.Text);
}
[Visual Basic]
Dim dec As Object
Set dec = CreateObject("BarcodeReader.BarcodeDecoder")
dec.DecodeFile ("c:\barcodes.jpg")
For i = 0 To dec.Barcodes.length - 1
Dim bc As Barcode
Set bc = dec.Barcodes.Item(i)
MsgBox bc.Text
Next i
Set dec = Nothing
[C/C++]
//creates the barcode decoder object
CComPtr<IBarcodeDecoder> pIBarcodeDecoder;
HRESULT hr = pIBarcodeDecoder.CoCreateInstance(
_T("BarcodeReader.BarcodeDecoder") );
_ASSERTE( SUCCEEDED(hr) );
hr = pIBarcodeDecoder->DecodeFile( _bstr_t("c:\\barcodes.jpg") );
_ASSERTE( SUCCEEDED(hr) );
|
DecodeFileRect Method
Similar to the DecodeFile method, but searches only a certain part of the image defined by the parameters x, y, width, height.
Syntax
object.DecodeFileRect(FileName, x, y, width, height)
Parameters
| FileName | A string defining the file name. |
| x | An integer value that defines the X coordinate of scanning zone. |
| y | An integer value that defines the Y coordinate of scanning zone. |
| width | An integer that defines the width of scanning zone. |
| height | An integer that defines the height scanning zone. |
Return Value
Integer. Returns the number of decoded barcodes.
|
DecodeStream Method
Similar to the DecodeFile method, but a file in the form of a data stream is passed as a parameter.
Everything that is contained in the image file is passed as a data stream.
Syntax
object.DecodeStream(FileStream)
Parameters
| FileStream | A Variant that contains a safe array of Bytes. |
Return Value
Integer. Returns the number of decoded barcodes.
Remarks
This method is convenient when there is no need to save the barcode image to a file, for instance, while decoding barcodes from some video capture device.
|
DecodeStreamRect Method
Similar to the DecodeStream method, but searches only a certain part of the image defined by the parameters x, y, width, height.
Syntax
object.DecodeStreamRect(FileStream, x, y, width, height)
Parameters
| FileStream | A Variant that contains a safe array of Bytes. |
| x | An integer value that defines the X coordinate of scanning zone. |
| y | An integer value that defines the Y coordinate of scanning zone. |
| width | An integer that defines the width of scanning zone. |
| height | An integer that defines the height scanning zone. |
Return Value
Integer. Returns the number of decoded barcodes.
|
DecodeGrayMap Method
This method finds barcodes in a raw gray map. It is the fastest method as compared to the other methods because no additional image transformations are performed in this case.
Syntax
object.DecodeGrayMap(GrayMap, GrayMapWidth, GrayMapHeight)
Parameters
| GrayMap | A Variant that contains a safe array of Bytes. |
| GrayMapWidth | Gray map width. |
| GrayMapHeight | Gray map height. |
Return Value
Integer. Returns the number of decoded barcodes.
Remarks
A gray map is a byte matrix. Each byte has the value from 0 to 255 and represents one image pixel.
0 means a black pixel, 255 means a white pixel.
The matrix is passed to the DecodeGrayMap method as a one-dimensional array. The first upper line of the image is sent first, then comes the second line and so on.
See the picture below for explanation.
Example
[C/C++]
const BYTE pgm[6300] = {
0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0x0,0x0, //...
};
//creates the barcode decoder object
CComPtr<IBarcodeDecoder> pIBarcodeDecoder;
HRESULT hr = pIBarcodeDecoder.CoCreateInstance(
_T("BarcodeReader.BarcodeDecoder") );
_ASSERTE( SUCCEEDED(hr) );
//creates the safe array
CComVariant var;
var.vt = VT_ARRAY | VT_UI1;
var.parray = SafeArrayCreateVector( VT_UI1, 0, sizeof(pgm) );
_ASSERTE( var.parray );
//locks the safe array
BYTE* pSaBuf=NULL;
if( SUCCEEDED(SafeArrayAccessData(var.parray, (void HUGEP**)&pSaBuf)) )
{
//copy the image into the safe array
memcpy( pSaBuf, pgm, sizeof(pgm) );
//unlock safe array
SafeArrayUnaccessData( var.parray );
}
hr = pIBarcodeDecoder->DecodeGrayMap( var, 105, 60 );
|
DecodeGrayMapRect Method
Similar to the DecodeGrayMap method, but searches only a certain part of the image defined by the parameters x, y, width, height.
Syntax
object.DecodeGrayMapRect(GrayMap, GrayMapWidth, GrayMapHeight,
x, y, width, height)
Parameters
| GrayMap | A Variant that contains a safe array of Bytes. |
| GrayMapWidth | Gray map width. |
| GrayMapHeight | Gray map height. |
| x | An integer value that defines the X coordinate of scanning zone. |
| y | An integer value that defines the Y coordinate of scanning zone. |
| width | An integer that defines the width of scanning zone. |
| height | An integer that defines the height scanning zone. |
Return Value
Integer. Returns the number of decoded barcodes.
|
|
|
|