|
Creates a barcode image as a png object which you can then print or
save to a file and decodes barcode scans from the CueCat scanner
<www.cuecat.com> and can query the Digital Convergence database for
a url.
Currently only creates type Code 128 barcodes.
If the data string is an odd length or contains non-digit characters,
Code B is used, otherwise Code C.
For more information on barcodes see
BarCode1 http://www.adams1.com/pub/russadam/barcode1.html.
Class Code128
# create a Code 128 barcode
my $barcode = Code128->new($bar_code,$quiet_zone,$polarity,$density,
$dpi,$image_type,$description);
where: $bar_code = string to be barcoded
$quiet_zone = number of clear x-dimensions each end
$polarity = bw (black on white) or wb (white on black)
$density = width of individual bars in .001 inch
$dpi = resolution of target printer
$image_type = 'transparent' or 'interlaced'
$description = optional description
Returns the png file in $barcode->{'png_file'}.
Class CodeISBN
Constructs the ISBN number from the raw barcode value on an ISBN
barcode (this is the number found above the ISBN barcode).
# return the ISBN number after previously decoding the barcode
my $isbn = CodeISBN->encode($scan->{'barcode_data'});
Returns $isbn->{'isbn_value'}.
Class Cuecat
Two decode methods are provided: decode and kdecode.
CueCat->decode uses a perl decode routine on raw scan data from the
CueCat. This method is NOT recommended on linux or any system using
X-Windows due to the initial Alt-F10 sequence sent by the CueCat.
It will work on a regular text console however, provided you do not
have a virtual terminal set up on tty10.
CueCat->kdecode is a binding to the linux CueCat kernel driver and
is the recommended method on linux. The kernel driver is available at
http://oss.lineo.com/cuecat/.
# decode a barcode with the decode method
my $scan = CueCat->decode($scan_string);
# decode a barcode with the kdecode method
my $scan = CueCat->kdecode;
Returns $scan->{'barcode_type'} $scan->{'barcode_data'} and
$scan->{'cuecat_ser_no'} in either method. If you call CueCat->kdecode
inside a loop you must destroy the object created by calling
$scan->destroy($scan->{'pid'}) before returning to the start of the
loop.
CueCat->get_dc_cue will query a Digital Convergence server and return
the url from the database. This method requires the raw (undecoded)
string sent by the scanner. It will generate a random "activation code"
in order to preserve the privacy of the user. If the url is not in DC's
database it will return the url of a form to submit the barcode to DC.
# retrieve a url
my $scan_string = ;
my $scan = CueCat->get_dc_cue($scan_string);
Returns $scan->{'url'}.
CueCat->encode will take decoded data and re-encode it to the raw scan
data format. This allows users of the linux kernel driver to get a
decoded scan from the driver and re-encode it in order to call
CueCat->get_dc_cue.
# encode data
my $data = CueCat->encode($barcode_data);
Returns $data->{'encoded'}. Note you must do this for all 3 pieces of the
original scan string and then reconstruct the scan format. See the example
file.
|