mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
2021-01-05 2.9.1 HaO TCL backend update
+- Added options -reverse, -werror, -wzpl +- Use version number from zint.h (first 3 digits). Do not use an own one.
This commit is contained in:
parent
e198a40b3a
commit
04bf0ec99c
@ -14,7 +14,7 @@
|
|||||||
# so you can encode the package version directly into the source files.
|
# so you can encode the package version directly into the source files.
|
||||||
#-----------------------------------------------------------------------
|
#-----------------------------------------------------------------------
|
||||||
|
|
||||||
AC_INIT([zint], [2.9.1.9])
|
AC_INIT([zint], [2.9.1])
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
# Call TEA_INIT as the first TEA_ macro to set up initial vars.
|
# Call TEA_INIT as the first TEA_ macro to set up initial vars.
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
package ifneeded zint 2.9.0\
|
package ifneeded zint 2.9.1\
|
||||||
[list load [file join $dir zint[info sharedlibextension]]]
|
[list load [file join $dir zint[info sharedlibextension]]]
|
||||||
|
@ -100,6 +100,9 @@
|
|||||||
- Alpha channel support added:
|
- Alpha channel support added:
|
||||||
- added option -nobackground
|
- added option -nobackground
|
||||||
- also allow RRGGBBAA for -fg and -bg options
|
- also allow RRGGBBAA for -fg and -bg options
|
||||||
|
2021-01-05 2.9.1 HaO
|
||||||
|
- Added options -reverse, -werror, -wzpl
|
||||||
|
- Use version number from zint.h (first 3 digits). Do not use an own one.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
|
#if defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
|
||||||
@ -118,6 +121,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <zint.h>
|
#include <zint.h>
|
||||||
|
/* Load version defines */
|
||||||
|
#include <zintconfig.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#if defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
|
#if defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
|
||||||
@ -136,15 +141,17 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
|
||||||
/* > File option defines */
|
|
||||||
|
|
||||||
#define VERSION "2.9.1.9"
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* >>>>> Hepler defines */
|
/* >>>>> Hepler defines */
|
||||||
|
|
||||||
|
/* Two macros are necessary to not include the define name, but the value */
|
||||||
#define STRING(x) #x
|
#define STRING(x) #x
|
||||||
|
#define TOSTRING(x) STRING(x)
|
||||||
|
|
||||||
|
/* Define VERSION as the first 3 digits of the zint library version number */
|
||||||
|
#define VERSION TOSTRING( ZINT_VERSION_MAJOR ) \
|
||||||
|
"." TOSTRING( ZINT_VERSION_MINOR ) \
|
||||||
|
"." TOSTRING( ZINT_VERSION_RELEASE )
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* >>>> External Prototypes (exports) */
|
/* >>>> External Prototypes (exports) */
|
||||||
@ -416,39 +423,55 @@ static char help_message[] = "zint tcl(stub,obj) dll\n"
|
|||||||
" data: data to encode in the symbol\n"
|
" data: data to encode in the symbol\n"
|
||||||
" photo: a tcl photo image handle ('p' after 'image create photo p')\n"
|
" photo: a tcl photo image handle ('p' after 'image create photo p')\n"
|
||||||
" Available options:\n"
|
" Available options:\n"
|
||||||
" -addongap number: (7..12, default: 9) set add-on gap in multiple of module size (UPC/EAN-CC)\n"
|
|
||||||
" -barcode choice: symbology, use 'zint symbology' to get a list\n"
|
" -barcode choice: symbology, use 'zint symbology' to get a list\n"
|
||||||
|
" -addongap number: (7..12, default: 9) set add-on gap in multiple of module size (UPC/EAN-CC)\n"
|
||||||
|
" -bg color: set background color as 6 or 8 hex rrggbbaa\n"
|
||||||
|
/* cli option --binary internally handled */
|
||||||
" -bind bool: bars above/below the code, size set by -border\n"
|
" -bind bool: bars above/below the code, size set by -border\n"
|
||||||
|
" -bold bool: use bold text\n"
|
||||||
" -border integer: width of a border around the symbol. Use with -bind/-box 1\n"
|
" -border integer: width of a border around the symbol. Use with -bind/-box 1\n"
|
||||||
" -box bool: box around bar code, size set be -border\n"
|
" -box bool: box around bar code, size set be -border\n"
|
||||||
" -height integer: Symbol height in modules\n"
|
/* cli option --cmyk not supported as no corresponding output */
|
||||||
" -whitesp integer: horizontal quiet zone in modules\n"
|
|
||||||
" -fg color: set foreground color as 6 or 8 hex rrggbbaa\n"
|
|
||||||
" -bg color: set background color as 6 or 8 hex rrggbbaa\n"
|
|
||||||
" -nobackground bool: set background transparent\n"
|
|
||||||
" -cols integer: PDF417, Codablock F: number of columns\n"
|
" -cols integer: PDF417, Codablock F: number of columns\n"
|
||||||
" -rows integer: Codablock F: number of rows\n"
|
/* cli option --data is standard parameter */
|
||||||
" -vers integer: Symbology option\n"
|
|
||||||
" -dmre bool: Allow Data Matrix Rectangular Extended\n"
|
" -dmre bool: Allow Data Matrix Rectangular Extended\n"
|
||||||
" -mask integer: Mask pattern to use for QR (0..7), MicroQR (0..3) or HanXin (0..3)\n"
|
|
||||||
" -separator 0..4 (default: 1) : Stacked symbologies: separator width\n"
|
|
||||||
" -rotate angle: Image rotation by 0,90 or 270 degrees\n"
|
|
||||||
" -secure integer: EC Level (PDF417, QR)\n"
|
|
||||||
" -mode: Structured primary data mode (Maxicode, Composite)\n"
|
|
||||||
" -primary text: Structured primary data (Maxicode, Composite)\n"
|
|
||||||
" -scmvv: Prefix secondary message with [)>\\R01\\Gvv (vv 00..99) (MaxiCode)\n"
|
|
||||||
" -dotty bool: use dots instead of boxes for matrix codes\n"
|
|
||||||
" -dotsize number: radius ratio of dots from 0.01 to 1.0\n"
|
" -dotsize number: radius ratio of dots from 0.01 to 1.0\n"
|
||||||
" -scale double: Scale the image to this factor\n"
|
" -dotty bool: use dots instead of boxes for matrix codes\n"
|
||||||
" -format binary|unicode|gs1: input data format. Default:unicode\n"
|
/* cli option --dump not supported */
|
||||||
" -fullmultibyte: allow multibyte compaction for xQR, HanXin, Gridmatrix\n"
|
/* cli option --ecinos not supported */
|
||||||
" -gssep bool: for gs1, use gs as separator instead fnc1 (Datamatrix only)\n"
|
|
||||||
" -eci number: ECI to use\n"
|
" -eci number: ECI to use\n"
|
||||||
" -notext bool: no interpretation line\n"
|
/* cli option --esc not supported */
|
||||||
" -square bool: force Data Matrix symbols to be square\n"
|
" -fg color: set foreground color as 6 or 8 hex rrggbbaa\n"
|
||||||
|
/* replaces cli options --binary and --gs1 */
|
||||||
|
" -format binary|unicode|gs1: input data format. Default:unicode\n"
|
||||||
|
" -fullmultibyte bool: allow multibyte compaction for xQR, HanXin, Gridmatrix\n"
|
||||||
|
/* cli option --gs1 replaced by -format */
|
||||||
|
" -gssep bool: for gs1, use gs as separator instead fnc1 (Datamatrix only)\n"
|
||||||
|
" -height integer: Symbol height in modules\n"
|
||||||
|
/* cli option --input not supported */
|
||||||
" -init bool: Create reader initialisation symbol (Code 128, Data Matrix)\n"
|
" -init bool: Create reader initialisation symbol (Code 128, Data Matrix)\n"
|
||||||
|
" number: Set encoding mode (MaxiCode/Composite)\n"
|
||||||
|
/* cli option --mirror not supported */
|
||||||
|
" -mode: Structured primary data mode (MaxiCode, Composite)\n"
|
||||||
|
" -nobackground bool: set background transparent\n"
|
||||||
|
" -notext bool: no interpretation line\n"
|
||||||
|
/* cli option --output not supported */
|
||||||
|
" -primary text: Structured primary data (MaxiCode, Composite)\n"
|
||||||
|
" -reverse bool: Reverse colours (white on black)\n"
|
||||||
|
" -rotate angle: Image rotation by 0,90 or 270 degrees\n"
|
||||||
|
" -rows integer: Codablock F: number of rows\n"
|
||||||
|
" -scale double: Scale the image to this factor\n"
|
||||||
|
" -scmvv number: Prefix SCM with [)>\\R01\\Gvv (vv is NUMBER) (MaxiCode)\n"
|
||||||
|
" -secure integer: EC Level (PDF417, QR)\n"
|
||||||
|
" -separator 0..4 (default: 1) : Stacked symbologies: separator width\n"
|
||||||
|
/* cli option --small replaced by -smalltext */
|
||||||
" -smalltext bool: tiny interpretation line font\n"
|
" -smalltext bool: tiny interpretation line font\n"
|
||||||
" -bold bool: use bold text\n"
|
" -square bool: force Data Matrix symbols to be square\n"
|
||||||
|
/* cli option --types not supported */
|
||||||
|
" -vers integer: Symbology option\n"
|
||||||
|
" -whitesp integer: horizontal quiet zone in modules\n"
|
||||||
|
" -werror bool: Convert all warnings into errors\n"
|
||||||
|
" -wzpl bool: ZPL compatibility mode (allows non-standard symbols)\n"
|
||||||
" -to {x0 y0 ?width? ?height?}: place to put in photo image\n"
|
" -to {x0 y0 ?width? ?height?}: place to put in photo image\n"
|
||||||
"\n"
|
"\n"
|
||||||
"zint symbologies: List available symbologies\n"
|
"zint symbologies: List available symbologies\n"
|
||||||
@ -587,7 +610,7 @@ static int Zint(ClientData unused, Tcl_Interp *interp, int objc,
|
|||||||
static int Encode(Tcl_Interp *interp, int objc,
|
static int Encode(Tcl_Interp *interp, int objc,
|
||||||
Tcl_Obj *CONST objv[])
|
Tcl_Obj *CONST objv[])
|
||||||
{
|
{
|
||||||
struct zint_symbol *hSymbol;
|
struct zint_symbol *my_symbol;
|
||||||
Tcl_DString dsInput;
|
Tcl_DString dsInput;
|
||||||
char *pStr = NULL;
|
char *pStr = NULL;
|
||||||
int lStr;
|
int lStr;
|
||||||
@ -605,6 +628,7 @@ static int Encode(Tcl_Interp *interp, int objc,
|
|||||||
int addon_gap = 0;
|
int addon_gap = 0;
|
||||||
int Separator = 1;
|
int Separator = 1;
|
||||||
int Mask = 0;
|
int Mask = 0;
|
||||||
|
unsigned int cap;
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* >> Check if at least data and object is given and a pair number of */
|
/* >> Check if at least data and object is given and a pair number of */
|
||||||
/* >> options */
|
/* >> options */
|
||||||
@ -621,9 +645,9 @@ static int Encode(Tcl_Interp *interp, int objc,
|
|||||||
}
|
}
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* >>> Prepare zint object */
|
/* >>> Prepare zint object */
|
||||||
hSymbol = ZBarcode_Create();
|
my_symbol = ZBarcode_Create();
|
||||||
hSymbol->input_mode = UNICODE_MODE;
|
my_symbol->input_mode = UNICODE_MODE;
|
||||||
hSymbol->option_3 = 0;
|
my_symbol->option_3 = 0;
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* >> Decode options */
|
/* >> Decode options */
|
||||||
for (optionPos = 4; optionPos < objc; optionPos+=2) {
|
for (optionPos = 4; optionPos < objc; optionPos+=2) {
|
||||||
@ -632,16 +656,18 @@ static int Encode(Tcl_Interp *interp, int objc,
|
|||||||
char *optionList[] = {
|
char *optionList[] = {
|
||||||
"-addongap", "-barcode", "-bg", "-bind", "-bold", "-border", "-box",
|
"-addongap", "-barcode", "-bg", "-bind", "-bold", "-border", "-box",
|
||||||
"-cols", "-dmre", "-dotsize", "-dotty", "-eci", "-fg", "-format",
|
"-cols", "-dmre", "-dotsize", "-dotty", "-eci", "-fg", "-format",
|
||||||
"-gssep", "-height", "-init", "-mode", "-nobackground", "-notext",
|
"-fullmultibyte", "-gssep", "-height", "-init", "-mask", "-mode",
|
||||||
"-primary", "-rotate", "-rows", "-scale", "-secure", "-smalltext",
|
"-nobackground", "-notext", "-primary", "-reverse", "-rotate",
|
||||||
"-square", "-to", "-vers", "-whitesp", "-fullmultibyte",
|
"-rows", "-scale", "-scmvv", "-secure", "-separator", "-smalltext",
|
||||||
"-separator", "-mask", "-scmvv", NULL};
|
"-square", "-to", "-vers", "-werror", "-whitesp", "-wzpl",
|
||||||
|
NULL};
|
||||||
enum iOption {
|
enum iOption {
|
||||||
iAddonGap, iBarcode, iBG, iBind, iBold, iBorder, iBox, iCols,
|
iAddonGap, iBarcode, iBG, iBind, iBold, iBorder, iBox,
|
||||||
iDMRE, iDotSize, iDotty, iECI, iFG, iFormat, iGSSep, iHeight,
|
iCols, iDMRE, iDotSize, iDotty, iECI, iFG, iFormat,
|
||||||
iInit, iMode, iNoBackground, iNoText, iPrimary, iRotate, iRows,
|
iFullMultiByte, iGSSep, iHeight, iInit, iMask, iMode,
|
||||||
iScale, iSecure, iSmallText, iSquare, iTo, iVers,
|
iNoBackground, iNoText, iPrimary, iReverse, iRotate,
|
||||||
iWhiteSp, iFullMultiByte, iSeparator, iMask, iSCMvv
|
iRows, iScale, iSCMvv, iSecure, iSeparator, iSmallText,
|
||||||
|
iSquare, iTo, iVers, iWError, iWhiteSp, iWZPL
|
||||||
};
|
};
|
||||||
int optionIndex;
|
int optionIndex;
|
||||||
int intValue;
|
int intValue;
|
||||||
@ -670,6 +696,9 @@ static int Encode(Tcl_Interp *interp, int objc,
|
|||||||
case iSmallText:
|
case iSmallText:
|
||||||
case iSquare:
|
case iSquare:
|
||||||
case iFullMultiByte:
|
case iFullMultiByte:
|
||||||
|
case iReverse:
|
||||||
|
case iWError:
|
||||||
|
case iWZPL:
|
||||||
/* >> Binary options */
|
/* >> Binary options */
|
||||||
if (TCL_OK != Tcl_GetBooleanFromObj(interp, objv[optionPos+1],
|
if (TCL_OK != Tcl_GetBooleanFromObj(interp, objv[optionPos+1],
|
||||||
&intValue))
|
&intValue))
|
||||||
@ -745,23 +774,23 @@ static int Encode(Tcl_Interp *interp, int objc,
|
|||||||
break;
|
break;
|
||||||
case iBind:
|
case iBind:
|
||||||
if (intValue) {
|
if (intValue) {
|
||||||
hSymbol->output_options |= BARCODE_BIND;
|
my_symbol->output_options |= BARCODE_BIND;
|
||||||
} else {
|
} else {
|
||||||
hSymbol->output_options &= ~BARCODE_BIND;
|
my_symbol->output_options &= ~BARCODE_BIND;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case iBold:
|
case iBold:
|
||||||
if (intValue) {
|
if (intValue) {
|
||||||
hSymbol->output_options |= BOLD_TEXT;
|
my_symbol->output_options |= BOLD_TEXT;
|
||||||
} else {
|
} else {
|
||||||
hSymbol->output_options &= ~BOLD_TEXT;
|
my_symbol->output_options &= ~BOLD_TEXT;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case iBox:
|
case iBox:
|
||||||
if (intValue) {
|
if (intValue) {
|
||||||
hSymbol->output_options |= BARCODE_BOX;
|
my_symbol->output_options |= BARCODE_BOX;
|
||||||
} else {
|
} else {
|
||||||
hSymbol->output_options &= ~BARCODE_BOX;
|
my_symbol->output_options &= ~BARCODE_BOX;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case iDotSize:
|
case iDotSize:
|
||||||
@ -770,21 +799,21 @@ static int Encode(Tcl_Interp *interp, int objc,
|
|||||||
Tcl_NewStringObj("Dot size below 0.01", -1));
|
Tcl_NewStringObj("Dot size below 0.01", -1));
|
||||||
fError = 1;
|
fError = 1;
|
||||||
} else {
|
} else {
|
||||||
hSymbol->dot_size = (float)doubleValue;
|
my_symbol->dot_size = (float)doubleValue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case iDotty:
|
case iDotty:
|
||||||
if (intValue) {
|
if (intValue) {
|
||||||
hSymbol->output_options |= BARCODE_DOTTY_MODE;
|
my_symbol->output_options |= BARCODE_DOTTY_MODE;
|
||||||
} else {
|
} else {
|
||||||
hSymbol->output_options &= ~BARCODE_DOTTY_MODE;
|
my_symbol->output_options &= ~BARCODE_DOTTY_MODE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case iGSSep:
|
case iGSSep:
|
||||||
if (intValue) {
|
if (intValue) {
|
||||||
hSymbol->output_options |= GS1_GS_SEPARATOR;
|
my_symbol->output_options |= GS1_GS_SEPARATOR;
|
||||||
} else {
|
} else {
|
||||||
hSymbol->output_options &= ~GS1_GS_SEPARATOR;
|
my_symbol->output_options &= ~GS1_GS_SEPARATOR;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case iFullMultiByte:
|
case iFullMultiByte:
|
||||||
@ -797,48 +826,64 @@ static int Encode(Tcl_Interp *interp, int objc,
|
|||||||
{
|
{
|
||||||
fError = 1;
|
fError = 1;
|
||||||
} else {
|
} else {
|
||||||
hSymbol->eci = s_eci_number[ECIIndex];
|
my_symbol->eci = s_eci_number[ECIIndex];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case iInit:
|
case iInit:
|
||||||
if (intValue) {
|
if (intValue) {
|
||||||
hSymbol->output_options |= READER_INIT;
|
my_symbol->output_options |= READER_INIT;
|
||||||
} else {
|
} else {
|
||||||
hSymbol->output_options &= ~READER_INIT;
|
my_symbol->output_options &= ~READER_INIT;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case iSmallText:
|
case iSmallText:
|
||||||
if (intValue) {
|
if (intValue) {
|
||||||
hSymbol->output_options |= SMALL_TEXT;
|
my_symbol->output_options |= SMALL_TEXT;
|
||||||
} else {
|
} else {
|
||||||
hSymbol->output_options &= ~SMALL_TEXT;
|
my_symbol->output_options &= ~SMALL_TEXT;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case iReverse:
|
||||||
|
if (intValue) {
|
||||||
|
strcpy(my_symbol->fgcolour, "ffffff");
|
||||||
|
strcpy(my_symbol->bgcolour, "000000");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case iWError:
|
||||||
|
if (intValue) {
|
||||||
|
my_symbol->warn_level = WARN_FAIL_ALL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case iWZPL:
|
||||||
|
if (intValue) {
|
||||||
|
my_symbol->warn_level = WARN_ZPL_COMPAT;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case iFG:
|
case iFG:
|
||||||
strncpy(hSymbol->fgcolour, pStr, lStr);
|
strncpy(my_symbol->fgcolour, pStr, lStr);
|
||||||
hSymbol->fgcolour[lStr]='\0';
|
my_symbol->fgcolour[lStr]='\0';
|
||||||
break;
|
break;
|
||||||
case iBG:
|
case iBG:
|
||||||
strncpy(hSymbol->bgcolour, pStr, lStr);
|
strncpy(my_symbol->bgcolour, pStr, lStr);
|
||||||
hSymbol->bgcolour[lStr]='\0';
|
my_symbol->bgcolour[lStr]='\0';
|
||||||
break;
|
break;
|
||||||
case iNoBackground:
|
case iNoBackground:
|
||||||
if (intValue) {
|
if (intValue) {
|
||||||
strcpy(hSymbol->bgcolour, "ffffff00");
|
strcpy(my_symbol->bgcolour, "ffffff00");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case iNoText:
|
case iNoText:
|
||||||
hSymbol->show_hrt = (intValue?0:1);
|
my_symbol->show_hrt = (intValue?0:1);
|
||||||
break;
|
break;
|
||||||
case iSquare:
|
case iSquare:
|
||||||
/* DM_SQUARE overwrites DM_DMRE */
|
/* DM_SQUARE overwrites DM_DMRE */
|
||||||
if (intValue)
|
if (intValue)
|
||||||
hSymbol->option_3 = DM_SQUARE;
|
my_symbol->option_3 = DM_SQUARE;
|
||||||
break;
|
break;
|
||||||
case iDMRE:
|
case iDMRE:
|
||||||
/* DM_DMRE overwrites DM_SQUARE */
|
/* DM_DMRE overwrites DM_SQUARE */
|
||||||
if (intValue)
|
if (intValue)
|
||||||
hSymbol->option_3 = DM_DMRE;
|
my_symbol->option_3 = DM_DMRE;
|
||||||
break;
|
break;
|
||||||
case iScale:
|
case iScale:
|
||||||
if (doubleValue < 0.01) {
|
if (doubleValue < 0.01) {
|
||||||
@ -846,7 +891,7 @@ static int Encode(Tcl_Interp *interp, int objc,
|
|||||||
Tcl_NewStringObj("Scale below 0.01", -1));
|
Tcl_NewStringObj("Scale below 0.01", -1));
|
||||||
fError = 1;
|
fError = 1;
|
||||||
} else {
|
} else {
|
||||||
hSymbol->scale = (float)doubleValue;
|
my_symbol->scale = (float)doubleValue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case iBorder:
|
case iBorder:
|
||||||
@ -855,7 +900,7 @@ static int Encode(Tcl_Interp *interp, int objc,
|
|||||||
Tcl_NewStringObj("Border out of range", -1));
|
Tcl_NewStringObj("Border out of range", -1));
|
||||||
fError = 1;
|
fError = 1;
|
||||||
} else {
|
} else {
|
||||||
hSymbol->border_width = intValue;
|
my_symbol->border_width = intValue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case iHeight:
|
case iHeight:
|
||||||
@ -864,7 +909,7 @@ static int Encode(Tcl_Interp *interp, int objc,
|
|||||||
Tcl_NewStringObj("Height out of range", -1));
|
Tcl_NewStringObj("Height out of range", -1));
|
||||||
fError = 1;
|
fError = 1;
|
||||||
} else {
|
} else {
|
||||||
hSymbol->height = intValue;
|
my_symbol->height = intValue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case iSeparator:
|
case iSeparator:
|
||||||
@ -891,7 +936,7 @@ static int Encode(Tcl_Interp *interp, int objc,
|
|||||||
Tcl_NewStringObj("SCM version out of range", -1));
|
Tcl_NewStringObj("SCM version out of range", -1));
|
||||||
fError = 1;
|
fError = 1;
|
||||||
} else {
|
} else {
|
||||||
hSymbol->option_2 = intValue + 1;
|
my_symbol->option_2 = intValue + 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case iCols:
|
case iCols:
|
||||||
@ -905,7 +950,7 @@ static int Encode(Tcl_Interp *interp, int objc,
|
|||||||
Tcl_NewStringObj("cols/vers out of range", -1));
|
Tcl_NewStringObj("cols/vers out of range", -1));
|
||||||
fError = 1;
|
fError = 1;
|
||||||
} else {
|
} else {
|
||||||
hSymbol->option_2 = intValue;
|
my_symbol->option_2 = intValue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case iSecure:
|
case iSecure:
|
||||||
@ -920,11 +965,11 @@ static int Encode(Tcl_Interp *interp, int objc,
|
|||||||
Tcl_NewStringObj("secure/mode/rows out of range", -1));
|
Tcl_NewStringObj("secure/mode/rows out of range", -1));
|
||||||
fError = 1;
|
fError = 1;
|
||||||
} else {
|
} else {
|
||||||
hSymbol->option_1 = intValue;
|
my_symbol->option_1 = intValue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case iPrimary:
|
case iPrimary:
|
||||||
strcpy(hSymbol->primary, Tcl_DStringValue( &dString ) );
|
strcpy(my_symbol->primary, Tcl_DStringValue( &dString ) );
|
||||||
Tcl_DStringFree(&dString);
|
Tcl_DStringFree(&dString);
|
||||||
break;
|
break;
|
||||||
case iRotate:
|
case iRotate:
|
||||||
@ -957,11 +1002,11 @@ static int Encode(Tcl_Interp *interp, int objc,
|
|||||||
{
|
{
|
||||||
fError = 1;
|
fError = 1;
|
||||||
} else {
|
} else {
|
||||||
hSymbol->symbology = s_code_number[intValue];
|
my_symbol->symbology = s_code_number[intValue];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case iWhiteSp:
|
case iWhiteSp:
|
||||||
hSymbol->whitespace_width = intValue;
|
my_symbol->whitespace_width = intValue;
|
||||||
break;
|
break;
|
||||||
case iTo:
|
case iTo:
|
||||||
/* >> Decode the -to parameter as list of X0 Y0 ?Width Height? */
|
/* >> Decode the -to parameter as list of X0 Y0 ?Width Height? */
|
||||||
@ -1014,30 +1059,35 @@ static int Encode(Tcl_Interp *interp, int objc,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch (intValue) {
|
switch (intValue) {
|
||||||
case iBinary: hSymbol->input_mode = DATA_MODE; break;
|
case iBinary: my_symbol->input_mode = DATA_MODE; break;
|
||||||
case iGS1: hSymbol->input_mode = GS1_MODE; break;
|
case iGS1: my_symbol->input_mode = GS1_MODE; break;
|
||||||
default: hSymbol->input_mode = UNICODE_MODE; break;
|
default: my_symbol->input_mode = UNICODE_MODE; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* >>> Get symbology capability mask */
|
||||||
|
cap = ZBarcode_Cap(my_symbol->symbology,
|
||||||
|
ZINT_CAP_STACKABLE | ZINT_CAP_EXTENDABLE | ZINT_CAP_FULL_MULTIBYTE
|
||||||
|
| ZINT_CAP_MASK);
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
/* >>> option_3 is set by three values depending on the symbology */
|
/* >>> option_3 is set by three values depending on the symbology */
|
||||||
/* On wrong symbology, the option is ignored(as does the zint program)*/
|
/* On wrong symbology, the option is ignored(as does the zint program)*/
|
||||||
if (fFullMultiByte && ZBarcode_Cap(hSymbol->symbology, ZINT_CAP_FULL_MULTIBYTE)) {
|
if (fFullMultiByte && (cap & ZINT_CAP_FULL_MULTIBYTE)) {
|
||||||
hSymbol->option_3 = ZINT_FULL_MULTIBYTE;
|
my_symbol->option_3 = ZINT_FULL_MULTIBYTE;
|
||||||
}
|
}
|
||||||
if (Mask && ZBarcode_Cap(hSymbol->symbology, ZINT_CAP_MASK)) {
|
if (Mask && (cap & ZINT_CAP_MASK)) {
|
||||||
hSymbol->option_3 |= Mask << 8;
|
my_symbol->option_3 |= Mask << 8;
|
||||||
}
|
}
|
||||||
if (Separator && ZBarcode_Cap(hSymbol->symbology, ZINT_CAP_STACKABLE)) {
|
if (Separator && (cap & ZINT_CAP_STACKABLE)) {
|
||||||
hSymbol->option_3 = Separator;
|
my_symbol->option_3 = Separator;
|
||||||
}
|
}
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* >>> option_2 is set by two values depending on the symbology */
|
/* >>> option_2 is set by two values depending on the symbology */
|
||||||
/* On wrong symbology, the option is ignored(as does the zint program)*/
|
/* On wrong symbology, the option is ignored(as does the zint program)*/
|
||||||
if (addon_gap && ZBarcode_Cap(hSymbol->symbology, ZINT_CAP_EXTENDABLE)) {
|
if (addon_gap && (cap & ZINT_CAP_EXTENDABLE)) {
|
||||||
hSymbol->option_2 = addon_gap;
|
my_symbol->option_2 = addon_gap;
|
||||||
}
|
}
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* >>> Prepare input dstring and encode it to ECI encoding*/
|
/* >>> Prepare input dstring and encode it to ECI encoding*/
|
||||||
@ -1046,7 +1096,7 @@ static int Encode(Tcl_Interp *interp, int objc,
|
|||||||
if (!fError) {
|
if (!fError) {
|
||||||
/*--------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------*/
|
||||||
/* >>> Get input mode */
|
/* >>> Get input mode */
|
||||||
if (hSymbol->input_mode == DATA_MODE) {
|
if (my_symbol->input_mode == DATA_MODE) {
|
||||||
/* Binary data */
|
/* Binary data */
|
||||||
pStr = (char *) Tcl_GetByteArrayFromObj(objv[2], &lStr);
|
pStr = (char *) Tcl_GetByteArrayFromObj(objv[2], &lStr);
|
||||||
} else {
|
} else {
|
||||||
@ -1060,7 +1110,7 @@ static int Encode(Tcl_Interp *interp, int objc,
|
|||||||
fError = 1;
|
fError = 1;
|
||||||
}
|
}
|
||||||
/* we must indicate binary data */
|
/* we must indicate binary data */
|
||||||
hSymbol->input_mode = DATA_MODE;
|
my_symbol->input_mode = DATA_MODE;
|
||||||
}
|
}
|
||||||
if (! fError ) {
|
if (! fError ) {
|
||||||
pStr = Tcl_GetStringFromObj(objv[2], &lStr);
|
pStr = Tcl_GetStringFromObj(objv[2], &lStr);
|
||||||
@ -1077,13 +1127,13 @@ static int Encode(Tcl_Interp *interp, int objc,
|
|||||||
Tk_PhotoHandle hPhoto;
|
Tk_PhotoHandle hPhoto;
|
||||||
/*--------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------*/
|
||||||
/* call zint graphic creation to buffer */
|
/* call zint graphic creation to buffer */
|
||||||
ErrorNumber = ZBarcode_Encode_and_Buffer(hSymbol,
|
ErrorNumber = ZBarcode_Encode_and_Buffer(my_symbol,
|
||||||
(unsigned char *) pStr, lStr, rotate_angle);
|
(unsigned char *) pStr, lStr, rotate_angle);
|
||||||
/*--------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------*/
|
||||||
/* >> Show a message */
|
/* >> Show a message */
|
||||||
if( 0 != ErrorNumber )
|
if( 0 != ErrorNumber )
|
||||||
{
|
{
|
||||||
Tcl_SetObjResult(interp, Tcl_NewStringObj(hSymbol->errtxt, -1));
|
Tcl_SetObjResult(interp, Tcl_NewStringObj(my_symbol->errtxt, -1));
|
||||||
}
|
}
|
||||||
if( ZINT_ERROR <= ErrorNumber )
|
if( ZINT_ERROR <= ErrorNumber )
|
||||||
{
|
{
|
||||||
@ -1098,11 +1148,11 @@ static int Encode(Tcl_Interp *interp, int objc,
|
|||||||
} else {
|
} else {
|
||||||
Tk_PhotoImageBlock sImageBlock;
|
Tk_PhotoImageBlock sImageBlock;
|
||||||
char * pImageRGBA = NULL;
|
char * pImageRGBA = NULL;
|
||||||
if (hSymbol->alphamap == NULL) {
|
if (my_symbol->alphamap == NULL) {
|
||||||
sImageBlock.pixelPtr = (unsigned char *) hSymbol->bitmap;
|
sImageBlock.pixelPtr = (unsigned char *) my_symbol->bitmap;
|
||||||
sImageBlock.width = hSymbol->bitmap_width;
|
sImageBlock.width = my_symbol->bitmap_width;
|
||||||
sImageBlock.height = hSymbol->bitmap_height;
|
sImageBlock.height = my_symbol->bitmap_height;
|
||||||
sImageBlock.pitch = 3*hSymbol->bitmap_width;
|
sImageBlock.pitch = 3*my_symbol->bitmap_width;
|
||||||
sImageBlock.pixelSize = 3;
|
sImageBlock.pixelSize = 3;
|
||||||
sImageBlock.offset[0] = 0;
|
sImageBlock.offset[0] = 0;
|
||||||
sImageBlock.offset[1] = 1;
|
sImageBlock.offset[1] = 1;
|
||||||
@ -1111,17 +1161,17 @@ static int Encode(Tcl_Interp *interp, int objc,
|
|||||||
} else {
|
} else {
|
||||||
int index;
|
int index;
|
||||||
/* Alpha channel present - prepare the image data in rgba order */
|
/* Alpha channel present - prepare the image data in rgba order */
|
||||||
pImageRGBA = ckalloc(hSymbol->bitmap_width*hSymbol->bitmap_height*4);
|
pImageRGBA = ckalloc(my_symbol->bitmap_width*my_symbol->bitmap_height*4);
|
||||||
for (index = 0; index < hSymbol->bitmap_width*hSymbol->bitmap_height; index++) {
|
for (index = 0; index < my_symbol->bitmap_width*my_symbol->bitmap_height; index++) {
|
||||||
pImageRGBA[index*4] = hSymbol->bitmap[index*3];
|
pImageRGBA[index*4] = my_symbol->bitmap[index*3];
|
||||||
pImageRGBA[index*4+1] = hSymbol->bitmap[index*3+1];
|
pImageRGBA[index*4+1] = my_symbol->bitmap[index*3+1];
|
||||||
pImageRGBA[index*4+2] = hSymbol->bitmap[index*3+2];
|
pImageRGBA[index*4+2] = my_symbol->bitmap[index*3+2];
|
||||||
pImageRGBA[index*4+3] = hSymbol->alphamap[index];
|
pImageRGBA[index*4+3] = my_symbol->alphamap[index];
|
||||||
}
|
}
|
||||||
sImageBlock.pixelPtr = (unsigned char *) pImageRGBA;
|
sImageBlock.pixelPtr = (unsigned char *) pImageRGBA;
|
||||||
sImageBlock.width = hSymbol->bitmap_width;
|
sImageBlock.width = my_symbol->bitmap_width;
|
||||||
sImageBlock.height = hSymbol->bitmap_height;
|
sImageBlock.height = my_symbol->bitmap_height;
|
||||||
sImageBlock.pitch = 4*hSymbol->bitmap_width;
|
sImageBlock.pitch = 4*my_symbol->bitmap_width;
|
||||||
sImageBlock.pixelSize = 4;
|
sImageBlock.pixelSize = 4;
|
||||||
sImageBlock.offset[0] = 0;
|
sImageBlock.offset[0] = 0;
|
||||||
sImageBlock.offset[1] = 1;
|
sImageBlock.offset[1] = 1;
|
||||||
@ -1129,10 +1179,10 @@ static int Encode(Tcl_Interp *interp, int objc,
|
|||||||
sImageBlock.offset[3] = 3;
|
sImageBlock.offset[3] = 3;
|
||||||
}
|
}
|
||||||
if (0 == destWidth) {
|
if (0 == destWidth) {
|
||||||
destWidth = hSymbol->bitmap_width;
|
destWidth = my_symbol->bitmap_width;
|
||||||
}
|
}
|
||||||
if (0 == destHeight) {
|
if (0 == destHeight) {
|
||||||
destHeight = hSymbol->bitmap_height;
|
destHeight = my_symbol->bitmap_height;
|
||||||
}
|
}
|
||||||
if (TCL_OK != Tk_PhotoPutBlock(interp, hPhoto, &sImageBlock,
|
if (TCL_OK != Tk_PhotoPutBlock(interp, hPhoto, &sImageBlock,
|
||||||
destX0, destY0, destWidth, destHeight,
|
destX0, destY0, destWidth, destHeight,
|
||||||
@ -1148,7 +1198,7 @@ static int Encode(Tcl_Interp *interp, int objc,
|
|||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
Tcl_FreeEncoding(hZINTEncoding);
|
Tcl_FreeEncoding(hZINTEncoding);
|
||||||
Tcl_DStringFree(& dsInput);
|
Tcl_DStringFree(& dsInput);
|
||||||
ZBarcode_Delete(hSymbol);
|
ZBarcode_Delete(my_symbol);
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
if (fError) {
|
if (fError) {
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
|
Loading…
Reference in New Issue
Block a user