MIL_ID ModelCodeId, | //in |
MIL_ID ImageBufId, | //in |
MIL_CONST_TEXT_PTR StringPtr, | //in |
MIL_INT64 ControlFlag | //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 McodeInquire() 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 write 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 the cell size, in pixels, of a unit of the code. If this setting is set to M_DEFAULT, the code will be written so as to just fit into the destination image. |
|
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 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. (more details...) |
||||||||||||||||||||||||||||||||||||||
MIL image buffer identifier |
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
|
||||||||||||||||||||||||||||||||||||||
MIL_TEXT("String") 1 |
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. (more details...) |
||||||||||||||||||||||||||||||||||||||
M_ESCAPE_SEQUENCE |
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. (more details...) |
Header | Include mil.h. |
Library | Use mil.lib; milcode.lib. |
DLL | Requires mil.dll; milcode.dll. |