BCGaztec Class
Aztec code comes from the 2D barcode family. You can encode a lot of information in only one barcode.
All the ASCII characters from 0 to 255 are supported. The barcode size will be determined by the number of data needed to be encoded and the chosen error correction level.
You can pass in ECI mode with the function
setTilde().
This class inherits from the
BCGBarcode2D class.
This class is also available for WebControl:
BCGaztecBCGBarcode2D's MethodsNo specific methods for this class.
Example
protected void Page_Load(
object sender,
EventArgs e)
{
BCGColor color_black = new BCGColor(0, 0, 0);
BCGColor color_white = new BCGColor(255, 255, 255);
BCGBarcode2D code = new BCGaztec();
code.setScale(2);
code.setErrorLevel(23);
code.setSize(BCGaztec.AZTEC_SIZE_SMALLEST);
code.setForegroundColor(color_black);
code.setBackgroundColor(color_white);
code.setTilde(true);
code.parse("Code 2D");
BCGDrawing drawing = new BCGDrawing(null, color_white);
drawing.setBarcode(code);
drawing.draw();
Response.ContentType = "image/png";
drawing.finish(ImageFormat.Png, Response.OutputStream);
}
Methods ExplanationsetErrorLevel(int level) — Sets the error correction level of the barcode
Description
It is the error correction level percentage before drawing the barcode.
The level must be between 0 and 99.
The default value is 23.
setSize(int size) — Sets the size of the barcode
Description
The size of the final barcode will be decided automatically depending on the data you give and the error correction level percentage
you have chosen.
But, you can specify different values to this method to get a different code. There are the possible values:
- BCGaztec.AZTEC_SIZE_SMALLEST : The code will be the smallest possible
- BCGaztec.AZTEC_SIZE_COMPACT : The code will try to be a compact code if possible
- BCGaztec.AZTEC_SIZE_FULL : The code will be in full mode (with the reference grid)
The default value is
BCGaztec.AZTEC_SIZE_SMALLEST.
setStructureAppend(int snum, int st) — Specifies the data will be expended on many barcodes without identifier
Description
The Aztec code data can be separated on many different barcodes.
The first argument is the barcode number (beginning with 1), the second argument is the total number of barcodes you have.
No identifier is set for the barcode. Make sure you have no identifier for every barcode in the group.
It is possible to encode the data on a maximum of 26 different barcodes.
Returns
true on success, false on failure.
setStructureAppend(int snum, int st, string sname) — Specifies the data will be expended on many barcodes with identifier
Description
The Aztec code data can be separated on many different barcodes.
The first argument is the barcode number (beginning with 1), the second argument is the total number of barcodes you have.
The last argument specifies an identifier for you barcodes group. This argument must stay the same for every barcode.
It is possible to encode the data on a maximum of 26 different barcodes.
Returns
true on success, false on failure.
setTilde(bool accept) — Modifies the use of the tilde character ~
Description
By putting
true to this the argument for this method, the tilde characters (ASCII 126)
will be processed as special characters. There are the special characters you can write.
- ~~ : Writes a simple tilde
- ~F : Writes the FNC1 character
- ~Exxxxxx : Writes the ECI xxxxxx character with x varying from 0 to 9.
The default value is
true.
setRune(int runeNumber) — Specifies to draw a Rune
Description
By calling the function
draw(), the Rune number
runeNumber
will be drawn to the screen. The Runes are special symbols.
Returns
true on success, false on failure.
parse(string text) — Analyzes a
text message to draw afterwards
Description
The data you pass to the text argument must be supported by the barcode you use.
Check the introduction of the barcode to obtain more information
draw(ref Bitmap bm) — Draws the barcode on the
bm
Description
The value of the
bm argument must be a
Bitmap image resource. The size of the image
can be defined by the value received from
getMaxSize().
getMaxSize() — Returns a table containing the required size for the image
Description
Returns a table which the first index is the image width and the second index is the image height.
The
BCGDrawing class uses this method to create the image resource.
Returns
int[] - [0] is the width, [1] is the height
getScale() — Gets the scale of the barcode
Description
Gets the scale of the barcode. The value is the number of the "smallest" unit in pixel.
Returns
int - value in pixel
setScale(int x) — Sets the scale of the barcode
Description
The barcode will be x times bigger. Then a pixel will be x by x for its size.
setForegroundColor(BCGColor color) — Sets the color for the bars
Description
The color of the bars of the barcode. By default, the color is black.
This argument can be a
BCGColor class or any other argument
that
BCGColor can accept in its constructor.
setBackgroundColor(BCGColor color) — Sets the color for the back (spaces)
Description
The color of the back (spaces) of the barcode. By default, the color is white.
This argument can be a
BCGColor class or any other argument
that
BCGColor can accept in its constructor.
setColor(BCGColor fg, BCGColor bg) — Sets the color for the bars and back (spaces)
setOffsetX(int offsetX) — Specifies the X offset
Description
Specifies the X offset of the barcode in pixel multiplied by the scale.
The required size returned by
getMaxSize() will sera modified accordingly.
setOffsetY(int offsetY) — Specifies the Y offset
Description
Specifies the Y offset of the barcode in pixel multiplied by the scale.
The required size returned by
getMaxSize() will sera modified accordingly.