The following example demonstrates typical use of ClearImage to read barcodes in Delphi application.
It reads Code39 barcodes from an image file.
'OR' type values in Type_ property to detect multiple barcode symbologies.
Alternatively set AutoDetect1D property to ciTrue to detect barcodes of the most popular symbologies.
To import ClearImage into Delphi project:
1. In Project menu select Import Type Library
2. Select ClearImage COM Server in list box
3. Click on the Create Unit button
To use ClearImage in Delphi project
1. Add the ClearImage_TLB unit to the uses clause
2. Initialize the COM interface:
in GUI: Call Application.Initialize;
in DOS:
Add to uses ActiveX, Windows
Call CoInitialize(nil); before any ClearImage calls
Call CoUnInitialize; before exiting application
Exception handling
Any error detected by ClearImage COM (e.g. Image.Open tries to open file that does not exist) generates COM exception. Use try - except to trap and process such errors.
If image to be shared between multiple processing modules, image object can be created separately and attached to processing object:
Image: ICiImage;
Image := Ci.CreateImage;
Image.Open(aFileName, 1);
Barcode.Image := Image;