Manual - DataMatrix

Introduction

Datamatrix code comes from the 2D barcode family. You can encode a large amount of information within a single barcode.
All the ASCII characters from 0 to 255 are supported. The barcode size will be determined by the amount of data to be encoded. The error correction level is automatically chosen.
You can enter into ECI mode with the function SetAcceptECI().

This class inherits the BCGBarcode2D class.

Example

Methods

BCGdatamatrix's Methods

BCGBarcode2D's Methods

BCGBarcode's Methods

Code Example


var colorBlack = new BCGColor(Color.Black);
var colorWhite = new BCGColor(Color.White);

// Barcode Part
var code = new BCGdatamatrix();
code.SetScale(2);
code.SetForegroundColor(colorBlack);
code.SetBackgroundColor(colorWhite);
code.Parse("Datamatrix");

// Drawing Part
var drawing = new BCGDrawing(code, colorWhite);

var memoryStream = new MemoryStream();
await drawing
    .FinishAsync(BCGDrawing.ImageFormat.Png, memoryStream);

Method explanations

  • GetSize() — Gets the size of the barcode
    Description
    Gets the size mode of the final barcode.
    See SetSize() for more details.
    Returns
    int - constant value defined in SetSize()
  • SetSize(int value) — Sets the size of the barcode
    Description
    The size of the final barcode will be decided automatically depending on the data you give.
    You can, however, specify different values to this method to get a different code. There are the possible values:
    - BCGdatamatrix.Size.Smallest : The code will be the smallest possible
    - BCGdatamatrix.Size.Square : The code will be a square
    - BCGdatamatrix.Size.Rectangle : The code will be a rectangle
    The default value is BCGdatamatrix.Size.Square.
  • GetDatamatrixSize() — Gets the size to use for the barcode
    Description
    Gets the Datamatrix size.
    Returns
    int[]
  • SetDatamatrixSize(int row, int col) — Specifies the size to use for the barcode
    Description
    Barcode Bakery will pick the smallest barcode size based on the information you provide.
    If you wish to have a specific size, you can force the size with this method.
    You must specify a valid size or this method will raise an exception.
    The default value is -1.
  • GetQuietZone() — Gets if the quiet zone will be drawn
    Returns
    bool - true if activated, false otherwise
  • SetQuietZone(int quietZoneSize) — Specifies to draw a quiet zone around the barcode
    Description
    Gets if the quiet zone will be drawn.
  • GetTilde() — Gets if the behavior for tilde ~ is modified
    Description
    Gets if the behavior for tilde ~ is modified.
    See SetTilde() for more details.
    Returns
    bool - true if activated, false otherwise
  • SetTilde(bool accept) — Modifies the use of the tilde character ~
    Description
    By setting true in this argument, the tilde characters (ASCII 126 ~) will be processed as special characters. These are the special characters you can write.
    - ~~ : Writes a simple tilde
    - ~F : Writes the FNC1 character
    The default value is false.
    Please note that it is possible to use ~F as the first character of your data, BUT it is possible that the automatic encoding changes the meaning of your barcode by not starting your data with a FNC1. So we recommend that you use the method SetFNC1() and drop the first ~F from your data.
  • GetAcceptECI() — Gets if ECI codes are accepted
    Description
    Gets if ECI codes are accepted.
    See SetAcceptECI() for more details.
    Returns
    int - value in pixels
  • SetAcceptECI(bool accept) — Specifies to accepts the ECI codes
    Description
    By setting true in this argument, the backslash characters (ASCII 92 \) will be processed as special characters. These are the special characters you can write.
    - \\ : Writes a simple backslash
    - \xxxxxx : Writes the ECI xxxxxx character with x representing an integer from 0 to 9
    The default value is false.
  • SetStructuredAppend(int snum, int st, int sid) — Specifies that data will be expanded between multiple barcodes
    Description
    Datamatrix code data can be separated throughout 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 your barcode group. This argument must be a number between 1 and 64516 and it must stay the same for each barcode in the group.
    It is possible to encode the data on a maximum of 16 different barcodes.
    Returns
    bool - true on success, false on failure
  • SetFNC1(int fnc1Type) — Transforms your barcode in GS1 or AIM standard
    Description
    This method will transform your barcode to accept FNC1 to be GS1 standard or AIM standard.
    BCGdatamatrix.Fnc1.None : The code will not follow any standards.
    BCGdatamatrix.Fnc1.Gs1 : The code will follow the GS1 standard. Separate GS1 identifiers by ~F. Don't forget to turn on SetTilde().
    BCGdatamatrix.Fnc1.Aim : The code will follow the AIM standard.
    The default value is BCGdatamatrix.Fnc1.None.
    Please note that it is possible to use ~F as the first character of your data, BUT it is possible that the automatic encoding changes the meaning of your barcode by not starting your data with a FNC1. So we recommend that you use the method SetFNC1() and drop the first ~F from your data.
  • GetEncoding() — Gets the forced encoding
    Description
    Gets the forced encoding
    See SetEncoding() for more details.
    Returns
    int - constant value defined in SetEncoding()
  • SetEncoding(int encoding) — Sets a specific encoding
    Description
    You can force an encoding to be used for different reasons. Some readers are not able to read a specific encoding, so you can force the ASCII mode.
    Note that by forcing the encoding, you may not get an efficient result. Furthermore, some characters cannot be represented in some encodings.
    See the technical information page for more information about the encodings.
    - BCGdatamatrix.Encoding.Unknown : No specific encoding is selected
    - BCGdatamatrix.Encoding.Ascii : ASCII and extended ASCII (low compression)
    - BCGdatamatrix.Encoding.C40 : C40 encoding (capital letters)
    - BCGdatamatrix.Encoding.Text : TEXT encoding (lowercase letters)
    - BCGdatamatrix.Encoding.X12 : X12 encoding (capital letters and numbers)
    - BCGdatamatrix.Encoding.Edifact : Edifact encoding
    - BCGdatamatrix.Encoding.Base256 : Binary encoding
    The default value is BCGdatamatrix.Encoding.Unknown.
  • GetMacro() — Gets if a macro is written
    Description
    Gets if a macro is written
    See SetMacro() for more details.
    Returns
    int - constant defined in SetMacro()
  • SetMacro(int macro) — Specifies to prepend and append values to your data
    Description
    The macro has been defined to make your data and barcode smaller in size. Use this method to prepend and append predefined data in your barcode when read.
    - BCGdatamatrix.Macro.None : Your data will appear raw. No prefix or suffix.
    - BCGdatamatrix.Macro._05 : Prefix: [)>RS05GS - Suffix: RSEoT
    - BCGdatamatrix.Macro._06 : Prefix: [)>RS06GS - Suffix: RSEoT
    The default value is BCGdatamatrix.Macro.None.
  • SetScaleX(int scaleX) — Sets the scaling X for the barcode
    Description
    The width in pixel of one module.
    The default value is 1.
    Note that this method is protected.
  • SetScaleY(int scaleY) — Sets the scaling Y for the barcode
    Description
    The height in pixel of one module.
    The default value is 1.
    Note that this method is protected.
  • Parse(string text) — Analyzes a text message to draw afterwards
    Description
    The data you pass to the text argument must be supported by the type of barcode you use.
    Check each barcode's introduction section to obtain more information on how to use this method within each symbology.
  • Draw(Graphics image) — Draws the barcode on the image
    Description
    The value of the image argument must be an image resource. The size of the image can be defined by the value received from GetDimension().
  • GetDimension(int width, int height) — Returns an array containing the required size for the image
    Description
    Returns an array in which the first index is the image width and the second index is the image height.
    The arguments are used to specify the starting point of the drawing. Should be 0 for both.
    The BCGDrawing class uses this method to create the image resource.
    Returns
    array(int, 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 pixels
  • SetScale(int scale) — 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.
  • GetForegroundColor() — Gets the color of the bars
    Description
    Gets the color of the bars of the barcode.
    Returns
  • SetForegroundColor(BCGColor color) — Sets the color of the bars
    Description
    Sets 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.
  • GetBackgroundColor() — Gets the color of the spaces
    Description
    Gets the color of the spaces of the barcode.
    Returns
  • SetBackgroundColor(BCGColor color) — Sets the color of the spaces
    Description
    Sets the color of the 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 foregroundColor, BCGColor backgroundColor) — Sets the color of the bars and spaces
    Description
    An easy and fast method to set the color of the bars and spaces. Check the SetForegroundColor() and SetBackgroundColor().
  • GetOffsetX() — Gets the X offset
    Description
    Gets the X offset of the barcode in pixels. The value isn't multiplied by the scale.
    Returns
    int - value in pixels
  • SetOffsetX(int value) — Sets the X offset
    Description
    Specifies the X offset of the barcode in pixels multiplied by the scale. The required size returned by GetDimension() will be modified accordingly.
  • GetOffsetY() — Gets the Y offset
    Description
    Gets the Y offset of the barcode in pixels. The value isn't multiplied by the scale.
    Returns
    int - value in pixels
  • SetOffsetY(int value) — Sets the Y offset
    Description
    Specifies the Y offset of the barcode in pixels multiplied by the scale. The required size returned by GetDimension() will be modified accordingly.
  • AddLabel(BCGLabel label) — Adds a label to the graphic
    Description
    Adds a BCGLabel object to the drawing.
  • RemoveLabel(BCGLabel label) — Removes a label from the graphic
    Description
    Removes a specific BCGLabel object from the drawing.
  • ClearLabels() — Removes the labels from the graphic
    Description
    Clears the BCGLabel objects from the drawing.