MIL_ID ModelCodeId, | //in |
MIL_ID ImageBufId, | //in |
MIL_CONST_TEXT_PTR StringPtr, | //in |
MIL_INT64 ControlFlag, | //in |
MIL_ID WriteResultCodeId | //in |
This function encodes a null-terminated ASCII string into a symbol (code) using the code type and encoding scheme, specified by the code model, and draws the code into a specified image.
For a given code model and string, you can inquire the minimum buffer size required to draw the code, using McodeWrite() with its ImageBufId parameter set to M_NULL, and then using McodeGetResult() with M_WRITE_SIZE_X and M_WRITE_SIZE_Y.
The control type settings of the specified code model determine how to perform the operation. Before performing a McodeWrite() operation, you must set certain controls, using McodeControl(), specifically:
Control |
Notes |
Specifies the number of cells in the X and Y directions. Improves the robustness of the operation, for 2D code types only. If these settings are set to M_DEFAULT, then the number of cells will be selected automatically so as to minimize the size of the resulting code. |
|
Specifies how to establish the cell size. |
|
M_CELL_SIZE_VALUE |
Specifies the cell size to use when M_CELL_SIZE_MODE is set to M_USER_DEFINED. |
M_DOT_SHAPE |
Specifies the shape in which to draw cells. |
M_DOT_SIZE |
Specifies the size of the dot (or square) in which to draw cells. |
Specifies the encoding scheme. This control type must be set for code types where M_ANY is not supported as the encoding scheme. |
|
Specifies the type of error correction. This control type must be set for code types where M_ANY is not a supported error correction type. |
|
Specifies the foreground color of the code. This control type is essential for all code types. |
If you have associated the target image with a camera calibration context, you can specify that certain input settings be interpreted in world units. To do so, use McodeControl() with M_CELL_SIZE_INPUT_UNITS set to M_WORLD. Note that if you set this constant to M_WORLD but you don't pass McodeWrite() a calibrated target image, the function will generate an error.
Specifies the 8-bit unsigned 1-band image buffer in which to write the symbol. Set this parameter to one of the following.
For specifying the image buffer
|
|||||||||||||||||||||||||||||||||||||||
Value | Description | ||||||||||||||||||||||||||||||||||||||
M_NULL |
Allows you to inquire about the minimum buffer size required. Using this value means that McodeWrite() will not write into an image buffer. After calling McodeWrite() with M_NULL, call McodeGetResult() to retrieve the minimum width (M_WRITE_SIZE_X) and height (M_WRITE_SIZE_Y) required for the image buffer. (summarize)Allows you to inquire about the minimum buffer size required. (more details...) |
||||||||||||||||||||||||||||||||||||||
MIL image buffer identifier |
Specifies that McodeWrite() will write into the image buffer, and in which image buffer to write. This buffer must be 8-bit unsigned. In addition, it should be large enough to hold the symbol. (summarize)Specifies that McodeWrite() will write into the image buffer, and in which image buffer to write. (more details...) |
Specifies the address of the string to be encoded.
For specifying the string of the code
|
|||||||||||||||||||||||||||||||||||||||
Value | Description | ||||||||||||||||||||||||||||||||||||||
M_NULL |
Specifies that a sample string will be encoded. This can be used if you need to test or use the functionality of McodeWrite() without needing to encode a specific string (for example, to draw the code type on a button in an interface). The sample string that is encoded depends on the control values set by McodeControl(). (summarize)Specifies that a sample string will be encoded. (more details...) |
||||||||||||||||||||||||||||||||||||||
MIL_TEXT("String") 1 |
Specifies the address of the string. You need to know the string specifications of the code to write. Note the following restrictions for certain code types:
In addition, add parentheses around the application identifiers in your string. Note that this is required by the McodeWrite() operation; the parentheses are not actually coded. (summarize)Specifies the address of the string. (more details...) |
1 If you are passing the value in a variable, don't enclose it in MIL_TEXT().
Specifies the function's control flag. This parameter can be set to one or more of the following value: (for example, M_ESCAPE_SEQUENCE + M_GS1_FORMAT).
For specifying the function's control
flag
|
|||||||||||||||||||||||||||||||||||||||
Value | Description | ||||||||||||||||||||||||||||||||||||||
M_DEFAULT |
Specifies that the string to encode does not use ASCII character codes for unprintable characters. Unprintable characters are not encoded. In addition, the string is not written in GS1 format. This value cannot be combined with any other value. (summarize)Specifies that the string to encode does not use ASCII character codes for unprintable characters. (more details...) |
||||||||||||||||||||||||||||||||||||||
M_ESCAPE_SEQUENCE |
Specifies that the string to encode uses ASCII character codes for unprintable characters. You must use a code type that supports unprintable characters specified using ASCII codes. When typing the string to encode, the unprintable character's ASCII character code must be in hexadecimal format, preceded by \x (for example, \x0D for ASCII 13, which is the carriage return). Note that if you want to encode the "\" character in escape sequence mode, type "\\". (summarize)Specifies that the string to encode uses ASCII character codes for unprintable characters. (more details...) |
||||||||||||||||||||||||||||||||||||||
M_GS1_FORMAT |
Specifies that the string should be written as a GS1 code. This value is only available when dealing with M_AZTEC, M_DATAMATRIX, M_CODE128, M_EAN14, M_GS1_128, and M_QRCODE code types. (summarize)Specifies that the string should be written as a GS1 code. (more details...) |
Specifies the identifier of the code write result buffer. The result buffer must have been allocated using McodeAllocResult() with M_CODE_WRITE_RESULT. Set this parameter to one of the following.
For specifying the write result buffer
|
|||||||||||||||||||||||||||||||||||||||
Value | Description | ||||||||||||||||||||||||||||||||||||||
MIL write result buffer identifier |
Specifies the identifier of the write result buffer. |
Header | Include mil.h. |
Library | Use mil.lib; milcode.lib. |
DLL | Requires mil.dll; milcode.dll. |