dBarScan provides three methods that may be used for decoding a barcode image.
The simplest function is scan(), that simply scans the complete width of the image, using the central third of the vertical height as the region where decoding is attempted. This method is most suited to images that contain only the barcode of interest in normal orioentation.
An example of the code required to decode an image from a file using the scan() method is:
Barscan1.dImage=System.Drawing.Image.FromFile(filename);
err=Barscan1.scan();
if
(err<0)
{
Output=Barscan1.oData(); // returns the barcode
data
MessageBox.Show(Output);
else
MessageBox.Show(“Barcode not detected”);
The BarScan demo program supplied with the component uses the technique above when scanning in “Full” mode. See the scan1_Click() function in the program’s source code.
A second method provided for decoding is the scan1(n, left, top) method. This is useful when the image provided to Barscan1.dImage contains material in addition to the barcode, or where the barcode is not in the central third of the image. This method mimics alaser beam scanning a raster pattern over a ¼ inch (6 mm) strip of the image starting at the coordinates left, top (in pixels) until a barcode is found. The raster pattern consists of n lines, each one being 6/n mm high.
The BarScan demo program supplied with the component uses this technique when scanning in “Laser” mode.
The third method provided for decoding is the scan2(left, top, width,depth) method. This provides maximum flexibility, in that the starting coordinates (left, top) and the width and height of the scan may all be specified, and the values used in conjunction with a selected area of the image (using the barscan1.selLeft, etc. properties). This permits a region of an image to be used as the target area and a scanning region within that area to be specified.
The BarScan demo program supplied with the component uses this technique when scanning in “CCD” mode.
The BarScan demo program allows an image file to be loaded; in “Laser” mode clicking to the left of the image (i.e. in the light margin) results in a red box being drawn around the area to be scanned; in “CCD” mode draw a box with the mouse around the target barcode while holding down the left mouse button; in “Full” mode the image should contain only the barcode. In each case, pushing the Scan button will initiate a scan.
The image files scantest3.xxx contain a 300 dpi scanned image of a page containing a variety of barcodes.