RMaxicode for Delphi

Copyright J4L (http://www.java4less.com) 2002.

 

Contents

Introduction

Installation

Sample application

The component

References

Introduction

The package RMaxicode contains the component you need to create Maxicode barcodes within your DELPHI applications.

Maxicode is a two-dimensional (2D) and fixed-size matrix symbology which is made up of offset rows of hexagonal modules arranged around a unique finder pattern. The size of Maxicode is 1.11 x 1.054 inches and it can contain up to 93 data characters of information (a total of 144 including error correction codewords).

The symbol was created by United Parcel Service for fast scanning and sorting of packages.RMaxicode supports the following features:

  • modes 2,3,4,5 and 6.
  • structured append
  • full character set.

 

Symbol structure

MaxiCode symbols are divided into a primary and a secondary message, each of which contains data and error correction codewords. The primary message is made of 10 codewords and 10 error correction codewords. The primary message is used in mode 2 and 3 to encode the Postal Code, the Service class and the country.

Error correction

MaxiCode symbols have error correction codewords, based on Reed-Solomon error correction algorithms, which can be used to detect errors and correct erroneous symbols. There are two error levels; standard and enhanced (mode 5).

Maxicode modes

Modes 2 and 3 are designed for use in the transport industry. They encode the destination address and the class of service as defined by the carrier. Mode 2 uses a 9 digit numeric postal code and mode 3 uses a 6 character alphanumeric postal code. The Service class and the country are both a 3 digit number in both modes.

Mode 4 can encode up to 93 characters or 138 digits. Mode 5 can only encode up to 77 characters but it provides more error correction capabilities (enhanced mode than mode 4.

Mode 6 indicates that the symbol encodes a message used to program the reader system (scanner).

Structured append

Up to eight MaxiCode symbols may be appended in a structured format. This allows files of data to be represented in up to 8 MaxiCode symbols.

 

Installation

There are 2 installation possibilities ActiveX version and Delphi source code.

In order to install the ActiveX version of the control:

  1. select main menu -> component -> import activeX control
  2. click on "Add...", select RBarcodeDX.ocx file
  3. You will now see: TBarcode1DX, TDatamatriX, TDPF417X and TMaxicodeX in the "Classes" window.
  4. click on "Install", install window will come up.
  5. click "ok" to install
  6. the controls will appear in the "ActiveX" tab of the components palette.

In order to install from the Delphi source code (registered users only):

  1. select main menu -> component -> install component
  2. click on "browse" and select Maxicode.pas
  3. click "ok"
  4. the control will appear in the "Barcodes" tab of the components palette.

 

Sample application

In order to run the sample application you must execute maxicodeDemo.exe or barcode1D2DDemo.exe.

 

In the sample application you can set following properties:

  • Mode to be used
  • Printer resolution (dots per inch).
  • Service class, Country and Postal code (for modes 2 and 3).
  • Data to be encoded.
  • Number of symbols in the secuence (if you use structured append)
  • Position of the symbol within the secuence.

and execute the following command:

  • Refresh: repaint the symbol using the new properties.
  • Print: print. The resolution you selected must match the resolution of the printer so that the final symbol has the correct size.
  • Save: save the symbol in bmp format.

Note: Tilde Processing: You can use the format ~ddd if you want to specify the ascii code of the character to be encoded. For example, if you enter the following text in the Data field:

~066AA

you will actually be encoding

BAA

because ~066 will be replaced with the character ascii character 66, which is B. You must use ~~ in order to encode the ~ character. If you want to deactivate this behaviour you must use processTilde:=false;.

 

The Component

The file Maxicode.dcu and Maxicode.pas ( if you have the source code) contains the component that creates the barcodes. It is a subclass of TGraphicControl and can be placed on any form.

The component has the following methods and properties:

 

Methods

  • paintBarcode(canvas): pains the barcode on the provided canvas.

Properties

  • TopMargin.
  • LeftMargin.
  • BackColor: background color of the barcode.
  • BarColor: foreground color of the barcode.
  • preferredHeight: returns size needed to draw the barcode.
  • preferredWidth: returns size needed to draw the barcode.
  • Country: country code (for modes 2 and 3)
  • Data: data to be encoded. If the postal code, service class and country are left empyt in mode 2 and 3, they will be extracted from this string as follows:
    1. If the string begins by [)>RS01GS the following format is expected:

      [)>RS01GSPostalCodeGSCountryGSServiceGSdata.....

      where RS is character number 30 and GS is character number 29

    2. otherwise the format must be: PostalCodeGSCountryGSServiceGSdata.....

  • HHexagon: Height of hexagon modules (pixels).
  • Mode: maxicode mode. Values range from 2 to 6
  • NumberOfCodes: number of symbol in structured appended mode
  • PositionOfCode: number of symbol in structured appended mode
  • resolution: current resolution of the printer (in dpi) . This is important so that you get the correct size.
  • serviceclass: service class (modes 2 and 3). In mode 2 it can be an alphanumeric of length 5. In mode 3 can be a numeric of length 9.
  • WHexagon: width of hexagon modules (pixels)
  • ZipCode: postal code (modes 2 and 3)
  • HexagonPattern: set a user defined pattern for the hexagons. For example, in a resolution of 8 dots per millimeter:

    pattern = { {0,0,0,0,0,0,0}, {0,0,0,1,1,0,0}, {0,0,1,1,1,1,0}, {0,1,1,1,1,1,1}, {0,1,1,1,1,1,1}, {0,1,1,1,1,1,1}, {0,0,1,1,1,1,0}, {0,0,0,1,1,0,0}, };
    myMaxicode.pattern:=pattern;

    you can uset getHHexagon() and gwtWHexagon to find out the size of the pattern in pixels.

  • L: length of the symbol. The default is 25.5 millimeters.
  • ProcessTilde: the default is value "true". Set it to "false" in order to deactivate the processing of ~.You can use the format ~ddd if you want to specify the ascii code of the character to be encoded. For example, if you enter the following text in the Data field:

    ~066AA

    you will actually be encoding

    BAA

    because ~066 will be replaced with the character ascii character 66, which is B. You must use ~~ in order to encode the ~ character.

You can also use the component in order to paint onto an external canvas. For example, in order to create a bitmap file you would use the following code:

var
bmp: TBitmap;
begin

bmp:=TBitmap.create();
bmp.height:=200;
bmp.width:=200;

{use paintBarcode() to paint onto an external Canvas}
barcode.paintBarcode(bmp.Canvas);

bmp.saveToFile('barcode.bmp');


end;

 

References

You can find more information about maxicode at: