All barcode implementations are derived from the abstract glbarcode::Barcode class. The glbarcode::Barcode2dBase subclass of glbarcode::Barcode provides a common framework for the implementation of 2D barcodes. Therefore, creating new 2D barcode types (or symbologies) would be typically accomplished by implementing a subclass of this glbarcode::Barcode2dBase class rather than directly implementing the glbarcode::Barcode class.
Virtual Methods
A 2D barcode subclass must implement the following virtual methods (or callbacks):
A barcode subclass may also need to implement the following virtual methods:
- glbarcode::Barcode2dBase::preprocess() – The preprocess method performs any transformation of the data needed before encoding. This method may be needed to perform a first-pass encoding to translate an extended alphabet into a simpler one. For example, this could be as simple as upshifting lowercase letters into uppercase if the symbology only supports uppercase. It is assumed that the data passed to this method has already been validated with the glbarcode::Barcode1dBase::validate() method.
- glbarcode::Barcode2dBase::vectorize() – The vectorize method converts the encoded data into a list of Drawing Primitives suitable for rendering. The glbarcode::Barcode2DBase class provides a default implementation that should be suitable for most 2D symbologies. The following protected methods are available to the vectorize implementation to create this list:
The following figure illustrates the data flow between these methods, which are called by glbarcode::Barcode2dBase::build():
2D build() data flow
Registering With The Barcode Factory
2D barcodes are registered with the barcode factory in exactly the same manner as 1D barcodes. See Implementing 1D Barcodes.