- zint_symbol->fgcolour & bgcolour buffer lengths extended 10

-> 16 to allow for "C,M,Y,K" comma-separated decimal percentage
  strings
- API/CLI/GUI: allow foreground/background colours to be specified
  as comma-separated decimal "C,M,Y,K" strings where "C", "M" etc.
  are percentages (0-100) (ticket #281, 3rd point)
- output.c: new funcs `out_colour_get_rgb()` & `out_colour_get_cmyk()`
  and use in bmp/emf/gif etc.
- PCX: add alpha support
- GUI: fix fg/gbcolor icon background not being reset on zap
- GUI: Rearrange some Appearance tab inputs (Border Type <-> Width,
  Show Text <-> Font, Text/Font <-> Printing Scale/Size) to flow
  more naturally (hopefully)
- GUI: save button "Save As..." -> "Save..." and add icon
- CLI: add --bgcolor/colour & --fgcolor/colour synonyms
This commit is contained in:
gitlost 2023-01-29 19:51:11 +00:00
parent 48eaa0cc4e
commit ab2abccdb6
55 changed files with 1439 additions and 886 deletions

View File

@ -3,7 +3,10 @@ Version 2.12.0.9 (dev) not released yet
**Incompatible changes** **Incompatible changes**
------------------------ ------------------------
- None yet - zint_symbol fgcolour and bgcolour buffer lengths extended 10 -> 16 to allow
for "C,M,Y,K" comma-separated decimal percentage strings
- CMYK values for EPS (slightly) and TIF (significantly) have changed - now use
the same RGB -> CMYK formula
Changes Changes
------- -------
@ -15,6 +18,13 @@ Changes
(ticket #204) (ticket #204)
- GUI: disable "Reset" colour if default; add "Unset" to Printing Scale dialog - GUI: disable "Reset" colour if default; add "Unset" to Printing Scale dialog
(allows unsetting of X-dim/resolution settings without having to zap) (allows unsetting of X-dim/resolution settings without having to zap)
- API/CLI/GUI: allow foreground/background colours to be specified as
comma-separated decimal percentage strings "C,M,Y,K" where "C", "M" etc. are
0-100 (ticket #281, 3rd point)
- PCX: add alpha support
- GUI: Rearrange some Appearance tab inputs (Border Type <-> Width, Show Text
<-> Font, Text/Font <-> Printing Scale/Size) to flow more naturally;
save button "Save As..." -> "Save..." and add icon
Bugs Bugs
---- ----
@ -24,6 +34,7 @@ Bugs
LD_LIBRARY_PATH and PATH (ticket #279, props Alexey Dokuchaev) LD_LIBRARY_PATH and PATH (ticket #279, props Alexey Dokuchaev)
- GUI: fg/bgcolor text edit: fix right-click context menu not working properly - GUI: fg/bgcolor text edit: fix right-click context menu not working properly
by checking for it on FocusOut by checking for it on FocusOut
- GUI: fix fg/gbcolor icon background not being reset on zap
Version 2.12.0 (2022-12-12) Version 2.12.0 (2022-12-12)

View File

@ -1,7 +1,7 @@
/* bmp.c - Handles output to Windows Bitmap file */ /* bmp.c - Handles output to Windows Bitmap file */
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2009-2022 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2009-2023 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -41,7 +41,7 @@
#include "output.h" #include "output.h"
#include "bmp.h" /* Bitmap header structure */ #include "bmp.h" /* Bitmap header structure */
INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) { INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, const unsigned char *pixelbuf) {
int i, row, column; int i, row, column;
int row_size; int row_size;
int bits_per_pixel; int bits_per_pixel;
@ -57,18 +57,19 @@ INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
color_ref_t fg_color_ref; color_ref_t fg_color_ref;
color_ref_t ultra_color_ref[8]; color_ref_t ultra_color_ref[8];
int ultra_fg_index = 9; int ultra_fg_index = 9;
unsigned char map[128];
const int output_to_stdout = symbol->output_options & BARCODE_STDOUT; /* Suppress gcc -fanalyzer warning */ const int output_to_stdout = symbol->output_options & BARCODE_STDOUT; /* Suppress gcc -fanalyzer warning */
fg_color_ref.red = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]); (void) out_colour_get_rgb(symbol->fgcolour, &fg_color_ref.red, &fg_color_ref.green, &fg_color_ref.blue,
fg_color_ref.green = (16 * ctoi(symbol->fgcolour[2])) + ctoi(symbol->fgcolour[3]); NULL /*alpha*/);
fg_color_ref.blue = (16 * ctoi(symbol->fgcolour[4])) + ctoi(symbol->fgcolour[5]);
fg_color_ref.reserved = 0x00; fg_color_ref.reserved = 0x00;
bg_color_ref.red = (16 * ctoi(symbol->bgcolour[0])) + ctoi(symbol->bgcolour[1]);
bg_color_ref.green = (16 * ctoi(symbol->bgcolour[2])) + ctoi(symbol->bgcolour[3]); (void) out_colour_get_rgb(symbol->bgcolour, &bg_color_ref.red, &bg_color_ref.green, &bg_color_ref.blue,
bg_color_ref.blue = (16 * ctoi(symbol->bgcolour[4])) + ctoi(symbol->bgcolour[5]); NULL /*alpha*/);
bg_color_ref.reserved = 0x00; bg_color_ref.reserved = 0x00;
if (symbol->symbology == BARCODE_ULTRA) { if (symbol->symbology == BARCODE_ULTRA) {
static const int ultra_chars[8] = { 'C', 'B', 'M', 'R', 'Y', 'G', 'K', 'W' };
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
ultra_color_ref[i].red = colour_to_red(i + 1); ultra_color_ref[i].red = colour_to_red(i + 1);
ultra_color_ref[i].green = colour_to_green(i + 1); ultra_color_ref[i].green = colour_to_green(i + 1);
@ -77,12 +78,17 @@ INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
if (memcmp(&ultra_color_ref[i], &fg_color_ref, sizeof(fg_color_ref)) == 0) { if (memcmp(&ultra_color_ref[i], &fg_color_ref, sizeof(fg_color_ref)) == 0) {
ultra_fg_index = i + 1; ultra_fg_index = i + 1;
} }
map[ultra_chars[i]] = i + 1;
} }
bits_per_pixel = 4; bits_per_pixel = 4;
colour_count = ultra_fg_index == 9 ? 10 : 9; colour_count = ultra_fg_index == 9 ? 10 : 9;
map['0'] = 0;
map['1'] = ultra_fg_index;
} else { } else {
bits_per_pixel = 1; bits_per_pixel = 1;
colour_count = 2; colour_count = 2;
map['0'] = 0;
map['1'] = 0x80;
} }
row_size = 4 * ((bits_per_pixel * symbol->bitmap_width + 31) / 32); row_size = 4 * ((bits_per_pixel * symbol->bitmap_width + 31) / 32);
data_size = symbol->bitmap_height * row_size; data_size = symbol->bitmap_height * row_size;
@ -102,46 +108,16 @@ INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
/* Pixel Plotting */ /* Pixel Plotting */
if (symbol->symbology == BARCODE_ULTRA) { if (symbol->symbology == BARCODE_ULTRA) {
for (row = 0; row < symbol->bitmap_height; row++) { for (row = 0; row < symbol->bitmap_height; row++) {
const unsigned char *pb = pixelbuf + (symbol->bitmap_width * (symbol->bitmap_height - row - 1));
for (column = 0; column < symbol->bitmap_width; column++) { for (column = 0; column < symbol->bitmap_width; column++) {
i = (column / 2) + (row * row_size); bitmap[(column >> 1) + (row * row_size)] |= map[pb[column]] << (!(column & 1) << 2);
switch (*(pixelbuf + (symbol->bitmap_width * (symbol->bitmap_height - row - 1)) + column)) {
case 'C': /* Cyan */
bitmap[i] += 1 << (4 * (1 - (column % 2)));
break;
case 'B': /* Blue */
bitmap[i] += 2 << (4 * (1 - (column % 2)));
break;
case 'M': /* Magenta */
bitmap[i] += 3 << (4 * (1 - (column % 2)));
break;
case 'R': /* Red */
bitmap[i] += 4 << (4 * (1 - (column % 2)));
break;
case 'Y': /* Yellow */
bitmap[i] += 5 << (4 * (1 - (column % 2)));
break;
case 'G': /* Green */
bitmap[i] += 6 << (4 * (1 - (column % 2)));
break;
case 'K': /* Black */
bitmap[i] += 7 << (4 * (1 - (column % 2)));
break;
case 'W': /* White */
bitmap[i] += 8 << (4 * (1 - (column % 2)));
break;
case '1': /* Foreground */
bitmap[i] += ultra_fg_index << (4 * (1 - (column % 2)));
break;
}
} }
} }
} else { } else {
for (row = 0; row < symbol->bitmap_height; row++) { for (row = 0; row < symbol->bitmap_height; row++) {
const unsigned char *pb = pixelbuf + (symbol->bitmap_width * (symbol->bitmap_height - row - 1));
for (column = 0; column < symbol->bitmap_width; column++) { for (column = 0; column < symbol->bitmap_width; column++) {
i = (column / 8) + (row * row_size); bitmap[(column >> 3) + (row * row_size)] |= map[pb[column]] >> (column & 7);
if ((*(pixelbuf + (symbol->bitmap_width * (symbol->bitmap_height - row - 1)) + column)) == '1') {
bitmap[i] += (0x01 << (7 - (column % 8)));
}
} }
} }
} }

View File

@ -1,7 +1,7 @@
/* emf.c - Support for Microsoft Enhanced Metafile Format */ /* emf.c - Support for Microsoft Enhanced Metafile Format */
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2016-2022 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2016-2023 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -168,7 +168,7 @@ static int utfle_length(unsigned char *input, int length) {
INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) { INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
int i; int i;
FILE *emf_file; FILE *emf_file;
int fgred, fggrn, fgblu, bgred, bggrn, bgblu; unsigned char fgred, fggrn, fgblu, bgred, bggrn, bgblu, bgalpha;
int error_number = 0; int error_number = 0;
int rectangle_count, this_rectangle; int rectangle_count, this_rectangle;
int circle_count, this_circle; int circle_count, this_circle;
@ -248,17 +248,10 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
return ZINT_ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
fgred = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]); (void) out_colour_get_rgb(symbol->fgcolour, &fgred, &fggrn, &fgblu, NULL /*alpha*/);
fggrn = (16 * ctoi(symbol->fgcolour[2])) + ctoi(symbol->fgcolour[3]); (void) out_colour_get_rgb(symbol->bgcolour, &bgred, &bggrn, &bgblu, &bgalpha);
fgblu = (16 * ctoi(symbol->fgcolour[4])) + ctoi(symbol->fgcolour[5]); if (bgalpha == 0) {
bgred = (16 * ctoi(symbol->bgcolour[0])) + ctoi(symbol->bgcolour[1]); draw_background = 0;
bggrn = (16 * ctoi(symbol->bgcolour[2])) + ctoi(symbol->bgcolour[3]);
bgblu = (16 * ctoi(symbol->bgcolour[4])) + ctoi(symbol->bgcolour[5]);
if (strlen(symbol->bgcolour) > 6) {
if ((ctoi(symbol->bgcolour[6]) == 0) && (ctoi(symbol->bgcolour[7]) == 0)) {
draw_background = 0;
}
} }
rectangle_count = count_rectangles(symbol); rectangle_count = count_rectangles(symbol);

View File

@ -1,7 +1,7 @@
/* gif.c - Handles output to gif file */ /* gif.c - Handles output to gif file */
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2009-2022 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2009-2023 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -44,7 +44,7 @@
typedef struct s_statestruct { typedef struct s_statestruct {
unsigned char *pOut; unsigned char *pOut;
unsigned char *pIn; const unsigned char *pIn;
unsigned int InLen; unsigned int InLen;
unsigned int OutLength; unsigned int OutLength;
unsigned int OutPosCur; unsigned int OutPosCur;
@ -297,6 +297,10 @@ INTERNAL int gif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
unsigned char backgroundColourIndex; unsigned char backgroundColourIndex;
unsigned char RGBCur[3]; unsigned char RGBCur[3];
unsigned char RGBUnused[3] = {0,0,0}; unsigned char RGBUnused[3] = {0,0,0};
unsigned char RGBfg[3];
unsigned char RGBbg[3];
unsigned char fgalpha;
unsigned char bgalpha;
int colourIndex; int colourIndex;
@ -311,6 +315,9 @@ INTERNAL int gif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
lzoutbufSize = GIF_LZW_PAGE_SIZE; lzoutbufSize = GIF_LZW_PAGE_SIZE;
} }
(void) out_colour_get_rgb(symbol->fgcolour, &RGBfg[0], &RGBfg[1], &RGBfg[2], &fgalpha);
(void) out_colour_get_rgb(symbol->bgcolour, &RGBbg[0], &RGBbg[1], &RGBbg[2], &bgalpha);
/* /*
* Build a table of the used palette items. * Build a table of the used palette items.
* Currently, there are the following 10 colour codes: * Currently, there are the following 10 colour codes:
@ -364,14 +371,10 @@ INTERNAL int gif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
/* Get RGB value */ /* Get RGB value */
switch (pixelColour) { switch (pixelColour) {
case '0': /* standard background */ case '0': /* standard background */
RGBCur[0] = (unsigned char) (16 * ctoi(symbol->bgcolour[0])) + ctoi(symbol->bgcolour[1]); RGBCur[0] = RGBbg[0]; RGBCur[1] = RGBbg[1]; RGBCur[2] = RGBbg[2];
RGBCur[1] = (unsigned char) (16 * ctoi(symbol->bgcolour[2])) + ctoi(symbol->bgcolour[3]);
RGBCur[2] = (unsigned char) (16 * ctoi(symbol->bgcolour[4])) + ctoi(symbol->bgcolour[5]);
break; break;
case '1': /* standard foreground */ case '1': /* standard foreground */
RGBCur[0] = (unsigned char) (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]); RGBCur[0] = RGBfg[0]; RGBCur[1] = RGBfg[1]; RGBCur[2] = RGBfg[2];
RGBCur[1] = (unsigned char) (16 * ctoi(symbol->fgcolour[2])) + ctoi(symbol->fgcolour[3]);
RGBCur[2] = (unsigned char) (16 * ctoi(symbol->fgcolour[4])) + ctoi(symbol->fgcolour[5]);
break; break;
case 'W': /* white */ case 'W': /* white */
RGBCur[0] = 255; RGBCur[1] = 255; RGBCur[2] = 255; RGBCur[0] = 255; RGBCur[1] = 255; RGBCur[2] = 255;
@ -436,17 +439,12 @@ INTERNAL int gif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
/* Note: does not allow both transparent foreground and background - /* Note: does not allow both transparent foreground and background -
* background takes priority */ * background takes priority */
transparent_index = -1; transparent_index = -1;
if (strlen(symbol->fgcolour) > 6) { if (bgalpha == 0) {
if ((symbol->fgcolour[6] == '0') && (symbol->fgcolour[7] == '0')) { /* Transparent background */
/* Transparent foreground */ transparent_index = bgindex;
transparent_index = fgindex; } else if (fgalpha == 0) {
} /* Transparent foreground */
} transparent_index = fgindex;
if (strlen(symbol->bgcolour) > 6) {
if ((symbol->bgcolour[6] == '0') && (symbol->bgcolour[7] == '0')) {
/* Transparent background */
transparent_index = bgindex;
}
} }
/* find palette bit size from palette size*/ /* find palette bit size from palette size*/

View File

@ -1,7 +1,7 @@
/* output.c - Common routines for raster/vector /* output.c - Common routines for raster/vector
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2020-2022 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2020-2023 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -43,38 +43,153 @@
#include "output.h" #include "output.h"
#include "font.h" #include "font.h"
#define SSET_F (IS_NUM_F | IS_UHX_F) /* SSET "0123456789ABCDEF" */ #define OUT_SSET_F (IS_NUM_F | IS_UHX_F | IS_LHX_F) /* SSET "0123456789ABCDEFabcdef" */
/* Check colour options are good. Note: using raster.c error nos 651-654 */ /* Helper to check an individual colour option is good */
INTERNAL int out_check_colour_options(struct zint_symbol *symbol) { static int out_check_colour(struct zint_symbol *symbol, const char *colour, const char *name) {
int fg_len = (int) strlen(symbol->fgcolour); const char *comma1, *comma2, *comma3;
int bg_len = (int) strlen(symbol->bgcolour); int val;
if ((fg_len != 6) && (fg_len != 8)) { if ((comma1 = strchr(colour, ',')) == NULL) {
strcpy(symbol->errtxt, "651: Malformed foreground colour (6 or 8 characters only)"); const int len = (int) strlen(colour);
if ((len != 6) && (len != 8)) {
sprintf(symbol->errtxt, "690: Malformed %s RGB colour (6 or 8 characters only)", name);
return ZINT_ERROR_INVALID_OPTION;
}
if (!is_sane(OUT_SSET_F, (unsigned char *) colour, len)) {
sprintf(symbol->errtxt, "691: Malformed %s RGB colour '%s' (hexadecimal only)", name, colour);
return ZINT_ERROR_INVALID_OPTION;
}
return 0;
}
/* CMYK comma-separated percentages */
if ((comma2 = strchr(comma1 + 1, ',')) == NULL || (comma3 = strchr(comma2 + 1, ',')) == NULL
|| strchr(comma3 + 1, ',') != NULL) {
sprintf(symbol->errtxt, "692: Malformed %s CMYK colour (4 decimal numbers, comma-separated)", name);
return ZINT_ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
if ((bg_len != 6) && (bg_len != 8)) { if (comma1 - colour > 3 || comma2 - (comma1 + 1) > 3 || comma3 - (comma2 + 1) > 3 || strlen(comma3 + 1) > 3) {
strcpy(symbol->errtxt, "652: Malformed background colour (6 or 8 characters only)"); sprintf(symbol->errtxt, "693: Malformed %s CMYK colour (3 digit maximum per number)", name);
return ZINT_ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
to_upper((unsigned char *) symbol->fgcolour, fg_len); if ((val = to_int((const unsigned char *) colour, (int) (comma1 - colour))) == -1 || val > 100) {
to_upper((unsigned char *) symbol->bgcolour, bg_len); sprintf(symbol->errtxt, "694: Malformed %s CMYK colour C (decimal 0-100 only)", name);
if (!is_sane(SSET_F, (unsigned char *) symbol->fgcolour, fg_len)) {
sprintf(symbol->errtxt, "653: Malformed foreground colour '%s' (hexadecimal only)", symbol->fgcolour);
return ZINT_ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
if ((val = to_int((const unsigned char *) (comma1 + 1), (int) (comma2 - (comma1 + 1)))) == -1 || val > 100) {
if (!is_sane(SSET_F, (unsigned char *) symbol->bgcolour, bg_len)) { sprintf(symbol->errtxt, "695: Malformed %s CMYK colour M (decimal 0-100 only)", name);
sprintf(symbol->errtxt, "654: Malformed background colour '%s' (hexadecimal only)", symbol->bgcolour); return ZINT_ERROR_INVALID_OPTION;
}
if ((val = to_int((const unsigned char *) (comma2 + 1), (int) (comma3 - (comma2 + 1)))) == -1 || val > 100) {
sprintf(symbol->errtxt, "696: Malformed %s CMYK colour Y (decimal 0-100 only)", name);
return ZINT_ERROR_INVALID_OPTION;
}
if ((val = to_int((const unsigned char *) (comma3 + 1), (int) strlen(comma3 + 1))) == -1 || val > 100) {
sprintf(symbol->errtxt, "697: Malformed %s CMYK colour K (decimal 0-100 only)", name);
return ZINT_ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
return 0; return 0;
} }
/* Check colour options are good (`symbol->fgcolour`, `symbol->bgcolour`) */
INTERNAL int out_check_colour_options(struct zint_symbol *symbol) {
if (out_check_colour(symbol, symbol->fgcolour, "foreground") != 0) {
return ZINT_ERROR_INVALID_OPTION;
}
if (out_check_colour(symbol, symbol->bgcolour, "background") != 0) {
return ZINT_ERROR_INVALID_OPTION;
}
return 0;
}
/* Return RGB(A) from (well-formed) colour string. Returns 0 if RGB or converted CMYK, 1 if RGBA */
INTERNAL int out_colour_get_rgb(const char *colour, unsigned char *red, unsigned char *green, unsigned char *blue,
unsigned char *alpha) {
const char *comma1, *comma2, *comma3;
int black, val;
if ((comma1 = strchr(colour, ',')) == NULL) {
*red = 16 * ctoi(colour[0]) + ctoi(colour[1]);
*green = 16 * ctoi(colour[2]) + ctoi(colour[3]);
*blue = 16 * ctoi(colour[4]) + ctoi(colour[5]);
if (alpha) {
*alpha = colour[6] ? 16 * ctoi(colour[6]) + ctoi(colour[7]) : 0xFF;
return colour[6] ? 1 : 0;
}
return 0;
}
comma2 = strchr(comma1 + 1, ',');
comma3 = strchr(comma2 + 1, ',');
black = 100 - to_int((const unsigned char *) (comma3 + 1), (int) strlen(comma3 + 1));
val = 100 - to_int((const unsigned char *) colour, (int) (comma1 - colour)); /* Cyan */
*red = (int) roundf((0xFF * val * black) / 10000.0f);
val = 100 - to_int((const unsigned char *) (comma1 + 1), (int) (comma2 - (comma1 + 1))); /* Magenta */
*green = (int) roundf((0xFF * val * black) / 10000.0f);
val = 100 - to_int((const unsigned char *) (comma2 + 1), (int) (comma3 - (comma2 + 1))); /* Yellow */
*blue = (int) roundf((0xFF * val * black) / 10000.0f);
if (alpha) {
*alpha = 0xFF;
}
return 0;
}
/* Return CMYK from (well-formed) colour string. Returns 0 if CMYK, 1 if converted RBG, 2 if converted RGBA */
INTERNAL int out_colour_get_cmyk(const char *colour, int *cyan, int *magenta, int *yellow, int *black,
unsigned char *rgb_alpha) {
const char *comma1;
unsigned char red, green, blue, alpha;
int have_alpha, k;
if ((comma1 = strchr(colour, ',')) != NULL) {
const char *const comma2 = strchr(comma1 + 1, ',');
const char *const comma3 = strchr(comma2 + 1, ',');
*cyan = to_int((const unsigned char *) colour, (int) (comma1 - colour));
*magenta = to_int((const unsigned char *) (comma1 + 1), (int) (comma2 - (comma1 + 1)));
*yellow = to_int((const unsigned char *) (comma2 + 1), (int) (comma3 - (comma2 + 1)));
*black = to_int((const unsigned char *) (comma3 + 1), (int) strlen(comma3 + 1));
if (rgb_alpha) {
*rgb_alpha = 0xFF;
}
return 0;
}
have_alpha = out_colour_get_rgb(colour, &red, &green, &blue, &alpha);
k = red;
if (green > k) {
k = green;
}
if (blue > k) {
k = blue;
}
if (k == 0) {
*cyan = *magenta = *yellow = 0;
*black = 100;
} else {
*cyan = (int) roundf((k - red) * 100.0f / k);
*magenta = (int) roundf((k - green) * 100.0f / k);
*yellow = (int) roundf((k - blue) * 100.0f / k);
*black = (int) roundf(((0xFF - k) * 100.0f) / 0xFF);
}
if (rgb_alpha) {
*rgb_alpha = have_alpha ? alpha : 0xFF;
}
return 1 + have_alpha;
}
/* Return minimum quiet zones for each symbology */ /* Return minimum quiet zones for each symbology */
static int out_quiet_zones(const struct zint_symbol *symbol, const int hide_text, static int out_quiet_zones(const struct zint_symbol *symbol, const int hide_text,
float *left, float *right, float *top, float *bottom) { float *left, float *right, float *top, float *bottom) {
@ -761,8 +876,7 @@ INTERNAL void out_upcean_split_text(int upceanflag, unsigned char text[],
/* Make a directory; already existing dir okay */ /* Make a directory; already existing dir okay */
/* Adapted from https://gist.github.com/JonathonReinhart/8c0d90191c38af2dcadb102c4e202950 and /* Adapted from https://gist.github.com/JonathonReinhart/8c0d90191c38af2dcadb102c4e202950 and
https://nachtimwald.com/2019/07/10/recursive-create-directory-in-c-revisited/ */ https://nachtimwald.com/2019/07/10/recursive-create-directory-in-c-revisited/ */
static int out_maybe_mkdir(const char* path) static int out_maybe_mkdir(const char* path) {
{
#ifdef _WIN32 #ifdef _WIN32
DWORD dwAttrib; DWORD dwAttrib;

View File

@ -1,7 +1,7 @@
/* output.h - Common routines for raster/vector */ /* output.h - Common routines for raster/vector */
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2020-2022 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2020-2023 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -39,16 +39,37 @@ extern "C" {
#include <stdio.h> /* For FILE */ #include <stdio.h> /* For FILE */
/* Check colour options are good (`symbol->fgcolour`, `symbol->bgcolour`) */
INTERNAL int out_check_colour_options(struct zint_symbol *symbol); INTERNAL int out_check_colour_options(struct zint_symbol *symbol);
/* Return RGB(A) from (well-formed) colour string. Returns 0 if RGB or converted CMYK, 1 if RGBA */
INTERNAL int out_colour_get_rgb(const char *colour, unsigned char *red, unsigned char *green, unsigned char *blue,
unsigned char *alpha);
/* Return CMYK from (well-formed) colour string. Returns 0 if CMYK, 1 if converted RBG, 2 if converted RGBA */
INTERNAL int out_colour_get_cmyk(const char *colour, int *cyan, int *magenta, int *yellow, int *black,
unsigned char *rgb_alpha);
/* Set left (x), top (y), right and bottom offsets for whitespace */
INTERNAL void out_set_whitespace_offsets(const struct zint_symbol *symbol, const int hide_text, INTERNAL void out_set_whitespace_offsets(const struct zint_symbol *symbol, const int hide_text,
float *xoffset, float *yoffset, float *roffset, float *boffset, const float scaler, float *xoffset, float *yoffset, float *roffset, float *boffset, const float scaler,
int *xoffset_si, int *yoffset_si, int *roffset_si, int *boffset_si); int *xoffset_si, int *yoffset_si, int *roffset_si, int *boffset_si);
/* Set composite offset and main width excluding addon (for start of addon calc) and addon text, returning
UPC/EAN type */
INTERNAL int out_process_upcean(const struct zint_symbol *symbol, int *p_main_width, int *p_comp_xoffset, INTERNAL int out_process_upcean(const struct zint_symbol *symbol, int *p_main_width, int *p_comp_xoffset,
unsigned char addon[6], int *p_addon_gap); unsigned char addon[6], int *p_addon_gap);
/* Calculate large bar height i.e. linear bars with zero row height that respond to the symbol height.
If scaler `si` non-zero (raster), then large_bar_height if non-zero or else row heights will be rounded
to nearest pixel and symbol height adjusted */
INTERNAL float out_large_bar_height(struct zint_symbol *symbol, int si, int *row_heights_si, int *symbol_height_si); INTERNAL float out_large_bar_height(struct zint_symbol *symbol, int si, int *row_heights_si, int *symbol_height_si);
/* Split UPC/EAN add-on text into various constituents */
INTERNAL void out_upcean_split_text(int upceanflag, unsigned char text[], INTERNAL void out_upcean_split_text(int upceanflag, unsigned char text[],
unsigned char textpart1[5], unsigned char textpart2[7], unsigned char textpart3[7], unsigned char textpart1[5], unsigned char textpart2[7], unsigned char textpart3[7],
unsigned char textpart4[2]); unsigned char textpart4[2]);
/* Create output file, creating sub-directories if necessary. Returns `fopen()` FILE pointer */
INTERNAL FILE *out_fopen(const char filename[256], const char *mode); INTERNAL FILE *out_fopen(const char filename[256], const char *mode);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -1,7 +1,7 @@
/* pcx.c - Handles output to ZSoft PCX file */ /* pcx.c - Handles output to ZSoft PCX file */
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2009-2022 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2009-2023 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -42,8 +42,8 @@
#include "pcx.h" /* PCX header structure */ #include "pcx.h" /* PCX header structure */
/* ZSoft PCX File Format Technical Reference Manual http://bespin.org/~qz/pc-gpe/pcx.txt */ /* ZSoft PCX File Format Technical Reference Manual http://bespin.org/~qz/pc-gpe/pcx.txt */
INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) { INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, const unsigned char *pixelbuf) {
int fgred, fggrn, fgblu, bgred, bggrn, bgblu; unsigned char fgred, fggrn, fgblu, fgalpha, bgred, bggrn, bgblu, bgalpha;
int row, column, i, colour; int row, column, i, colour;
int run_count; int run_count;
FILE *pcx_file; FILE *pcx_file;
@ -55,17 +55,13 @@ INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
rle_row[bytes_per_line - 1] = 0; /* Will remain zero if bitmap_width odd */ rle_row[bytes_per_line - 1] = 0; /* Will remain zero if bitmap_width odd */
fgred = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]); (void) out_colour_get_rgb(symbol->fgcolour, &fgred, &fggrn, &fgblu, &fgalpha);
fggrn = (16 * ctoi(symbol->fgcolour[2])) + ctoi(symbol->fgcolour[3]); (void) out_colour_get_rgb(symbol->bgcolour, &bgred, &bggrn, &bgblu, &bgalpha);
fgblu = (16 * ctoi(symbol->fgcolour[4])) + ctoi(symbol->fgcolour[5]);
bgred = (16 * ctoi(symbol->bgcolour[0])) + ctoi(symbol->bgcolour[1]);
bggrn = (16 * ctoi(symbol->bgcolour[2])) + ctoi(symbol->bgcolour[3]);
bgblu = (16 * ctoi(symbol->bgcolour[4])) + ctoi(symbol->bgcolour[5]);
header.manufacturer = 10; /* ZSoft */ header.manufacturer = 10; /* ZSoft */
header.version = 5; /* Version 3.0 */ header.version = 5; /* Version 3.0 */
header.encoding = 1; /* Run length encoding */ header.encoding = 1; /* Run length encoding */
header.bits_per_pixel = 8; header.bits_per_pixel = 8; /* TODO: 1-bit monochrome black/white */
header.window_xmin = 0; header.window_xmin = 0;
header.window_ymin = 0; header.window_ymin = 0;
header.window_xmax = symbol->bitmap_width - 1; header.window_xmax = symbol->bitmap_width - 1;
@ -78,7 +74,7 @@ INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
} }
header.reserved = 0; header.reserved = 0;
header.number_of_planes = 3; header.number_of_planes = 3 + (fgalpha != 0xFF || bgalpha != 0xFF); /* TODO: 1-bit monochrome black/white */
header.bytes_per_line = bytes_per_line; header.bytes_per_line = bytes_per_line;
@ -109,11 +105,13 @@ INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
fwrite(&header, sizeof(pcx_header_t), 1, pcx_file); fwrite(&header, sizeof(pcx_header_t), 1, pcx_file);
for (row = 0; row < symbol->bitmap_height; row++) { for (row = 0; row < symbol->bitmap_height; row++) {
for (colour = 0; colour < 3; colour++) { const unsigned char *const pb = pixelbuf + row * symbol->bitmap_width;
for (colour = 0; colour < header.number_of_planes; colour++) {
for (column = 0; column < symbol->bitmap_width; column++) { for (column = 0; column < symbol->bitmap_width; column++) {
const unsigned char ch = pb[column];
switch (colour) { switch (colour) {
case 0: case 0:
switch (pixelbuf[(row * symbol->bitmap_width) + column]) { switch (ch) {
case 'W': /* White */ case 'W': /* White */
case 'M': /* Magenta */ case 'M': /* Magenta */
case 'R': /* Red */ case 'R': /* Red */
@ -135,7 +133,7 @@ INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
} }
break; break;
case 1: case 1:
switch (pixelbuf[(row * symbol->bitmap_width) + column]) { switch (ch) {
case 'W': /* White */ case 'W': /* White */
case 'C': /* Cyan */ case 'C': /* Cyan */
case 'Y': /* Yellow */ case 'Y': /* Yellow */
@ -157,7 +155,7 @@ INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
} }
break; break;
case 2: case 2:
switch (pixelbuf[(row * symbol->bitmap_width) + column]) { switch (ch) {
case 'W': /* White */ case 'W': /* White */
case 'C': /* Cyan */ case 'C': /* Cyan */
case 'B': /* Blue */ case 'B': /* Blue */
@ -178,6 +176,9 @@ INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
break; break;
} }
break; break;
case 3:
rle_row[column] = ch != '0' ? fgalpha : bgalpha;
break;
} }
} }

View File

@ -1,7 +1,7 @@
/* png.c - Handles output to PNG file */ /* png.c - Handles output to PNG file */
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2009-2022 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2009-2023 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -73,7 +73,7 @@ INTERNAL void wpng_error_handler_test(png_structp png_ptr, png_const_charp msg)
#endif #endif
/* Guestimate best compression strategy */ /* Guestimate best compression strategy */
static int guess_compression_strategy(struct zint_symbol *symbol, unsigned char *pixelbuf) { static int guess_compression_strategy(struct zint_symbol *symbol, const unsigned char *pixelbuf) {
(void)pixelbuf; (void)pixelbuf;
/* TODO: Do properly */ /* TODO: Do properly */
@ -92,7 +92,7 @@ static int guess_compression_strategy(struct zint_symbol *symbol, unsigned char
return Z_FILTERED; return Z_FILTERED;
} }
INTERNAL int png_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) { INTERNAL int png_pixel_plot(struct zint_symbol *symbol, const unsigned char *pixelbuf) {
struct wpng_error_type wpng_error; struct wpng_error_type wpng_error;
FILE *outfile; FILE *outfile;
png_structp png_ptr; png_structp png_ptr;
@ -108,30 +108,14 @@ INTERNAL int png_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
int num_trans; int num_trans;
int bit_depth; int bit_depth;
int compression_strategy; int compression_strategy;
unsigned char *pb; const unsigned char *pb;
const int output_to_stdout = symbol->output_options & BARCODE_STDOUT; const int output_to_stdout = symbol->output_options & BARCODE_STDOUT;
unsigned char *outdata = (unsigned char *) z_alloca(symbol->bitmap_width); unsigned char *outdata = (unsigned char *) z_alloca(symbol->bitmap_width);
wpng_error.symbol = symbol; wpng_error.symbol = symbol;
fg.red = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]); (void) out_colour_get_rgb(symbol->fgcolour, &fg.red, &fg.green, &fg.blue, &fg_alpha);
fg.green = (16 * ctoi(symbol->fgcolour[2])) + ctoi(symbol->fgcolour[3]); (void) out_colour_get_rgb(symbol->bgcolour, &bg.red, &bg.green, &bg.blue, &bg_alpha);
fg.blue = (16 * ctoi(symbol->fgcolour[4])) + ctoi(symbol->fgcolour[5]);
bg.red = (16 * ctoi(symbol->bgcolour[0])) + ctoi(symbol->bgcolour[1]);
bg.green = (16 * ctoi(symbol->bgcolour[2])) + ctoi(symbol->bgcolour[3]);
bg.blue = (16 * ctoi(symbol->bgcolour[4])) + ctoi(symbol->bgcolour[5]);
if (strlen(symbol->fgcolour) > 6) {
fg_alpha = (16 * ctoi(symbol->fgcolour[6])) + ctoi(symbol->fgcolour[7]);
} else {
fg_alpha = 0xff;
}
if (strlen(symbol->bgcolour) > 6) {
bg_alpha = (16 * ctoi(symbol->bgcolour[6])) + ctoi(symbol->bgcolour[7]);
} else {
bg_alpha = 0xff;
}
num_trans = 0; num_trans = 0;
if (symbol->symbology == BARCODE_ULTRA) { if (symbol->symbology == BARCODE_ULTRA) {

View File

@ -1,7 +1,7 @@
/* ps.c - Post Script output */ /* ps.c - Post Script output */
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2009-2022 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2009-2023 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -137,10 +137,12 @@ INTERNAL void ps_convert_test(const unsigned char *string, unsigned char *ps_str
INTERNAL int ps_plot(struct zint_symbol *symbol) { INTERNAL int ps_plot(struct zint_symbol *symbol) {
FILE *feps; FILE *feps;
int fgred, fggrn, fgblu, bgred, bggrn, bgblu; unsigned char fgred, fggrn, fgblu, bgred, bggrn, bgblu, bgalpha;
float red_ink, green_ink, blue_ink, red_paper, green_paper, blue_paper; int fgcyan, fgmagenta, fgyellow, fgblack, bgcyan, bgmagenta, bgyellow, bgblack;
float cyan_ink, magenta_ink, yellow_ink, black_ink; float red_ink = 0.0f, green_ink = 0.0f, blue_ink = 0.0f; /* Suppress `-Wmaybe-uninitialized` */
float cyan_paper, magenta_paper, yellow_paper, black_paper; float red_paper = 0.0f, green_paper = 0.0f, blue_paper = 0.0f;
float cyan_ink = 0.0f, magenta_ink = 0.0f, yellow_ink = 0.0f, black_ink = 0.0f;
float cyan_paper = 0.0f, magenta_paper = 0.0f, yellow_paper = 0.0f, black_paper = 0.0f;
int error_number = 0; int error_number = 0;
float ax, ay, bx, by, cx, cy, dx, dy, ex, ey, fx, fy; float ax, ay, bx, by, cx, cy, dx, dy, ex, ey, fx, fy;
float previous_diameter; float previous_diameter;
@ -166,12 +168,6 @@ INTERNAL int ps_plot(struct zint_symbol *symbol) {
return ZINT_ERROR_INVALID_DATA; return ZINT_ERROR_INVALID_DATA;
} }
if (strlen(symbol->bgcolour) > 6) {
if ((ctoi(symbol->bgcolour[6]) == 0) && (ctoi(symbol->bgcolour[7]) == 0)) {
draw_background = 0;
}
}
if (output_to_stdout) { if (output_to_stdout) {
feps = stdout; feps = stdout;
} else { } else {
@ -183,64 +179,31 @@ INTERNAL int ps_plot(struct zint_symbol *symbol) {
locale = setlocale(LC_ALL, "C"); locale = setlocale(LC_ALL, "C");
fgred = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]); if ((symbol->output_options & CMYK_COLOUR) == 0) {
fggrn = (16 * ctoi(symbol->fgcolour[2])) + ctoi(symbol->fgcolour[3]); (void) out_colour_get_rgb(symbol->fgcolour, &fgred, &fggrn, &fgblu, NULL /*alpha*/);
fgblu = (16 * ctoi(symbol->fgcolour[4])) + ctoi(symbol->fgcolour[5]); red_ink = fgred / 255.0f;
bgred = (16 * ctoi(symbol->bgcolour[0])) + ctoi(symbol->bgcolour[1]); green_ink = fggrn / 255.0f;
bggrn = (16 * ctoi(symbol->bgcolour[2])) + ctoi(symbol->bgcolour[3]); blue_ink = fgblu / 255.0f;
bgblu = (16 * ctoi(symbol->bgcolour[4])) + ctoi(symbol->bgcolour[5]);
red_ink = (float) (fgred / 256.0);
green_ink = (float) (fggrn / 256.0);
blue_ink = (float) (fgblu / 256.0);
red_paper = (float) (bgred / 256.0);
green_paper = (float) (bggrn / 256.0);
blue_paper = (float) (bgblu / 256.0);
/* Convert RGB to CMYK */ (void) out_colour_get_rgb(symbol->bgcolour, &bgred, &bggrn, &bgblu, &bgalpha);
if (red_ink > green_ink) { red_paper = bgred / 255.0f;
if (blue_ink > red_ink) { green_paper = bggrn / 255.0f;
black_ink = 1.0f - blue_ink; blue_paper = bgblu / 255.0f;
} else {
black_ink = 1.0f - red_ink;
}
} else { } else {
if (blue_ink > red_ink) { (void) out_colour_get_cmyk(symbol->fgcolour, &fgcyan, &fgmagenta, &fgyellow, &fgblack, NULL /*rgb_alpha*/);
black_ink = 1.0f - blue_ink; cyan_ink = fgcyan / 100.0f;
} else { magenta_ink = fgmagenta / 100.0f;
black_ink = 1.0f - green_ink; yellow_ink = fgyellow / 100.0f;
} black_ink = fgblack / 100.0f;
}
if (black_ink < 1.0f) {
cyan_ink = (1.0f - red_ink - black_ink) / (1.0f - black_ink);
magenta_ink = (1.0f - green_ink - black_ink) / (1.0f - black_ink);
yellow_ink = (1.0f - blue_ink - black_ink) / (1.0f - black_ink);
} else {
cyan_ink = 0.0f;
magenta_ink = 0.0f;
yellow_ink = 0.0f;
}
if (red_paper > green_paper) { (void) out_colour_get_cmyk(symbol->bgcolour, &bgcyan, &bgmagenta, &bgyellow, &bgblack, &bgalpha);
if (blue_paper > red_paper) { cyan_paper = bgcyan / 100.0f;
black_paper = 1.0f - blue_paper; magenta_paper = bgmagenta / 100.0f;
} else { yellow_paper = bgyellow / 100.0f;
black_paper = 1.0f - red_paper; black_paper = bgblack / 100.0f;
}
} else {
if (blue_paper > red_paper) {
black_paper = 1.0f - blue_paper;
} else {
black_paper = 1.0f - green_paper;
}
} }
if (black_paper < 1.0f) { if (bgalpha == 0) {
cyan_paper = (1.0f - red_paper - black_paper) / (1.0f - black_paper); draw_background = 0;
magenta_paper = (1.0f - green_paper - black_paper) / (1.0f - black_paper);
yellow_paper = (1.0f - blue_paper - black_paper) / (1.0f - black_paper);
} else {
cyan_paper = 0.0f;
magenta_paper = 0.0f;
yellow_paper = 0.0f;
} }
for (i = 0, len = (int) ustrlen(symbol->text); i < len; i++) { for (i = 0, len = (int) ustrlen(symbol->text); i < len; i++) {
@ -426,7 +389,7 @@ INTERNAL int ps_plot(struct zint_symbol *symbol) {
previous_diameter = circle->diameter - circle->width; previous_diameter = circle->diameter - circle->width;
radius = (float) (0.5 * previous_diameter); radius = (float) (0.5 * previous_diameter);
} }
if (circle->colour) { if (circle->colour) { /* Legacy - no longer used */
/* A 'white' circle */ /* A 'white' circle */
if ((symbol->output_options & CMYK_COLOUR) == 0) { if ((symbol->output_options & CMYK_COLOUR) == 0) {
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_paper, green_paper, blue_paper); fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_paper, green_paper, blue_paper);

View File

@ -1,7 +1,7 @@
/* raster.c - Handles output to raster files */ /* raster.c - Handles output to raster files */
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2009-2022 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2009-2023 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -50,18 +50,18 @@
#define UPCEAN_TEXT 1 #define UPCEAN_TEXT 1
#ifndef ZINT_NO_PNG #ifndef ZINT_NO_PNG
INTERNAL int png_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf); INTERNAL int png_pixel_plot(struct zint_symbol *symbol, const unsigned char *pixelbuf);
#endif /* ZINT_NO_PNG */ #endif /* ZINT_NO_PNG */
INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf); INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, const unsigned char *pixelbuf);
INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf); INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, const unsigned char *pixelbuf);
INTERNAL int gif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf); INTERNAL int gif_pixel_plot(struct zint_symbol *symbol, const unsigned char *pixelbuf);
INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf); INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, const unsigned char *pixelbuf);
static const char ultra_colour[] = "0CBMRYGKW"; static const char ultra_colour[] = "0CBMRYGKW";
static int buffer_plot(struct zint_symbol *symbol, const unsigned char *pixelbuf) { static int buffer_plot(struct zint_symbol *symbol, const unsigned char *pixelbuf) {
/* Place pixelbuffer into symbol */ /* Place pixelbuffer into symbol */
int fgalpha, bgalpha; unsigned char fgalpha, bgalpha;
unsigned char map[91][3] = { unsigned char map[91][3] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 0x00-0F */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 0x00-0F */
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 0x10-1F */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 0x10-1F */
@ -77,25 +77,13 @@ static int buffer_plot(struct zint_symbol *symbol, const unsigned char *pixelbuf
int plot_alpha = 0; int plot_alpha = 0;
const size_t bm_bitmap_width = (size_t) symbol->bitmap_width * 3; const size_t bm_bitmap_width = (size_t) symbol->bitmap_width * 3;
map[DEFAULT_INK][0] = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]); if (out_colour_get_rgb(symbol->fgcolour, &map[DEFAULT_INK][0], &map[DEFAULT_INK][1], &map[DEFAULT_INK][2],
map[DEFAULT_INK][1] = (16 * ctoi(symbol->fgcolour[2])) + ctoi(symbol->fgcolour[3]); &fgalpha)) {
map[DEFAULT_INK][2] = (16 * ctoi(symbol->fgcolour[4])) + ctoi(symbol->fgcolour[5]);
map[DEFAULT_PAPER][0] = (16 * ctoi(symbol->bgcolour[0])) + ctoi(symbol->bgcolour[1]);
map[DEFAULT_PAPER][1] = (16 * ctoi(symbol->bgcolour[2])) + ctoi(symbol->bgcolour[3]);
map[DEFAULT_PAPER][2] = (16 * ctoi(symbol->bgcolour[4])) + ctoi(symbol->bgcolour[5]);
if (strlen(symbol->fgcolour) > 6) {
fgalpha = (16 * ctoi(symbol->fgcolour[6])) + ctoi(symbol->fgcolour[7]);
plot_alpha = 1; plot_alpha = 1;
} else {
fgalpha = 0xff;
} }
if (out_colour_get_rgb(symbol->bgcolour, &map[DEFAULT_PAPER][0], &map[DEFAULT_PAPER][1], &map[DEFAULT_PAPER][2],
if (strlen(symbol->bgcolour) > 6) { &bgalpha)) {
bgalpha = (16 * ctoi(symbol->bgcolour[6])) + ctoi(symbol->bgcolour[7]);
plot_alpha = 1; plot_alpha = 1;
} else {
bgalpha = 0xff;
} }
/* Free any previous bitmap */ /* Free any previous bitmap */

View File

@ -1,7 +1,7 @@
/* svg.c - Scalable Vector Graphics */ /* svg.c - Scalable Vector Graphics */
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2009-2022 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2009-2023 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -113,6 +113,7 @@ static void make_html_friendly(unsigned char *string, char *html_version) {
} }
INTERNAL int svg_plot(struct zint_symbol *symbol) { INTERNAL int svg_plot(struct zint_symbol *symbol) {
static const char font_family[] = "Helvetica, sans-serif";
FILE *fsvg; FILE *fsvg;
int error_number = 0; int error_number = 0;
const char *locale = NULL; const char *locale = NULL;
@ -122,10 +123,9 @@ INTERNAL int svg_plot(struct zint_symbol *symbol) {
int i; int i;
char fgcolour_string[7]; char fgcolour_string[7];
char bgcolour_string[7]; char bgcolour_string[7];
int bg_alpha = 0xff; unsigned char fgred, fggreen, fgblue, fg_alpha;
int fg_alpha = 0xff; unsigned char bgred, bggreen, bgblue, bg_alpha;
float fg_alpha_opacity = 0.0f, bg_alpha_opacity = 0.0f; float fg_alpha_opacity = 0.0f, bg_alpha_opacity = 0.0f; /* Suppress `-Wmaybe-uninitialized` */
const char font_family[] = "Helvetica, sans-serif";
int bold; int bold;
struct zint_vector_rect *rect; struct zint_vector_rect *rect;
@ -139,25 +139,16 @@ INTERNAL int svg_plot(struct zint_symbol *symbol) {
const int output_to_stdout = symbol->output_options & BARCODE_STDOUT; const int output_to_stdout = symbol->output_options & BARCODE_STDOUT;
char *html_string; char *html_string;
for (i = 0; i < 6; i++) { (void) out_colour_get_rgb(symbol->fgcolour, &fgred, &fggreen, &fgblue, &fg_alpha);
fgcolour_string[i] = symbol->fgcolour[i]; if (fg_alpha != 0xff) {
bgcolour_string[i] = symbol->bgcolour[i]; fg_alpha_opacity = fg_alpha / 255.0f;
} }
fgcolour_string[6] = '\0'; sprintf(fgcolour_string, "%02X%02X%02X", fgred, fggreen, fgblue);
bgcolour_string[6] = '\0'; (void) out_colour_get_rgb(symbol->bgcolour, &bgred, &bggreen, &bgblue, &bg_alpha);
if (bg_alpha != 0xff) {
if (strlen(symbol->fgcolour) > 6) { bg_alpha_opacity = bg_alpha / 255.0f;
fg_alpha = (16 * ctoi(symbol->fgcolour[6])) + ctoi(symbol->fgcolour[7]);
if (fg_alpha != 0xff) {
fg_alpha_opacity = (float) (fg_alpha / 255.0);
}
}
if (strlen(symbol->bgcolour) > 6) {
bg_alpha = (16 * ctoi(symbol->bgcolour[6])) + ctoi(symbol->bgcolour[7]);
if (bg_alpha != 0xff) {
bg_alpha_opacity = (float) (bg_alpha / 255.0);
}
} }
sprintf(bgcolour_string, "%02X%02X%02X", bgred, bggreen, bgblue);
len = (int) ustrlen(symbol->text); len = (int) ustrlen(symbol->text);
html_len = len + 1; html_len = len + 1;
@ -283,7 +274,7 @@ INTERNAL int svg_plot(struct zint_symbol *symbol) {
fprintf(fsvg, " <circle cx=\"%.2f\" cy=\"%.2f\" r=\"%.*f\"", fprintf(fsvg, " <circle cx=\"%.2f\" cy=\"%.2f\" r=\"%.*f\"",
circle->x, circle->y, circle->width ? 3 : 2, radius); circle->x, circle->y, circle->width ? 3 : 2, radius);
if (circle->colour) { if (circle->colour) { /* Legacy - no longer used */
if (circle->width) { if (circle->width) {
fprintf(fsvg, " stroke=\"#%s\" stroke-width=\"%.3f\" fill=\"none\"", bgcolour_string, circle->width); fprintf(fsvg, " stroke=\"#%s\" stroke-width=\"%.3f\" fill=\"none\"", bgcolour_string, circle->width);
} else { } else {

Binary file not shown.

View File

@ -1,5 +1,5 @@
%!PS-Adobe-3.0 EPSF-3.0 %!PS-Adobe-3.0 EPSF-3.0
%%Creator: Zint 2.10.0.9 %%Creator: Zint 2.12.0.9
%%Title: Zint Generated Symbol %%Title: Zint Generated Symbol
%%Pages: 0 %%Pages: 0
%%BoundingBox: 0 0 128 119 %%BoundingBox: 0 0 128 119
@ -8,10 +8,10 @@
/TR { newpath 4 1 roll exch moveto 1 index 0 rlineto 0 exch rlineto neg 0 rlineto closepath fill } bind def /TR { newpath 4 1 roll exch moveto 1 index 0 rlineto 0 exch rlineto neg 0 rlineto closepath fill } bind def
/TE { pop pop } bind def /TE { pop pop } bind def
newpath newpath
0.98 0.59 0.19 setrgbcolor 0.99 0.59 0.19 setrgbcolor
118.90 0.00 TB 0.00 128.00 TR 118.90 0.00 TB 0.00 128.00 TR
TE TE
0.08 0.48 0.81 setrgbcolor 0.08 0.48 0.82 setrgbcolor
100.00 18.90 TB 0.00 2.00 TR 100.00 18.90 TB 0.00 2.00 TR
TE TE
100.00 18.90 TB 6.00 2.00 TR 100.00 18.90 TB 6.00 2.00 TR

View File

@ -1,5 +1,5 @@
%!PS-Adobe-3.0 EPSF-3.0 %!PS-Adobe-3.0 EPSF-3.0
%%Creator: Zint 2.10.0.9 %%Creator: Zint 2.12.0.9
%%Title: Zint Generated Symbol %%Title: Zint Generated Symbol
%%Pages: 0 %%Pages: 0
%%BoundingBox: 0 0 128 119 %%BoundingBox: 0 0 128 119
@ -8,10 +8,10 @@
/TR { newpath 4 1 roll exch moveto 1 index 0 rlineto 0 exch rlineto neg 0 rlineto closepath fill } bind def /TR { newpath 4 1 roll exch moveto 1 index 0 rlineto 0 exch rlineto neg 0 rlineto closepath fill } bind def
/TE { pop pop } bind def /TE { pop pop } bind def
newpath newpath
0.00 0.40 0.81 0.02 setcmykcolor 0.00 0.40 0.81 0.01 setcmykcolor
118.90 0.00 TB 0.00 128.00 TR 118.90 0.00 TB 0.00 128.00 TR
TE TE
0.90 0.41 0.00 0.19 setcmykcolor 0.90 0.41 0.00 0.18 setcmykcolor
100.00 18.90 TB 0.00 2.00 TR 100.00 18.90 TB 0.00 2.00 TR
TE TE
100.00 18.90 TB 6.00 2.00 TR 100.00 18.90 TB 6.00 2.00 TR

View File

@ -0,0 +1,70 @@
%!PS-Adobe-3.0 EPSF-3.0
%%Creator: Zint 2.12.0.9
%%Title: Zint Generated Symbol
%%Pages: 0
%%BoundingBox: 0 0 128 119
%%EndComments
/TB { 2 copy } bind def
/TR { newpath 4 1 roll exch moveto 1 index 0 rlineto 0 exch rlineto neg 0 rlineto closepath fill } bind def
/TE { pop pop } bind def
newpath
0.90 0.40 0.00 0.09 setcmykcolor
100.00 18.90 TB 0.00 2.00 TR
TE
100.00 18.90 TB 6.00 2.00 TR
TE
100.00 18.90 TB 10.00 4.00 TR
TE
100.00 18.90 TB 16.00 4.00 TR
TE
100.00 18.90 TB 22.00 2.00 TR
TE
100.00 18.90 TB 26.00 4.00 TR
TE
100.00 18.90 TB 32.00 2.00 TR
TE
100.00 18.90 TB 38.00 2.00 TR
TE
100.00 18.90 TB 42.00 2.00 TR
TE
100.00 18.90 TB 46.00 4.00 TR
TE
100.00 18.90 TB 52.00 2.00 TR
TE
100.00 18.90 TB 56.00 4.00 TR
TE
100.00 18.90 TB 64.00 2.00 TR
TE
100.00 18.90 TB 68.00 2.00 TR
TE
100.00 18.90 TB 72.00 4.00 TR
TE
100.00 18.90 TB 78.00 4.00 TR
TE
100.00 18.90 TB 84.00 4.00 TR
TE
100.00 18.90 TB 92.00 2.00 TR
TE
100.00 18.90 TB 96.00 2.00 TR
TE
100.00 18.90 TB 100.00 2.00 TR
TE
100.00 18.90 TB 104.00 2.00 TR
TE
100.00 18.90 TB 110.00 2.00 TR
TE
100.00 18.90 TB 114.00 4.00 TR
TE
100.00 18.90 TB 120.00 4.00 TR
TE
100.00 18.90 TB 126.00 2.00 TR
TE
matrix currentmatrix
/Helvetica findfont
14.00 scalefont setfont
0 0 moveto 64.00 3.50 translate 0.00 rotate 0 0 moveto
(*123*) stringwidth
pop
-2 div 0 rmoveto
(*123*) show
setmatrix

View File

@ -1,5 +1,5 @@
%!PS-Adobe-3.0 EPSF-3.0 %!PS-Adobe-3.0 EPSF-3.0
%%Creator: Zint 2.10.0.9 %%Creator: Zint 2.12.0.9
%%Title: Zint Generated Symbol %%Title: Zint Generated Symbol
%%Pages: 0 %%Pages: 0
%%BoundingBox: 0 0 28 26 %%BoundingBox: 0 0 28 26
@ -8,7 +8,7 @@
/TR { newpath 4 1 roll exch moveto 1 index 0 rlineto 0 exch rlineto neg 0 rlineto closepath fill } bind def /TR { newpath 4 1 roll exch moveto 1 index 0 rlineto 0 exch rlineto neg 0 rlineto closepath fill } bind def
/TE { pop pop } bind def /TE { pop pop } bind def
newpath newpath
0.98 0.59 0.19 setrgbcolor 0.99 0.59 0.19 setrgbcolor
26.00 0.00 TB 0.00 28.00 TR 26.00 0.00 TB 0.00 28.00 TR
TE TE
0.00 1.00 1.00 setrgbcolor 0.00 1.00 1.00 setrgbcolor

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 B

View File

@ -0,0 +1,24 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="46" height="59" version="1.1"
xmlns="http://www.w3.org/2000/svg">
<desc>Zint Generated Symbol
</desc>
<g id="barcode" fill="#001FCC">
<rect x="0.00" y="0.00" width="2.00" height="40.00" />
<rect x="4.00" y="0.00" width="2.00" height="40.00" />
<rect x="8.00" y="0.00" width="2.00" height="40.00" />
<rect x="12.00" y="0.00" width="2.00" height="40.00" />
<rect x="16.00" y="0.00" width="2.00" height="40.00" />
<rect x="22.00" y="0.00" width="2.00" height="40.00" />
<rect x="26.00" y="0.00" width="6.00" height="40.00" />
<rect x="38.00" y="0.00" width="2.00" height="40.00" />
<rect x="42.00" y="0.00" width="4.00" height="40.00" />
<text x="23.00" y="55.40" text-anchor="middle"
font-family="Helvetica, sans-serif" font-size="14.0" >
123
</text>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1013 B

Binary file not shown.

View File

@ -431,7 +431,7 @@ static void test_input(const testCtx *const p_ctx) {
/* 75*/ { UNICODE_MODE, "ÿ12345678\012à12345678abcdef\0121\01223456\012\0127890àAàBCDEFà\012\012à", -1, 0, 684, 0, "(62) 104 100 95 99 12 34 56 78 101 74 101 98 64 99 12 34 56 78 100 65 66 67 68 69 70 98 74", "BWIPP different encodation, CodeA instead of ShA, shorter" }, /* 75*/ { UNICODE_MODE, "ÿ12345678\012à12345678abcdef\0121\01223456\012\0127890àAàBCDEFà\012\012à", -1, 0, 684, 0, "(62) 104 100 95 99 12 34 56 78 101 74 101 98 64 99 12 34 56 78 100 65 66 67 68 69 70 98 74", "BWIPP different encodation, CodeA instead of ShA, shorter" },
/* 76*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B\\^A12\\^C34\\^A\\^B5\\^C67\\^A\\^B\\^CA\\^B\\^A", -1, 0, 145, 0, "(13) 103 17 18 99 34 100 21 99 67 100 33 69 106", "BWIPP no manual mode" }, /* 76*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B\\^A12\\^C34\\^A\\^B5\\^C67\\^A\\^B\\^CA\\^B\\^A", -1, 0, 145, 0, "(13) 103 17 18 99 34 100 21 99 67 100 33 69 106", "BWIPP no manual mode" },
/* 77*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^C1234ABC12\012", -1, 0, 145, 0, "(13) 105 12 34 100 33 34 35 99 12 101 74 36 106", "StartC 12 34 CodeB A B C CodeC 12 CodeA LF; BWIPP no manual mode" }, /* 77*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^C1234ABC12\012", -1, 0, 145, 0, "(13) 105 12 34 100 33 34 35 99 12 101 74 36 106", "StartC 12 34 CodeB A B C CodeC 12 CodeA LF; BWIPP no manual mode" },
/* 78*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "A\\^", -1, 0, 68, 1, "(6) 104 33 60 62 31 106", "StartC 12 34 CodeB A B C CodeC 12 CodeA LF; BWIPP no manual mode" }, /* 78*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "A\\^", -1, 0, 68, 1, "(6) 104 33 60 62 31 106", "StartC 12 34 CodeB A B C CodeC 12 CodeA LF" },
}; };
int data_size = ARRAY_SIZE(data); int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;

View File

@ -1,6 +1,6 @@
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2020-2022 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2020-2023 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -81,6 +81,7 @@ static void test_print(const testCtx *const p_ctx) {
/* 25*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, 600.f / 25.4f, "E0E0E0", "700070", 0, "THIS IS A 93 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, UNAPPENDED, MAXICODE SYMBOL...", "maxicode_#185_600dpi.emf", "#185 Maxicode scaling" }, /* 25*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, 600.f / 25.4f, "E0E0E0", "700070", 0, "THIS IS A 93 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, UNAPPENDED, MAXICODE SYMBOL...", "maxicode_#185_600dpi.emf", "#185 Maxicode scaling" },
/* 26*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, 0, "", "FFFFFF00", 90, "THIS IS A 93 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, UNAPPENDED, MAXICODE SYMBOL...", "maxicode_rotate_90_nobg.emf", "" }, /* 26*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, 0, "", "FFFFFF00", 90, "THIS IS A 93 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, UNAPPENDED, MAXICODE SYMBOL...", "maxicode_rotate_90_nobg.emf", "" },
/* 27*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, 300.0f, "", "FFFFFF00", 90, "THIS IS A 93 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, UNAPPENDED, MAXICODE SYMBOL...", "maxicode_rotate_90_nobg_300dpi.emf", "" }, /* 27*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, 300.0f, "", "FFFFFF00", 90, "THIS IS A 93 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, UNAPPENDED, MAXICODE SYMBOL...", "maxicode_rotate_90_nobg_300dpi.emf", "" },
/* 28*/ { BARCODE_UPU_S10, -1, -1, CMYK_COLOUR, -1, -1, -1, -1, 0, "71,0,40,44", "FFFFFF00", 0, "QA47312482PS", "upu_s10_cmyk_nobg.emf", "" },
}; };
int data_size = ARRAY_SIZE(data); int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;

View File

@ -1,6 +1,6 @@
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2020-2022 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2020-2023 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -164,15 +164,18 @@ static void test_print(const testCtx *const p_ctx) {
/* 19*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 0, 5, 1.7, { 0, 0, "" }, "", "", "12", "dotcode_5.0_ds1.7.gif", "" }, /* 19*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 0, 5, 1.7, { 0, 0, "" }, "", "", "12", "dotcode_5.0_ds1.7.gif", "" },
/* 20*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 0, 0, 0, { 0, 0, "" }, "2674C344", "FDFFC2CC", "12", "dotcode_bgfgalpha.gif", "" }, /* 20*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 0, 0, 0, { 0, 0, "" }, "2674C344", "FDFFC2CC", "12", "dotcode_bgfgalpha.gif", "" },
/* 21*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 0, 0, 0, { 0, 0, "" }, "00000000", "FFFFFF00", "12", "dotcode_bgfgtrans.gif", "" }, /* 21*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 0, 0, 0, { 0, 0, "" }, "00000000", "FFFFFF00", "12", "dotcode_bgfgtrans.gif", "" },
/* 22*/ { BARCODE_ULTRA, 1, BARCODE_BOX, 1, 1, -1, -1, 0, 0, 0, { 0, 0, "" }, "0000FF", "FF0000", "12", "ultra_fgbg_hvwsp1_box1.gif", "" }, /* 22*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 0, 0, 0, { 0, 0, "" }, "00000000", "FFFFFF", "12", "dotcode_fgtrans.gif", "" },
/* 23*/ { BARCODE_ITF14, 4, BARCODE_BIND, 24, -1, -1, -1, 61.8, 3, 0, { 0, 0, "" }, "", "", "0501054800395", "itf14_height61.8_bind4_wsp24_3.gif", "#204 ARM-Cortex crash" }, /* 23*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 0, 0, 0, { 0, 0, "" }, "000000", "FFFFFF00", "12", "dotcode_bgtrans.gif", "" },
/* 24*/ { BARCODE_ITF14, 0, BARCODE_BIND, -1, -1, -1, -1, 0.5, 0.5, 0, { 0, 0, "" }, "", "", "0501054800395", "itf14_height0.5_box0_0.5.gif", "No box, no text" }, /* 24*/ { BARCODE_DOTCODE, -1, CMYK_COLOUR, -1, -1, -1, -1, 0, 0, 0, { 0, 0, "" }, "71,0,40,44", "", "12", "dotcode_cmyk_fg.gif", "" },
/* 25*/ { BARCODE_ITF14, -1, -1, -1, -1, -1, -1, 0.5, 1.1, 0, { 0, 0, "" }, "", "", "0501054800395", "itf14_height0.5_1.1.gif", "" }, /* 25*/ { BARCODE_ULTRA, 1, BARCODE_BOX, 1, 1, -1, -1, 0, 0, 0, { 0, 0, "" }, "0000FF", "FF0000", "12", "ultra_fgbg_hvwsp1_box1.gif", "" },
/* 26*/ { BARCODE_CODE16K, -1, -1, 3, 5, -1, -1, 0.5, 0, 0, { 0, 0, "" }, "", "", "1234567890", "code16k_height0.5_wsp3_vwsp5.gif", "Separator covers bars" }, /* 26*/ { BARCODE_ITF14, 4, BARCODE_BIND, 24, -1, -1, -1, 61.8, 3, 0, { 0, 0, "" }, "", "", "0501054800395", "itf14_height61.8_bind4_wsp24_3.gif", "#204 ARM-Cortex crash" },
/* 27*/ { BARCODE_CODE16K, -1, -1, 3, 5, -1, -1, 1.5, 0, 0, { 0, 0, "" }, "", "", "1234567890", "code16k_height1.5_wsp3_vwsp5.gif", "" }, /* 27*/ { BARCODE_ITF14, 0, BARCODE_BIND, -1, -1, -1, -1, 0.5, 0.5, 0, { 0, 0, "" }, "", "", "0501054800395", "itf14_height0.5_box0_0.5.gif", "No box, no text" },
/* 28*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, 0, 0, 0, { 2, 9, "001002" }, "", "", "1234567890", "datamatrix_seq2of9.gif", "" }, /* 28*/ { BARCODE_ITF14, -1, -1, -1, -1, -1, -1, 0.5, 1.1, 0, { 0, 0, "" }, "", "", "0501054800395", "itf14_height0.5_1.1.gif", "" },
/* 29*/ { BARCODE_ULTRA, -1, -1, 1, -1, -1, 2, 0, 0, 0, { 0, 0, "" }, "", "", "12", "ultra_rev2.gif", "Revision 2" }, /* 29*/ { BARCODE_CODE16K, -1, -1, 3, 5, -1, -1, 0.5, 0, 0, { 0, 0, "" }, "", "", "1234567890", "code16k_height0.5_wsp3_vwsp5.gif", "Separator covers bars" },
/* 30*/ { BARCODE_DPD, -1, BARCODE_QUIET_ZONES | COMPLIANT_HEIGHT, -1, -1, -1, -1, 0, 0, 0, { 0, 0, "" }, "", "", "008182709980000020028101276", "dpd_compliant.gif", "Now with bind top 3X default" }, /* 30*/ { BARCODE_CODE16K, -1, -1, 3, 5, -1, -1, 1.5, 0, 0, { 0, 0, "" }, "", "", "1234567890", "code16k_height1.5_wsp3_vwsp5.gif", "" },
/* 31*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, 0, 0, 0, { 2, 9, "001002" }, "", "", "1234567890", "datamatrix_seq2of9.gif", "" },
/* 32*/ { BARCODE_ULTRA, -1, -1, 1, -1, -1, 2, 0, 0, 0, { 0, 0, "" }, "", "", "12", "ultra_rev2.gif", "Revision 2" },
/* 33*/ { BARCODE_DPD, -1, BARCODE_QUIET_ZONES | COMPLIANT_HEIGHT, -1, -1, -1, -1, 0, 0, 0, { 0, 0, "" }, "", "", "008182709980000020028101276", "dpd_compliant.gif", "Now with bind top 3X default" },
}; };
int data_size = ARRAY_SIZE(data); int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;

View File

@ -1,6 +1,6 @@
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2021-2022 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2021-2023 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -36,6 +36,172 @@
#include <direct.h> #include <direct.h>
#endif #endif
static void test_check_colour_options(const testCtx *const p_ctx) {
struct item {
char *fgcolour;
char *bgcolour;
int ret;
char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { "FFFFFF", "000000", 0, "" },
/* 1*/ { "ffffff", "ffffff", 0, "" },
/* 2*/ { "77777777", "33333333", 0, "" },
/* 3*/ { "FFFFF", "000000", ZINT_ERROR_INVALID_OPTION, "690: Malformed foreground RGB colour (6 or 8 characters only)" },
/* 4*/ { "FFFFFFF", "000000", ZINT_ERROR_INVALID_OPTION, "690: Malformed foreground RGB colour (6 or 8 characters only)" },
/* 5*/ { "FFFFFG", "000000", ZINT_ERROR_INVALID_OPTION, "691: Malformed foreground RGB colour 'FFFFFG' (hexadecimal only)" },
/* 6*/ { "FFFFFF", "000000000", ZINT_ERROR_INVALID_OPTION, "690: Malformed background RGB colour (6 or 8 characters only)" },
/* 7*/ { "FFFFFF", "0000000Z", ZINT_ERROR_INVALID_OPTION, "691: Malformed background RGB colour '0000000Z' (hexadecimal only)" },
/* 8*/ { "100,100,100,100", "0,1,2,3", 0, "" },
/* 9*/ { "100,,100,100", ",1,2,", 0, "" },
/* 10*/ { "100,100,100", "0,1,2,3", ZINT_ERROR_INVALID_OPTION, "692: Malformed foreground CMYK colour (4 decimal numbers, comma-separated)" },
/* 11*/ { "100,100,99,1001", "0,1,2,3", ZINT_ERROR_INVALID_OPTION, "693: Malformed foreground CMYK colour (3 digit maximum per number)" },
/* 12*/ { "101,100,100,100", "0,1,2,3", ZINT_ERROR_INVALID_OPTION, "694: Malformed foreground CMYK colour C (decimal 0-100 only)" },
/* 13*/ { "100,101,100,100", "0,1,2,3", ZINT_ERROR_INVALID_OPTION, "695: Malformed foreground CMYK colour M (decimal 0-100 only)" },
/* 14*/ { "100,100,101,100", "0,1,2,3", ZINT_ERROR_INVALID_OPTION, "696: Malformed foreground CMYK colour Y (decimal 0-100 only)" },
/* 15*/ { "100,100,100,101", "0,1,2,3", ZINT_ERROR_INVALID_OPTION, "697: Malformed foreground CMYK colour K (decimal 0-100 only)" },
/* 16*/ { "100,100,100,100", "0,1,", ZINT_ERROR_INVALID_OPTION, "692: Malformed background CMYK colour (4 decimal numbers, comma-separated)" },
/* 17*/ { "100,100,100,100", "0,0123,3,4", ZINT_ERROR_INVALID_OPTION, "693: Malformed background CMYK colour (3 digit maximum per number)" },
/* 18*/ { "100,100,100,100", "0,1,2,101", ZINT_ERROR_INVALID_OPTION, "697: Malformed background CMYK colour K (decimal 0-100 only)" },
/* 19*/ { "100,100,100,100", "0,1,2,3,", ZINT_ERROR_INVALID_OPTION, "692: Malformed background CMYK colour (4 decimal numbers, comma-separated)" },
};
int data_size = ARRAY_SIZE(data);
int i, ret;
struct zint_symbol symbol;
testStart("test_check_colour_options");
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
strcpy(symbol.fgcolour, data[i].fgcolour);
strcpy(symbol.bgcolour, data[i].bgcolour);
symbol.errtxt[0] = '\0';
ret = out_check_colour_options(&symbol);
assert_equal(ret, data[i].ret, "i:%d ret %d != %d (%s)\n", i, ret, data[i].ret, symbol.errtxt);
assert_zero(strcmp(symbol.errtxt, data[i].expected), "i:%d symbol.errtxt (%s) != expected (%s)\n", i, symbol.errtxt, data[i].expected);
}
testFinish();
}
static void test_colour_get_rgb(const testCtx *const p_ctx) {
struct item {
char *colour;
int ret;
unsigned char red;
unsigned char green;
unsigned char blue;
unsigned char alpha;
char *expected_cmyk;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { "FFFFFF", 0, 0xFF, 0xFF, 0xFF, 0xFF, "0,0,0,0" },
/* 1*/ { "000000", 0, 0x00, 0x00, 0x00, 0xFF, "0,0,0,100" },
/* 2*/ { "FEDCBA", 0, 0xFE, 0xDC, 0xBA, 0xFF, "0,13,27,0" },
/* 3*/ { "EEDD9900", 1, 0xEE, 0xDD, 0x99, 0x00, "0,7,36,7" },
/* 4*/ { "98765432", 1, 0x98, 0x76, 0x54, 0x32, "0,22,45,40" },
/* 5*/ { "147AD0", 0, 0x14, 0x7A, 0xD0, 0xFF, "90,41,0,18" },
/* 6*/ { "FC9630", 0, 0xFC, 0x96, 0x30, 0xFF, "0,40,81,1" },
/* 7*/ { "112233", 0, 0x11, 0x22, 0x33, 0xFF, "67,33,0,80" },
/* 8*/ { "CCDDEE", 0, 0xCC, 0xDD, 0xEE, 0xFF, "14,7,0,7" },
/* 9*/ { "0,0,0,0", 0, 0xFF, 0xFF, 0xFF, 0xFF, "0,0,0,0" },
/* 10*/ { "80,30,60,0", 0, 0x33, 0xB3, 0x66, 0xFF, "72,0,43,30" },
/* 11*/ { "50,50,50,50", 0, 0x40, 0x40, 0x40, 0xFF, "0,0,0,75" },
};
int data_size = ARRAY_SIZE(data);
int i, ret;
testStart("test_colour_get_rgb");
for (i = 0; i < data_size; i++) {
unsigned char red, green, blue, alpha, rgb_alpha;
int cyan, magenta, yellow, black;
int have_alpha;
char rgb[9];
char cmyk[16];
if (testContinue(p_ctx, i)) continue;
ret = out_colour_get_rgb(data[i].colour, &red, &green, &blue, &alpha);
assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret);
assert_equal(red, data[i].red, "i:%d red 0x%02X (%d) != 0x%02X (%d) (green 0x%02X, blue 0x%02X)\n", i, red, red, data[i].red, data[i].red, green, blue);
assert_equal(green, data[i].green, "i:%d green %d (0x%02X) != %d (0x%02X)\n", i, green, green, data[i].green, data[i].green);
assert_equal(blue, data[i].blue, "i:%d blue %d (0x%02X) != %d (0x%02X)\n", i, blue, blue, data[i].blue, data[i].blue);
assert_equal(alpha, data[i].alpha, "i:%d alpha %d (0x%02X) != %d (0x%02X)\n", i, alpha, alpha, data[i].alpha, data[i].alpha);
have_alpha = ret == 1;
if (have_alpha) {
sprintf(rgb, "%02X%02X%02X%02X", red, green, blue, alpha);
} else {
sprintf(rgb, "%02X%02X%02X", red, green, blue);
}
ret = out_colour_get_cmyk(rgb, &cyan, &magenta, &yellow, &black, &rgb_alpha);
assert_equal(ret, 1 + have_alpha, "i:%d out_colour_get_cmyk(%s) ret %d != %d\n", i, rgb, ret, 1 + have_alpha);
assert_equal(rgb_alpha, alpha, "i:%d rgb_alpha %d (0x%02X) != %d (0x%02X)\n", i, rgb_alpha, rgb_alpha, alpha, alpha);
sprintf(cmyk, "%d,%d,%d,%d", cyan, magenta, yellow, black);
assert_zero(strcmp(cmyk, data[i].expected_cmyk), "i:%d strcmp(%s, %s) != 0\n", i, cmyk, data[i].expected_cmyk);
}
testFinish();
}
static void test_colour_get_cmyk(const testCtx *const p_ctx) {
struct item {
char *colour;
int ret;
int cyan;
int magenta;
int yellow;
int black;
unsigned char alpha;
char *expected_rgb;
int ret_rgb;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { "80,30,60,0", 0, 80, 30, 60, 0, 0xFF, "33B366FF", 0 },
/* 1*/ { "50,50,50,50", 0, 50, 50, 50, 50, 0xFF, "404040FF", 0 },
/* 2*/ { "0,0,0,100", 0, 0, 0, 0, 100, 0xFF, "000000FF", 0 },
/* 3*/ { "71,0,40,44", 0, 71, 0, 40, 44, 0xFF, "298F56FF", 0 },
/* 4*/ { "123456", 1, 79, 40, 0, 44, 0xFF, "123456FF", 0 },
/* 5*/ { "12345678", 2, 79, 40, 0, 44, 0x78, "12345678", 1 },
};
int data_size = ARRAY_SIZE(data);
int i, ret;
testStart("test_colour_get_cmyk");
for (i = 0; i < data_size; i++) {
int cyan, magenta, yellow, black;
unsigned char red, green, blue, alpha, rgb_alpha;
char rgb[9];
if (testContinue(p_ctx, i)) continue;
ret = out_colour_get_cmyk(data[i].colour, &cyan, &magenta, &yellow, &black, &alpha);
assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret);
assert_equal(cyan, data[i].cyan, "i:%d cyan %d != %d (magenta %d, yellow %d, black %d)\n", i, cyan, data[i].cyan, magenta, yellow, black);
assert_equal(magenta, data[i].magenta, "i:%d magenta %d != %d\n", i, magenta, data[i].magenta);
assert_equal(yellow, data[i].yellow, "i:%d yellow %d != %d\n", i, yellow, data[i].yellow);
assert_equal(alpha, data[i].alpha, "i:%d alpha %d != %d\n", i, alpha, data[i].alpha);
ret = out_colour_get_rgb(data[i].colour, &red, &green, &blue, &rgb_alpha);
assert_equal(ret, data[i].ret_rgb, "i:%d out_colour_get_rgb(%s) ret %d != %d\n", i, rgb, ret, data[i].ret_rgb);
assert_equal(rgb_alpha, alpha, "i:%d rgb_alpha %d != %d\n", i, rgb_alpha, alpha);
sprintf(rgb, "%02X%02X%02X%02X", red, green, blue, rgb_alpha);
assert_zero(strcmp(rgb, data[i].expected_rgb), "i:%d strcmp(%s, %s) != 0\n", i, rgb, data[i].expected_rgb);
}
testFinish();
}
INTERNAL int out_quiet_zones_test(const struct zint_symbol *symbol, const int hide_text, INTERNAL int out_quiet_zones_test(const struct zint_symbol *symbol, const int hide_text,
float *left, float *right, float *top, float *bottom); float *left, float *right, float *top, float *bottom);
@ -161,6 +327,9 @@ static void test_fopen(const testCtx *const p_ctx) {
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func */ testFunction funcs[] = { /* name, func */
{ "test_check_colour_options", test_check_colour_options },
{ "test_colour_get_rgb", test_colour_get_rgb },
{ "test_colour_get_cmyk", test_colour_get_cmyk },
{ "test_quiet_zones", test_quiet_zones }, { "test_quiet_zones", test_quiet_zones },
{ "test_fopen", test_fopen }, { "test_fopen", test_fopen },
}; };

View File

@ -1,6 +1,6 @@
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2020-2022 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2020-2023 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -54,6 +54,7 @@ static void test_print(const testCtx *const p_ctx) {
/* 1*/ { BARCODE_CODABLOCKF, -1, -1, -1, -1, -1, 20, "FFFFFF", "000000", 0, "1234567890123456789012345678901234567890", "codeblockf_reverse.pcx" }, /* 1*/ { BARCODE_CODABLOCKF, -1, -1, -1, -1, -1, 20, "FFFFFF", "000000", 0, "1234567890123456789012345678901234567890", "codeblockf_reverse.pcx" },
/* 2*/ { BARCODE_QRCODE, -1, -1, -1, -1, 2, 1, "", "D2E3F4", 0, "1234567890", "qr_bg.pcx" }, /* 2*/ { BARCODE_QRCODE, -1, -1, -1, -1, 2, 1, "", "D2E3F4", 0, "1234567890", "qr_bg.pcx" },
/* 3*/ { BARCODE_ULTRA, 1, BARCODE_BOX, 1, 1, -1, -1, "FF0000", "0000FF", 0, "ULTRACODE_123456789!", "ultra_fg_bg_hvwsp1_box1.pcx" }, /* 3*/ { BARCODE_ULTRA, 1, BARCODE_BOX, 1, 1, -1, -1, "FF0000", "0000FF", 0, "ULTRACODE_123456789!", "ultra_fg_bg_hvwsp1_box1.pcx" },
/* 4*/ { BARCODE_CODE11, -1, -1, -1, -1, -1, -1, "12345678", "FEDCBA98", 0, "123", "code11_fgbgtrans.pcx" },
}; };
int data_size = ARRAY_SIZE(data); int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;

View File

@ -1,6 +1,6 @@
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2020-2022 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2020-2023 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -202,6 +202,7 @@ static void test_print(const testCtx *const p_ctx) {
/* 56*/ { BARCODE_AZTEC, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, { 4, 7, "Z1.txt" }, "", "", "3456", "", 0, "aztec_z1_seq4of7.png", "" }, /* 56*/ { BARCODE_AZTEC, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, { 4, 7, "Z1.txt" }, "", "", "3456", "", 0, "aztec_z1_seq4of7.png", "" },
/* 57*/ { BARCODE_PDF417, -1, -1, BARCODE_NO_QUIET_ZONES, -1, -1, -1, 5, 8, 16, 1.5, { 0, 0, "" }, "", "", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", "", ZINT_WARN_NONCOMPLIANT, "pdf417_#204.png", "Ticket #204 Blank line in PDF417" }, /* 57*/ { BARCODE_PDF417, -1, -1, BARCODE_NO_QUIET_ZONES, -1, -1, -1, 5, 8, 16, 1.5, { 0, 0, "" }, "", "", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", "", ZINT_WARN_NONCOMPLIANT, "pdf417_#204.png", "Ticket #204 Blank line in PDF417" },
/* 58*/ { BARCODE_DPD, -1, -1, BARCODE_QUIET_ZONES | COMPLIANT_HEIGHT, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", "008182709980000020028101276", "", 0, "dpd_compliant.png", "Now with bind top 3X default" }, /* 58*/ { BARCODE_DPD, -1, -1, BARCODE_QUIET_ZONES | COMPLIANT_HEIGHT, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", "008182709980000020028101276", "", 0, "dpd_compliant.png", "Now with bind top 3X default" },
/* 59*/ { BARCODE_CHANNEL, -1, -1, CMYK_COLOUR | COMPLIANT_HEIGHT, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "100,85,0,20", "FFFFFF00", "123", "", 0, "channel_cmyk_nobg.png", "" },
}; };
int data_size = ARRAY_SIZE(data); int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;

View File

@ -1,6 +1,6 @@
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2020-2022 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2020-2023 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -57,40 +57,41 @@ static void test_print(const testCtx *const p_ctx) {
/* 1*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, 0, 0, "", "", 90, "Égjpqy", "code128_egrave_bold_rotate_90.eps" }, /* 1*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, 0, 0, "", "", 90, "Égjpqy", "code128_egrave_bold_rotate_90.eps" },
/* 2*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, -1, -1, 0, 0, "147AD0", "FC9630", 0, "123", "code39_fg_bg.eps" }, /* 2*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, -1, -1, 0, 0, "147AD0", "FC9630", 0, "123", "code39_fg_bg.eps" },
/* 3*/ { BARCODE_CODE39, -1, -1, CMYK_COLOUR, -1, -1, -1, -1, 0, 0, "147AD0EE", "FC9630", 0, "123", "code39_fgalpha_bg_cmyk.eps" }, /* 3*/ { BARCODE_CODE39, -1, -1, CMYK_COLOUR, -1, -1, -1, -1, 0, 0, "147AD0EE", "FC9630", 0, "123", "code39_fgalpha_bg_cmyk.eps" },
/* 4*/ { BARCODE_ULTRA, -1, -1, -1, -1, -1, -1, -1, 0, 0, "147AD0", "FC9630", 0, "123", "ultra_fg_bg.eps" }, /* 4*/ { BARCODE_CODE39, -1, -1, CMYK_COLOUR, -1, -1, -1, -1, 0, 0, "90,40,0,9", "FC963000", 0, "123", "code39_nobg_cmyk.eps" },
/* 5*/ { BARCODE_ULTRA, -1, 1, BARCODE_BOX, 2, -1, -1, -1, 0, 0, "0000FF", "FF0000", 0, "123", "ultra_fg_bg_box.eps" }, /* 5*/ { BARCODE_ULTRA, -1, -1, -1, -1, -1, -1, -1, 0, 0, "147AD0", "FC9630", 0, "123", "ultra_fg_bg.eps" },
/* 6*/ { BARCODE_ULTRA, -1, 2, BARCODE_BOX | CMYK_COLOUR, 1, 1, -1, -1, 0, 0, "0000FF", "FF0000", 0, "123", "ultra_fg_bg_box_cmyk.eps" }, /* 6*/ { BARCODE_ULTRA, -1, 1, BARCODE_BOX, 2, -1, -1, -1, 0, 0, "0000FF", "FF0000", 0, "123", "ultra_fg_bg_box.eps" },
/* 7*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", 0, "9771384524017+12", "ean13_2addon_ggs_5.2.2.5.1-2.eps" }, /* 7*/ { BARCODE_ULTRA, -1, 2, BARCODE_BOX | CMYK_COLOUR, 1, 1, -1, -1, 0, 0, "0000FF", "FF0000", 0, "123", "ultra_fg_bg_box_cmyk.eps" },
/* 8*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", 0, "012345678905+24", "upca_2addon_ggs_5.2.6.6-5.eps" }, /* 8*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", 0, "9771384524017+12", "ean13_2addon_ggs_5.2.2.5.1-2.eps" },
/* 9*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", 0, "0123456+12345", "upce_5addon.eps" }, /* 9*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", 0, "012345678905+24", "upca_2addon_ggs_5.2.6.6-5.eps" },
/* 10*/ { BARCODE_UPCE, -1, -1, SMALL_TEXT | BOLD_TEXT, -1, -1, -1, -1, 0, 0, "", "", 0, "0123456+12345", "upce_5addon_small_bold.eps" }, /* 10*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", 0, "0123456+12345", "upce_5addon.eps" },
/* 11*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, -1, -1, -1, -1, 0, 0, "", "", 0, "A\\B)ç(D", "code128_escape_latin1.eps" }, /* 11*/ { BARCODE_UPCE, -1, -1, SMALL_TEXT | BOLD_TEXT, -1, -1, -1, -1, 0, 0, "", "", 0, "0123456+12345", "upce_5addon_small_bold.eps" },
/* 12*/ { BARCODE_DBAR_LTD, -1, -1, BOLD_TEXT, -1, -1, -1, -1, 0, 0, "", "", 0, "1501234567890", "dbar_ltd_24724_fig7_bold.eps" }, /* 12*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, -1, -1, -1, -1, 0, 0, "", "", 0, "A\\B)ç(D", "code128_escape_latin1.eps" },
/* 13*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 0.1, 0, "", "", 0, "12", "dotcode_0.1.eps" }, /* 13*/ { BARCODE_DBAR_LTD, -1, -1, BOLD_TEXT, -1, -1, -1, -1, 0, 0, "", "", 0, "1501234567890", "dbar_ltd_24724_fig7_bold.eps" },
/* 14*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 0.08, 0, "", "", 0, "12", "dotcode_0.1.eps" }, /* 14*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 0.1, 0, "", "", 0, "12", "dotcode_0.1.eps" },
/* 15*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", 0, "12", "dotcode_1.0.eps" }, /* 15*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 0.08, 0, "", "", 0, "12", "dotcode_0.1.eps" },
/* 16*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 0, 0.1, "", "", 0, "12", "dotcode_1.0_ds0.1.eps" }, /* 16*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", 0, "12", "dotcode_1.0.eps" },
/* 17*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 0, 1.1, "", "", 0, "12", "dotcode_1.0_ds1.1.eps" }, /* 17*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 0, 0.1, "", "", 0, "12", "dotcode_1.0_ds0.1.eps" },
/* 18*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 1.5, 0, "", "", 0, "12", "dotcode_1.5.eps" }, /* 18*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 0, 1.1, "", "", 0, "12", "dotcode_1.0_ds1.1.eps" },
/* 19*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 1.5, 0.4, "", "", 0, "12", "dotcode_1.5_ds0.4.eps" }, /* 19*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 1.5, 0, "", "", 0, "12", "dotcode_1.5.eps" },
/* 20*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 1.5, 1.1, "", "", 0, "12", "dotcode_1.5_ds1.1.eps" }, /* 20*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 1.5, 0.4, "", "", 0, "12", "dotcode_1.5_ds0.4.eps" },
/* 21*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 1.5, 2.1, "", "", 0, "12", "dotcode_1.5_ds2.1.eps" }, /* 21*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 1.5, 1.1, "", "", 0, "12", "dotcode_1.5_ds1.1.eps" },
/* 22*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 2, 0, "", "", 0, "12", "dotcode_2.0.eps" }, /* 22*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 1.5, 2.1, "", "", 0, "12", "dotcode_1.5_ds2.1.eps" },
/* 23*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 2, 0.9, "", "", 0, "12", "dotcode_2.0_ds0.9.eps" }, /* 23*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 2, 0, "", "", 0, "12", "dotcode_2.0.eps" },
/* 24*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 2, 1.1, "", "", 0, "12", "dotcode_2.0_ds1.1.eps" }, /* 24*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 2, 0.9, "", "", 0, "12", "dotcode_2.0_ds0.9.eps" },
/* 25*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 3, 0, "", "", 0, "12", "dotcode_3.0.eps" }, /* 25*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 2, 1.1, "", "", 0, "12", "dotcode_2.0_ds1.1.eps" },
/* 26*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 3, 0.4, "", "", 0, "12", "dotcode_3.0_ds0.4.eps" }, /* 26*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 3, 0, "", "", 0, "12", "dotcode_3.0.eps" },
/* 27*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 3, 1.1, "", "", 0, "12", "dotcode_3.0_ds1.1.eps" }, /* 27*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 3, 0.4, "", "", 0, "12", "dotcode_3.0_ds0.4.eps" },
/* 28*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 3.5, 0, "", "", 0, "12", "dotcode_3.5.eps" }, /* 28*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 3, 1.1, "", "", 0, "12", "dotcode_3.0_ds1.1.eps" },
/* 29*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 3.5, 0.4, "", "", 0, "12", "dotcode_3.5_ds0.4.eps" }, /* 29*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 3.5, 0, "", "", 0, "12", "dotcode_3.5.eps" },
/* 30*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 3.5, 1.1, "", "", 0, "12", "dotcode_3.5_ds1.1.eps" }, /* 30*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 3.5, 0.4, "", "", 0, "12", "dotcode_3.5_ds0.4.eps" },
/* 31*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 5, 0, "", "", 0, "12", "dotcode_5.0.eps" }, /* 31*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 3.5, 1.1, "", "", 0, "12", "dotcode_3.5_ds1.1.eps" },
/* 32*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 5, 0.2, "", "", 0, "12", "dotcode_5.0_ds0.2.eps" }, /* 32*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 5, 0, "", "", 0, "12", "dotcode_5.0.eps" },
/* 33*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 5, 1.1, "", "", 0, "12", "dotcode_5.0_ds1.1.eps" }, /* 33*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 5, 0.2, "", "", 0, "12", "dotcode_5.0_ds0.2.eps" },
/* 34*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 5, 1.7, "", "", 0, "12", "dotcode_5.0_ds1.7.eps" }, /* 34*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 5, 1.1, "", "", 0, "12", "dotcode_5.0_ds1.1.eps" },
/* 35*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 0, 0, "FF0000", "0000FF00", 0, "12", "dotcode_no_bg.eps" }, /* 35*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 5, 1.7, "", "", 0, "12", "dotcode_5.0_ds1.7.eps" },
/* 36*/ { BARCODE_MAXICODE, -1, -1, CMYK_COLOUR, -1, -1, -1, -1, 0, 0, "", "", 270, "12", "maxicode_rotate_270_cmyk.eps" }, /* 36*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 0, 0, "FF0000", "0000FF00", 0, "12", "dotcode_no_bg.eps" },
/* 37*/ { BARCODE_MAXICODE, -1, -1, -1, 3, -1, -1, -1, 0, 0, "", "0000FF00", 180, "12", "maxicode_no_bg_hwsp3_rotate_180.eps" }, /* 37*/ { BARCODE_MAXICODE, -1, -1, CMYK_COLOUR, -1, -1, -1, -1, 0, 0, "", "", 270, "12", "maxicode_rotate_270_cmyk.eps" },
/* 38*/ { BARCODE_MAXICODE, -1, -1, -1, 3, -1, -1, -1, 0, 0, "", "0000FF00", 180, "12", "maxicode_no_bg_hwsp3_rotate_180.eps" },
}; };
int data_size = ARRAY_SIZE(data); int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;

View File

@ -1,6 +1,6 @@
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2020-2022 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2020-2023 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -109,6 +109,7 @@ static void test_print(const testCtx *const p_ctx) {
/* 50*/ { BARCODE_CODE49, -1, -1, COMPLIANT_HEIGHT, -1, -1, -1, -1, -1, -1, 0, "FF11157F", "", 0, "A", "", 0, "code49_comph_fgalpha.svg" }, /* 50*/ { BARCODE_CODE49, -1, -1, COMPLIANT_HEIGHT, -1, -1, -1, -1, -1, -1, 0, "FF11157F", "", 0, "A", "", 0, "code49_comph_fgalpha.svg" },
/* 51*/ { BARCODE_CODABLOCKF, -1, -1, COMPLIANT_HEIGHT, -1, -1, -1, -1, -1, 2, 0, "00000033", "FFFFFF66", 0, "1234567890123456789012345678901234", "", 0, "codablockf_comph_sep2_fgbgalpha.svg" }, /* 51*/ { BARCODE_CODABLOCKF, -1, -1, COMPLIANT_HEIGHT, -1, -1, -1, -1, -1, 2, 0, "00000033", "FFFFFF66", 0, "1234567890123456789012345678901234", "", 0, "codablockf_comph_sep2_fgbgalpha.svg" },
/* 52*/ { BARCODE_DPD, -1, -1, BARCODE_QUIET_ZONES | COMPLIANT_HEIGHT, -1, -1, -1, -1, -1, -1, 0, "", "", 0, "008182709980000020028101276", "", 0, "dpd_compliant.svg" }, /* 52*/ { BARCODE_DPD, -1, -1, BARCODE_QUIET_ZONES | COMPLIANT_HEIGHT, -1, -1, -1, -1, -1, -1, 0, "", "", 0, "008182709980000020028101276", "", 0, "dpd_compliant.svg" },
/* 53*/ { BARCODE_CHANNEL, -1, -1, CMYK_COLOUR | COMPLIANT_HEIGHT, -1, -1, -1, -1, -1, -1, 0, "100,85,0,20", "FFFFFF00", 0, "123", "", 0, "channel_cmyk_nobg.svg" },
}; };
int data_size = ARRAY_SIZE(data); int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;

View File

@ -1,6 +1,6 @@
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2020-2022 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2020-2023 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -188,19 +188,20 @@ static void test_print(const testCtx *const p_ctx) {
/* 5*/ { BARCODE_CODE128, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "00000099", "FEDCBACC", "A", "", "code128_fgbgalpha.tif", "" }, /* 5*/ { BARCODE_CODE128, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "00000099", "FEDCBACC", "A", "", "code128_fgbgalpha.tif", "" },
/* 6*/ { BARCODE_CODE128, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, -1, 0, 0, "C00000", "FEDCBA", "A", "", "code128_cmyk.tif", "" }, /* 6*/ { BARCODE_CODE128, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, -1, 0, 0, "C00000", "FEDCBA", "A", "", "code128_cmyk.tif", "" },
/* 7*/ { BARCODE_CODE128, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, -1, 0, 0, "C0000099", "FEDCBACC", "A", "", "code128_cmyk_fgbgalpha.tif", "" }, /* 7*/ { BARCODE_CODE128, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, -1, 0, 0, "C0000099", "FEDCBACC", "A", "", "code128_cmyk_fgbgalpha.tif", "" },
/* 8*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "C00000", "FEDCBACC", "1234", "", "ultra_bgalpha.tif", "" }, /* 8*/ { BARCODE_CODE128, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, -1, 0, 0, "71,0,40,44", "10,0,20,5", "A", "", "code128_cmyk_fgbgcmyk.tif", "" },
/* 9*/ { BARCODE_ULTRA, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, -1, 0, 0, "C00000", "FEDCBACC", "1234", "", "ultra_cmyk_bgalpha.tif", "" }, /* 9*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "C00000", "FEDCBACC", "1234", "", "ultra_bgalpha.tif", "" },
/* 10*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "000000BB", "FEDCBA", "1234", "", "ultra_fgalpha.tif", "" }, /* 10*/ { BARCODE_ULTRA, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, -1, 0, 0, "C00000", "FEDCBACC", "1234", "", "ultra_cmyk_bgalpha.tif", "" },
/* 11*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "000000BB", "FEDCBACC", "1234", "", "ultra_fgbgalpha.tif", "" }, /* 11*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "000000BB", "FEDCBA", "1234", "", "ultra_fgalpha.tif", "" },
/* 12*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "000000BB", "", "1234", "", "ultra_fgalpha_nobg.tif", "" }, /* 12*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "000000BB", "FEDCBACC", "1234", "", "ultra_fgbgalpha.tif", "" },
/* 13*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "", "FEDCBACC", "1234", "", "ultra_bgalpha_nofg.tif", "" }, /* 13*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "000000BB", "", "1234", "", "ultra_fgalpha_nobg.tif", "" },
/* 14*/ { BARCODE_ULTRA, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0.5f, "", "", "1", "", "ultra_odd.tif", "" }, /* 14*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "", "FEDCBACC", "1234", "", "ultra_bgalpha_nofg.tif", "" },
/* 15*/ { BARCODE_ULTRA, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, -1, 0, 0, "", "", "1234", "", "ultra_cmyk.tif", "" }, /* 15*/ { BARCODE_ULTRA, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0.5f, "", "", "1", "", "ultra_odd.tif", "" },
/* 16*/ { BARCODE_ULTRA, -1, 1, BARCODE_BOX, 1, 1, -1, -1, -1, 0, 0, "FF0000", "0000FF", "1234", "", "ultra_fgbg_hvwsp1_box1.tif", "" }, /* 16*/ { BARCODE_ULTRA, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, -1, 0, 0, "", "", "1234", "", "ultra_cmyk.tif", "" },
/* 17*/ { BARCODE_HANXIN, UNICODE_MODE, -1, -1, -1, -1, -1, 4, 84, 0, 2, "", "", "1", "", "hanxin_v84_l4_scale2.tif", "" }, /* 17*/ { BARCODE_ULTRA, -1, 1, BARCODE_BOX, 1, 1, -1, -1, -1, 0, 0, "FF0000", "0000FF", "1234", "", "ultra_fgbg_hvwsp1_box1.tif", "" },
/* 18*/ { BARCODE_AZTEC, -1, -1, -1, -1, -1, -1, -1, 32, 0, 0, "4BE055", "", "1", "", "aztec_v32_fg.tif", "" }, /* 18*/ { BARCODE_HANXIN, UNICODE_MODE, -1, -1, -1, -1, -1, 4, 84, 0, 2, "", "", "1", "", "hanxin_v84_l4_scale2.tif", "" },
/* 19*/ { BARCODE_DAFT, -1, -1, -1, -1, -1, -1, -1, -1, 8, 0.5f, "", "", "F", "", "daft_height8_scale0.5.tif", "" }, /* 19*/ { BARCODE_AZTEC, -1, -1, -1, -1, -1, -1, -1, 32, 0, 0, "4BE055", "", "1", "", "aztec_v32_fg.tif", "" },
/* 20*/ { BARCODE_DAFT, -1, -1, -1, -1, -1, -1, -1, -1, 1, 0.5f, "", "", "DAFT", "", "daft_height1_scale0.5.tif", "" }, /* 20*/ { BARCODE_DAFT, -1, -1, -1, -1, -1, -1, -1, -1, 8, 0.5f, "", "", "F", "", "daft_height8_scale0.5.tif", "" },
/* 21*/ { BARCODE_DAFT, -1, -1, -1, -1, -1, -1, -1, -1, 1, 0.5f, "", "", "DAFT", "", "daft_height1_scale0.5.tif", "" },
}; };
int data_size = ARRAY_SIZE(data); int data_size = ARRAY_SIZE(data);
int i, length, ret; int i, length, ret;

View File

@ -1,7 +1,7 @@
/* tif.c - Aldus Tagged Image File Format support */ /* tif.c - Aldus Tagged Image File Format support */
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2016-2022 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2016-2023 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -32,6 +32,7 @@
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
#include <math.h>
#include <stdio.h> #include <stdio.h>
#ifdef _MSC_VER #ifdef _MSC_VER
#include <io.h> #include <io.h>
@ -59,20 +60,16 @@ static void to_color_map(const unsigned char rgb[4], tiff_color_t *color_map_ent
color_map_entry->blue = (rgb[2] << 8) | rgb[2]; color_map_entry->blue = (rgb[2] << 8) | rgb[2];
} }
static void to_cmyk(const unsigned char rgb[3], const unsigned char alpha, unsigned char *cmyk) { static void to_cmyk(const char *colour, unsigned char *cmyk) {
unsigned char max = rgb[0]; int cyan, magenta, yellow, black;
if (rgb[1] > max) { unsigned char alpha;
max = rgb[1];
}
if (rgb[2] > max) {
max = rgb[2];
}
cmyk[0] = max - rgb[0];
cmyk[1] = max - rgb[1];
cmyk[2] = max - rgb[2];
cmyk[3] = 0xff - max;
cmyk[4] = alpha;
(void) out_colour_get_cmyk(colour, &cyan, &magenta, &yellow, &black, &alpha);
cmyk[0] = (unsigned char) roundf(cyan * 0xFF / 100.0f);
cmyk[1] = (unsigned char) roundf(magenta * 0xFF / 100.0f);
cmyk[2] = (unsigned char) roundf(yellow * 0xFF / 100.0f);
cmyk[3] = (unsigned char) roundf(black * 0xFF / 100.0f);
cmyk[4] = alpha;
} }
static int is_big_endian(void) { static int is_big_endian(void) {
@ -80,7 +77,7 @@ static int is_big_endian(void) {
} }
/* TIFF Revision 6.0 https://www.adobe.io/content/dam/udp/en/open/standards/tiff/TIFF6.pdf */ /* TIFF Revision 6.0 https://www.adobe.io/content/dam/udp/en/open/standards/tiff/TIFF6.pdf */
INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) { INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, const unsigned char *pixelbuf) {
unsigned char fg[4], bg[4]; unsigned char fg[4], bg[4];
int i; int i;
int pmi; /* PhotometricInterpretation */ int pmi; /* PhotometricInterpretation */
@ -101,7 +98,7 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
unsigned int bytes_put; unsigned int bytes_put;
long total_bytes_put; long total_bytes_put;
FILE *tif_file; FILE *tif_file;
unsigned char *pb; const unsigned char *pb;
int compression = TIF_NO_COMPRESSION; int compression = TIF_NO_COMPRESSION;
tif_lzw_state lzw_state; tif_lzw_state lzw_state;
long file_pos; long file_pos;
@ -119,47 +116,32 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
int ifd_size; int ifd_size;
uint32_t temp32; uint32_t temp32;
fg[0] = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]); (void) out_colour_get_rgb(symbol->fgcolour, &fg[0], &fg[1], &fg[2], &fg[3]);
fg[1] = (16 * ctoi(symbol->fgcolour[2])) + ctoi(symbol->fgcolour[3]); (void) out_colour_get_rgb(symbol->bgcolour, &bg[0], &bg[1], &bg[2], &bg[3]);
fg[2] = (16 * ctoi(symbol->fgcolour[4])) + ctoi(symbol->fgcolour[5]);
bg[0] = (16 * ctoi(symbol->bgcolour[0])) + ctoi(symbol->bgcolour[1]);
bg[1] = (16 * ctoi(symbol->bgcolour[2])) + ctoi(symbol->bgcolour[3]);
bg[2] = (16 * ctoi(symbol->bgcolour[4])) + ctoi(symbol->bgcolour[5]);
if (strlen(symbol->fgcolour) > 6) {
fg[3] = (16 * ctoi(symbol->fgcolour[6])) + ctoi(symbol->fgcolour[7]);
} else {
fg[3] = 0xff;
}
if (strlen(symbol->bgcolour) > 6) {
bg[3] = (16 * ctoi(symbol->bgcolour[6])) + ctoi(symbol->bgcolour[7]);
} else {
bg[3] = 0xff;
}
if (symbol->symbology == BARCODE_ULTRA) { if (symbol->symbology == BARCODE_ULTRA) {
static const int ultra_chars[8] = { 'W', 'C', 'B', 'M', 'R', 'Y', 'G', 'K' }; static const int ultra_chars[8] = { 'W', 'C', 'B', 'M', 'R', 'Y', 'G', 'K' };
static const unsigned char ultra_rgbs[8][3] = {
{ 0xff, 0xff, 0xff, }, /* White */
{ 0, 0xff, 0xff, }, /* Cyan */
{ 0, 0, 0xff, }, /* Blue */
{ 0xff, 0, 0xff, }, /* Magenta */
{ 0xff, 0, 0, }, /* Red */
{ 0xff, 0xff, 0, }, /* Yellow */
{ 0, 0xff, 0, }, /* Green */
{ 0, 0, 0, }, /* Black */
};
if (symbol->output_options & CMYK_COLOUR) { if (symbol->output_options & CMYK_COLOUR) {
static const unsigned char ultra_cmyks[8][4] = {
{ 0, 0, 0, 0 }, /* White */
{ 0xFF, 0, 0, 0 }, /* Cyan */
{ 0xFF, 0xFF, 0, 0 }, /* Blue */
{ 0, 0xFF, 0, 0 }, /* Magenta */
{ 0, 0xFF, 0xFF, 0 }, /* Red */
{ 0, 0, 0xFF, 0 }, /* Yellow */
{ 0xFF, 0, 0xFF, 0 }, /* Green */
{ 0, 0, 0, 0xFF }, /* Black */
};
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
map[ultra_chars[i]] = i; map[ultra_chars[i]] = i;
to_cmyk(ultra_rgbs[i], fg[3], palette[i]); memcpy(palette[i], ultra_cmyks[i], 4);
palette[i][4] = fg[3];
} }
map['0'] = 8; map['0'] = 8;
to_cmyk(bg, bg[3], palette[8]); to_cmyk(symbol->bgcolour, palette[8]);
map['1'] = 9; map['1'] = 9;
to_cmyk(fg, fg[3], palette[9]); to_cmyk(symbol->fgcolour, palette[9]);
pmi = TIF_PMI_SEPARATED; pmi = TIF_PMI_SEPARATED;
bits_per_sample = 8; bits_per_sample = 8;
@ -171,6 +153,16 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
} }
pixels_per_sample = 1; pixels_per_sample = 1;
} else { } else {
static const unsigned char ultra_rgbs[8][3] = {
{ 0xff, 0xff, 0xff, }, /* White */
{ 0, 0xff, 0xff, }, /* Cyan */
{ 0, 0, 0xff, }, /* Blue */
{ 0xff, 0, 0xff, }, /* Magenta */
{ 0xff, 0, 0, }, /* Red */
{ 0xff, 0xff, 0, }, /* Yellow */
{ 0, 0xff, 0, }, /* Green */
{ 0, 0, 0, }, /* Black */
};
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
map[ultra_chars[i]] = i; map[ultra_chars[i]] = i;
memcpy(palette[i], ultra_rgbs[i], 3); memcpy(palette[i], ultra_rgbs[i], 3);
@ -201,9 +193,9 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
} else { /* fg/bg only */ } else { /* fg/bg only */
if (symbol->output_options & CMYK_COLOUR) { if (symbol->output_options & CMYK_COLOUR) {
map['0'] = 0; map['0'] = 0;
to_cmyk(bg, bg[3], palette[0]); to_cmyk(symbol->bgcolour, palette[0]);
map['1'] = 1; map['1'] = 1;
to_cmyk(fg, fg[3], palette[1]); to_cmyk(symbol->fgcolour, palette[1]);
pmi = TIF_PMI_SEPARATED; pmi = TIF_PMI_SEPARATED;
bits_per_sample = 8; bits_per_sample = 8;

View File

@ -72,7 +72,7 @@ extern "C" {
float x, y; /* Centre */ float x, y; /* Centre */
float diameter; /* Circle diameter. Does not include width (if any) */ float diameter; /* Circle diameter. Does not include width (if any) */
float width; /* Width of circle perimeter (circumference). 0 for fill (disc) */ float width; /* Width of circle perimeter (circumference). 0 for fill (disc) */
int colour; /* Non-zero for draw with background colour (else draw with foreground colour) */ int colour; /* Zero for draw with foreground colour (else draw with background colour (legacy)) */
struct zint_vector_circle *next; /* Pointer to next circle */ struct zint_vector_circle *next; /* Pointer to next circle */
}; };
@ -101,8 +101,8 @@ extern "C" {
int whitespace_height; /* Height in X-dimensions of whitespace above & below the barcode */ int whitespace_height; /* Height in X-dimensions of whitespace above & below the barcode */
int border_width; /* Size of border in X-dimensions */ int border_width; /* Size of border in X-dimensions */
int output_options; /* Various output parameters (bind, box etc, see below) */ int output_options; /* Various output parameters (bind, box etc, see below) */
char fgcolour[10]; /* Foreground as RGB/RGBA hexadecimal string, 6 or 8 characters, NUL-terminated */ char fgcolour[16]; /* Foreground as hexadecimal RGB/RGBA or decimal "C,M,Y,K" string, NUL-terminated */
char bgcolour[10]; /* Background as RGB/RGBA hexadecimal string, 6 or 8 characters, NUL-terminated */ char bgcolour[16]; /* Background as hexadecimal RGB/RGBA or decimal "C,M,Y,K" string, NUL-terminated */
char *fgcolor; /* Pointer to fgcolour (alternate spelling) */ char *fgcolor; /* Pointer to fgcolour (alternate spelling) */
char *bgcolor; /* Pointer to bgcolour (alternate spelling) */ char *bgcolor; /* Pointer to bgcolour (alternate spelling) */
char outfile[256]; /* Name of file to output to, NUL-terminated. Default "out.png" ("out.gif" if no PNG) */ char outfile[256]; /* Name of file to output to, NUL-terminated. Default "out.png" ("out.gif" if no PNG) */

View File

@ -29,6 +29,7 @@
#include <QFontMetrics> #include <QFontMetrics>
/* The following include is necessary to compile with Qt 5.15 on Windows; Qt 5.7 did not require it */ /* The following include is necessary to compile with Qt 5.15 on Windows; Qt 5.7 did not require it */
#include <QPainterPath> #include <QPainterPath>
#include <QRegularExpression>
// Shorthand // Shorthand
#define QSL QStringLiteral #define QSL QStringLiteral
@ -41,6 +42,41 @@ namespace Zint {
static const int maxSegs = 256; static const int maxSegs = 256;
static const int maxCLISegs = 10; /* CLI restricted to 10 segments (including main data) */ static const int maxCLISegs = 10; /* CLI restricted to 10 segments (including main data) */
static const QRegularExpression colorRE(
QSL("^([0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?)|(((100|[0-9]{0,2}),){3}(100|[0-9]{0,2}))$"));
static QString qcolor_to_str(const QColor &color) {
if (color.alpha() == 0xFF) {
return QString::asprintf("%02X%02X%02X", color.red(), color.green(), color.blue());
}
return QString::asprintf("%02X%02X%02X%02X", color.red(), color.green(), color.blue(), color.alpha());
}
static QColor str_to_qcolor(const QString &text) {
QColor color;
int r, g, b, a;
if (text.contains(',')) {
int comma1 = text.indexOf(',');
int comma2 = text.indexOf(',', comma1 + 1);
int comma3 = text.indexOf(',', comma2 + 1);
int black = 100 - text.mid(comma3 + 1).toInt();
int val = 100 - text.mid(0, comma1).toInt();
r = (int) roundf((0xFF * val * black) / 10000.0f);
val = 100 - text.mid(comma1 + 1, comma2 - comma1 - 1).toInt();
g = (int) roundf((0xFF * val * black) / 10000.0f);
val = 100 - text.mid(comma2 + 1, comma3 - comma2 - 1).toInt();
b = (int) roundf((0xFF * val * black) / 10000.0f);
a = 0xFF;
} else {
r = text.mid(0, 2).toInt(nullptr, 16);
g = text.mid(2, 2).toInt(nullptr, 16);
b = text.mid(4, 2).toInt(nullptr, 16);
a = text.length() == 8 ? text.mid(6, 2).toInt(nullptr, 16) : 0xFF;
}
color.setRgb(r, g, b, a);
return color;
}
/* Helper to convert ECI combo index to ECI value */ /* Helper to convert ECI combo index to ECI value */
static int ECIIndexToECI(const int ECIIndex) { static int ECIIndexToECI(const int ECIIndex) {
int ret; int ret;
@ -109,7 +145,7 @@ namespace Zint {
m_scale(1.0f), m_scale(1.0f),
m_dotty(false), m_dot_size(4.0f / 5.0f), m_dotty(false), m_dot_size(4.0f / 5.0f),
m_guardDescent(5.0f), m_guardDescent(5.0f),
m_fgColor(Qt::black), m_bgColor(Qt::white), m_cmyk(false), m_fgStr(QSL("000000")), m_bgStr(QSL("FFFFFF")), m_cmyk(false),
m_borderType(0), m_borderWidth(0), m_borderType(0), m_borderWidth(0),
m_whitespace(0), m_vwhitespace(0), m_whitespace(0), m_vwhitespace(0),
m_fontSetting(0), m_fontSetting(0),
@ -175,14 +211,8 @@ namespace Zint {
if (m_reader_init) { if (m_reader_init) {
m_zintSymbol->output_options |= READER_INIT; m_zintSymbol->output_options |= READER_INIT;
} }
strcpy(m_zintSymbol->fgcolour, m_fgColor.name().toLatin1().right(6)); strcpy(m_zintSymbol->fgcolour, m_fgStr.toLatin1().left(15));
if (m_fgColor.alpha() != 0xFF) { strcpy(m_zintSymbol->bgcolour, m_bgStr.toLatin1().left(15));
strcat(m_zintSymbol->fgcolour, m_fgColor.name(QColor::HexArgb).toLatin1().mid(1,2));
}
strcpy(m_zintSymbol->bgcolour, m_bgColor.name().toLatin1().right(6));
if (m_bgColor.alpha() != 0xFF) {
strcat(m_zintSymbol->bgcolour, m_bgColor.name(QColor::HexArgb).toLatin1().mid(1,2));
}
strcpy(m_zintSymbol->primary, m_primaryMessage.toLatin1().left(127)); strcpy(m_zintSymbol->primary, m_primaryMessage.toLatin1().left(127));
m_zintSymbol->option_1 = m_option_1; m_zintSymbol->option_1 = m_option_1;
m_zintSymbol->option_2 = m_option_2; m_zintSymbol->option_2 = m_option_2;
@ -412,22 +442,48 @@ namespace Zint {
memset(&m_structapp, 0, sizeof(m_structapp)); memset(&m_structapp, 0, sizeof(m_structapp));
} }
/* Foreground colour */ /* Foreground colour (may be RGB(A) hex string or CMYK decimal "C,M,Y,K" percentage string) */
QString QZint::fgStr() const {
return m_fgStr;
}
bool QZint::setFgStr(const QString& fgStr) {
if (fgStr.indexOf(colorRE) == 0) {
m_fgStr = fgStr;
return true;
}
return false;
}
/* Foreground colour as QColor */
QColor QZint::fgColor() const { QColor QZint::fgColor() const {
return m_fgColor; return str_to_qcolor(m_fgStr);
} }
void QZint::setFgColor(const QColor& fgColor) { void QZint::setFgColor(const QColor& fgColor) {
m_fgColor = fgColor; m_fgStr = qcolor_to_str(fgColor);
} }
/* Background colour */ /* Background colour (may be RGB(A) hex string or CMYK decimal "C,M,Y,K" percentage string) */
QString QZint::bgStr() const {
return m_bgStr;
}
bool QZint::setBgStr(const QString& bgStr) {
if (bgStr.indexOf(colorRE) == 0) {
m_bgStr = bgStr;
return true;
}
return false;
}
/* Background colour as QColor */
QColor QZint::bgColor() const { QColor QZint::bgColor() const {
return m_bgColor; return str_to_qcolor(m_bgStr);
} }
void QZint::setBgColor(const QColor& bgColor) { void QZint::setBgColor(const QColor& bgColor) {
m_bgColor = bgColor; m_bgStr = qcolor_to_str(bgColor);
} }
/* Use CMYK colour space (Encapsulated PostScript and TIF) */ /* Use CMYK colour space (Encapsulated PostScript and TIF) */
@ -848,6 +904,8 @@ namespace Zint {
struct zint_vector_hexagon *hex; struct zint_vector_hexagon *hex;
struct zint_vector_circle *circle; struct zint_vector_circle *circle;
struct zint_vector_string *string; struct zint_vector_string *string;
QColor fgColor = str_to_qcolor(m_fgStr);
QColor bgColor = str_to_qcolor(m_bgStr);
encode(); encode();
@ -897,8 +955,10 @@ namespace Zint {
painter.translate(xtr, ytr); painter.translate(xtr, ytr);
painter.scale(scale, scale); painter.scale(scale, scale);
QBrush bgBrush(m_bgColor); QBrush bgBrush(bgColor);
painter.fillRect(QRectF(0, 0, gwidth, gheight), bgBrush); if (bgColor.alpha() != 0) {
painter.fillRect(QRectF(0, 0, gwidth, gheight), bgBrush);
}
// Plot rectangles // Plot rectangles
rect = m_zintSymbol->vector->rectangles; rect = m_zintSymbol->vector->rectangles;
@ -908,7 +968,7 @@ namespace Zint {
QBrush brush(Qt::SolidPattern); QBrush brush(Qt::SolidPattern);
while (rect) { while (rect) {
if (rect->colour == -1) { if (rect->colour == -1) {
brush.setColor(m_fgColor); brush.setColor(fgColor);
} else { } else {
brush.setColor(colourToQtColor(rect->colour)); brush.setColor(colourToQtColor(rect->colour));
} }
@ -924,7 +984,7 @@ namespace Zint {
hex = m_zintSymbol->vector->hexagons; hex = m_zintSymbol->vector->hexagons;
if (hex) { if (hex) {
painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::Antialiasing);
QBrush fgBrush(m_fgColor); QBrush fgBrush(fgColor);
qreal previous_diameter = 0.0, radius = 0.0, half_radius = 0.0, half_sqrt3_radius = 0.0; qreal previous_diameter = 0.0, radius = 0.0, half_radius = 0.0, half_sqrt3_radius = 0.0;
while (hex) { while (hex) {
if (previous_diameter != hex->diameter) { if (previous_diameter != hex->diameter) {
@ -953,20 +1013,20 @@ namespace Zint {
if (circle) { if (circle) {
painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::Antialiasing);
QPen p; QPen p;
QBrush fgBrush(m_fgColor); QBrush fgBrush(fgColor);
qreal previous_diameter = 0.0, radius = 0.0; qreal previous_diameter = 0.0, radius = 0.0;
while (circle) { while (circle) {
if (previous_diameter != circle->diameter) { if (previous_diameter != circle->diameter) {
previous_diameter = circle->diameter; previous_diameter = circle->diameter;
radius = 0.5 * previous_diameter; radius = 0.5 * previous_diameter;
} }
if (circle->colour) { // Set means use background colour if (circle->colour) { // Set means use background colour (legacy, no longer used)
p.setColor(m_bgColor); p.setColor(bgColor);
p.setWidthF(circle->width); p.setWidthF(circle->width);
painter.setPen(p); painter.setPen(p);
painter.setBrush(circle->width ? Qt::NoBrush : bgBrush); painter.setBrush(circle->width ? Qt::NoBrush : bgBrush);
} else { } else {
p.setColor(m_fgColor); p.setColor(fgColor);
p.setWidthF(circle->width); p.setWidthF(circle->width);
painter.setPen(p); painter.setPen(p);
painter.setBrush(circle->width ? Qt::NoBrush : fgBrush); painter.setBrush(circle->width ? Qt::NoBrush : fgBrush);
@ -981,7 +1041,7 @@ namespace Zint {
if (string) { if (string) {
painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::Antialiasing);
QPen p; QPen p;
p.setColor(m_fgColor); p.setColor(fgColor);
painter.setPen(p); painter.setPen(p);
bool bold = (m_zintSymbol->output_options & BOLD_TEXT) bool bold = (m_zintSymbol->output_options & BOLD_TEXT)
&& (!isExtendable() || (m_zintSymbol->output_options & SMALL_TEXT)); && (!isExtendable() || (m_zintSymbol->output_options & SMALL_TEXT));
@ -1080,6 +1140,7 @@ namespace Zint {
const bool autoHeight, const float heightPerRow, const QString& outfile, const bool autoHeight, const float heightPerRow, const QString& outfile,
const QZintXdimDpVars *xdimdpVars) const { const QZintXdimDpVars *xdimdpVars) const {
QString cmd(win && !noEXE ? QSL("zint.exe") : QSL("zint")); QString cmd(win && !noEXE ? QSL("zint.exe") : QSL("zint"));
bool nobackground = bgColor().alpha() == 0;
char name_buf[32]; char name_buf[32];
if (barcodeNames && ZBarcode_BarcodeName(m_symbol, name_buf) == 0) { if (barcodeNames && ZBarcode_BarcodeName(m_symbol, name_buf) == 0) {
@ -1093,8 +1154,8 @@ namespace Zint {
arg_int(cmd, "--addongap=", option2()); arg_int(cmd, "--addongap=", option2());
} }
if (bgColor() != Qt::white && bgColor() != QColor(0xFF, 0xFF, 0xFF, 0)) { if (bgStr() != QSL("FFFFFF") && !nobackground) {
arg_color(cmd, "--bg=", bgColor()); arg_str(cmd, "--bg=", bgStr());
} }
bool default_bind = false, default_bind_top = false, default_box = false, default_border = false; bool default_bind = false, default_bind_top = false, default_box = false, default_border = false;
@ -1166,8 +1227,8 @@ namespace Zint {
arg_bool(cmd, "--extraesc", inputMode() & EXTRA_ESCAPE_MODE); arg_bool(cmd, "--extraesc", inputMode() & EXTRA_ESCAPE_MODE);
arg_bool(cmd, "--fast", inputMode() & FAST_MODE); arg_bool(cmd, "--fast", inputMode() & FAST_MODE);
if (fgColor() != Qt::black) { if (fgStr() != QSL("000000") && fgStr() != QSL("000000FF")) {
arg_color(cmd, "--fg=", fgColor()); arg_str(cmd, "--fg=", fgStr());
} }
arg_bool(cmd, "--fullmultibyte", supportsFullMultibyte() && (option3() & 0xFF) == ZINT_FULL_MULTIBYTE); arg_bool(cmd, "--fullmultibyte", supportsFullMultibyte() && (option3() & 0xFF) == ZINT_FULL_MULTIBYTE);
@ -1202,7 +1263,7 @@ namespace Zint {
arg_int(cmd, "--mode=", option1()); arg_int(cmd, "--mode=", option1());
} }
arg_bool(cmd, "--nobackground", bgColor() == QColor(0xFF, 0xFF, 0xFF, 0)); arg_bool(cmd, "--nobackground", nobackground);
arg_bool(cmd, "--noquietzones", hasDefaultQuietZones() && noQuietZones()); arg_bool(cmd, "--noquietzones", hasDefaultQuietZones() && noQuietZones());
arg_bool(cmd, "--notext", hasHRT() && !showText()); arg_bool(cmd, "--notext", hasHRT() && !showText());
arg_data(cmd, longOptOnly ? "--output=" : "-o ", outfile, win); arg_data(cmd, longOptOnly ? "--output=" : "-o ", outfile, win);
@ -1300,14 +1361,6 @@ namespace Zint {
} }
} }
void QZint::arg_color(QString& cmd, const char *const opt, const QColor val) {
if (val.alpha() != 0xFF) {
cmd += QString::asprintf(" %s%02X%02X%02X%02X", opt, val.red(), val.green(), val.blue(), val.alpha());
} else {
cmd += QString::asprintf(" %s%02X%02X%02X", opt, val.red(), val.green(), val.blue());
}
}
void QZint::arg_data(QString& cmd, const char *const opt, const QString& val, const bool win) { void QZint::arg_data(QString& cmd, const char *const opt, const QString& val, const bool win) {
if (!val.isEmpty()) { if (!val.isEmpty()) {
QString text(val); QString text(val);

View File

@ -1,7 +1,7 @@
/*************************************************************************** /***************************************************************************
* Copyright (C) 2008 by BogDan Vatra * * Copyright (C) 2008 by BogDan Vatra *
* bogdan@licentia.eu * * bogdan@licentia.eu *
* Copyright (C) 2010-2022 Robin Stuart * * Copyright (C) 2010-2023 Robin Stuart *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by * * it under the terms of the GNU General Public License as published by *
@ -124,11 +124,19 @@ public:
void setStructApp(const int count, const int index, const QString& id); void setStructApp(const int count, const int index, const QString& id);
void clearStructApp(); void clearStructApp();
/* Foreground colour */ /* Foreground colour (may be RGB(A) hex string or CMYK decimal "C,M,Y,K" percentage string) */
QString fgStr() const; // `symbol->fgcolour`
bool setFgStr(const QString& fgStr); // Returns false if not valid colour string
/* Foreground colour as QColor */
QColor fgColor() const; // `symbol->fgcolour` QColor fgColor() const; // `symbol->fgcolour`
void setFgColor(const QColor& fgColor); void setFgColor(const QColor& fgColor);
/* Background colour */ /* Background colour (may be RGB(A) hex string or CMYK decimal "C,M,Y,K" percentage string) */
QString bgStr() const; // `symbol->bgcolour`
bool setBgStr(const QString& bgStr); // Returns false if not valid colour string
/* Background colour as QColor */
QColor bgColor() const; // `symbol->bgcolour` QColor bgColor() const; // `symbol->bgcolour`
void setBgColor(const QColor& bgColor); void setBgColor(const QColor& bgColor);
@ -322,7 +330,6 @@ private:
static void arg_str(QString& cmd, const char *const opt, const QString& val); static void arg_str(QString& cmd, const char *const opt, const QString& val);
static void arg_int(QString& cmd, const char *const opt, const int val, const bool allowZero = false); static void arg_int(QString& cmd, const char *const opt, const int val, const bool allowZero = false);
static void arg_bool(QString& cmd, const char *const opt, const bool val); static void arg_bool(QString& cmd, const char *const opt, const bool val);
static void arg_color(QString& cmd, const char *const opt, const QColor val);
static void arg_data(QString& cmd, const char *const opt, const QString& val, const bool win); static void arg_data(QString& cmd, const char *const opt, const QString& val, const bool win);
static void arg_seg(QString& cmd, const int seg_no, const QZintSeg& val, const bool win); static void arg_seg(QString& cmd, const int seg_no, const QZintSeg& val, const bool win);
static void arg_data_esc(QString& cmd, const char *const opt, QString& text, const bool win); static void arg_data_esc(QString& cmd, const char *const opt, QString& text, const bool win);
@ -349,8 +356,8 @@ private:
float m_dot_size; float m_dot_size;
float m_guardDescent; float m_guardDescent;
struct zint_structapp m_structapp; struct zint_structapp m_structapp;
QColor m_fgColor; QString m_fgStr;
QColor m_bgColor; QString m_bgStr;
bool m_cmyk; bool m_cmyk;
int m_borderType; int m_borderType;
int m_borderWidth; int m_borderWidth;

View File

@ -137,13 +137,27 @@ private slots:
QCOMPARE(bc.structAppIndex(), structapp.index); QCOMPARE(bc.structAppIndex(), structapp.index);
QCOMPARE(bc.structAppID(), QString(structapp.id)); QCOMPARE(bc.structAppID(), QString(structapp.id));
QString fgStr("12344567");
bc.setFgStr(fgStr);
QCOMPARE(bc.fgStr(), fgStr);
QColor fgColor(0x12, 0x34, 0x45, 0x67); QColor fgColor(0x12, 0x34, 0x45, 0x67);
bc.setFgColor(fgColor); bc.setFgColor(fgColor);
QCOMPARE(bc.fgColor(), fgColor); QCOMPARE(bc.fgColor(), fgColor);
QCOMPARE(bc.fgStr(), fgStr);
QString bgStr("89ABCDEF");
bc.setBgStr(bgStr);
QCOMPARE(bc.bgStr(), bgStr);
QColor bgColor(0x89, 0xAB, 0xCD, 0xEF); QColor bgColor(0x89, 0xAB, 0xCD, 0xEF);
bc.setBgColor(bgColor); bc.setBgColor(bgColor);
QCOMPARE(bc.bgColor(), bgColor); QCOMPARE(bc.bgColor(), bgColor);
QCOMPARE(bc.bgStr(), bgStr);
QString bgStr2("71,0,40,44");
bc.setBgStr(bgStr2);
QCOMPARE(bc.bgStr(), bgStr2);
bool cmyk = true; bool cmyk = true;
bc.setCMYK(cmyk); bc.setCMYK(cmyk);
@ -500,8 +514,10 @@ private slots:
QTest::addColumn<int>("symbology"); QTest::addColumn<int>("symbology");
QTest::addColumn<int>("inputMode"); QTest::addColumn<int>("inputMode");
QTest::addColumn<QString>("text"); QTest::addColumn<QString>("text");
QTest::addColumn<QString>("primary"); QTest::addColumn<QString>("primary");
QTest::addColumn<float>("height"); QTest::addColumn<float>("height");
QTest::addColumn<int>("option1"); QTest::addColumn<int>("option1");
QTest::addColumn<int>("option2"); QTest::addColumn<int>("option2");
@ -510,24 +526,31 @@ private slots:
QTest::addColumn<float>("dpmm"); QTest::addColumn<float>("dpmm");
QTest::addColumn<bool>("dotty"); QTest::addColumn<bool>("dotty");
QTest::addColumn<float>("dotSize"); QTest::addColumn<float>("dotSize");
QTest::addColumn<float>("guardDescent"); QTest::addColumn<float>("guardDescent");
QTest::addColumn<int>("structAppCount"); QTest::addColumn<int>("structAppCount");
QTest::addColumn<int>("structAppIndex"); QTest::addColumn<int>("structAppIndex");
QTest::addColumn<QString>("structAppID"); QTest::addColumn<QString>("structAppID");
QTest::addColumn<QString>("fgStr");
QTest::addColumn<QString>("bgStr");
QTest::addColumn<QColor>("fgColor"); QTest::addColumn<QColor>("fgColor");
QTest::addColumn<QColor>("bgColor"); QTest::addColumn<QColor>("bgColor");
QTest::addColumn<bool>("cmyk"); QTest::addColumn<bool>("cmyk");
QTest::addColumn<int>("borderTypeIndex"); QTest::addColumn<int>("borderTypeIndex");
QTest::addColumn<int>("borderWidth"); QTest::addColumn<int>("borderWidth");
QTest::addColumn<int>("whitespace"); QTest::addColumn<int>("whitespace");
QTest::addColumn<int>("vWhitespace"); QTest::addColumn<int>("vWhitespace");
QTest::addColumn<int>("fontSetting"); QTest::addColumn<int>("fontSetting");
QTest::addColumn<bool>("showText"); QTest::addColumn<bool>("showText");
QTest::addColumn<bool>("gsSep"); QTest::addColumn<bool>("gsSep");
QTest::addColumn<bool>("quietZones"); QTest::addColumn<bool>("quietZones");
QTest::addColumn<bool>("noQuietZones"); QTest::addColumn<bool>("noQuietZones");
QTest::addColumn<bool>("compliantHeight"); QTest::addColumn<bool>("compliantHeight");
QTest::addColumn<int>("rotateAngle"); QTest::addColumn<int>("rotateAngle");
QTest::addColumn<int>("eci"); QTest::addColumn<int>("eci");
QTest::addColumn<bool>("gs1Parens"); QTest::addColumn<bool>("gs1Parens");
QTest::addColumn<bool>("gs1NoCheck"); QTest::addColumn<bool>("gs1NoCheck");
@ -553,8 +576,9 @@ private slots:
<< BARCODE_AUSPOST << DATA_MODE // symbology-inputMode << BARCODE_AUSPOST << DATA_MODE // symbology-inputMode
<< "12345678" << "" // text-primary << "12345678" << "" // text-primary
<< 30.0f << -1 << 0 << 0 << 1.0f << 0.0f << false << 0.8f // height-dotSize << 30.0f << -1 << 0 << 0 << 1.0f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor << 5.0f << 0 << 0 << "" // guardDescent-structAppID
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
<< 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle << true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug << 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
@ -569,8 +593,9 @@ private slots:
<< BARCODE_AZTEC << UNICODE_MODE // symbology-inputMode << BARCODE_AZTEC << UNICODE_MODE // symbology-inputMode
<< "12345678Ж0%var%" << "" // text-primary << "12345678Ж0%var%" << "" // text-primary
<< 0.0f << 1 << 0 << 0 << 4.0f << 0.0f << true << 0.9f // height-dotSize << 0.0f << 1 << 0 << 0 << 4.0f << 0.0f << true << 0.9f // height-dotSize
<< 5.0f << 2 << 1 << "as\"dfa'sdf" << QColor(Qt::blue) << QColor(Qt::white) // guardDescent-bgColor << 5.0f << 2 << 1 << "as\"dfa'sdf" // guardDescent-structAppID
<< true << 0 << 0 << 2 << 3 << 0 // cmyk-fontSetting << "" << "" << QColor(Qt::blue) << QColor(Qt::white) << true // fgStr-cmyk
<< 0 << 0 << 2 << 3 << 0 // borderTypeIndex-fontSetting
<< true << false << false << false << false << 0 // showText-rotateAngle << true << false << false << false << false << 0 // showText-rotateAngle
<< 7 << false << false << false << WARN_DEFAULT << false // eci-debug << 7 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
@ -580,12 +605,29 @@ private slots:
" --secure=1 --structapp=\"1,2,as\\\"dfa'sdf\" --vwhitesp=3 -w 2" " --secure=1 --structapp=\"1,2,as\\\"dfa'sdf\" --vwhitesp=3 -w 2"
<< "" << "" << "" << ""; << "" << "" << "" << "";
QTest::newRow("BARCODE_AZTEC") << false << 0.0f << ""
<< BARCODE_AZTEC << UNICODE_MODE // symbology-inputMode
<< "12345678Ж0%var%" << "" // text-primary
<< 0.0f << 1 << 0 << 0 << 4.0f << 0.0f << true << 0.9f // height-dotSize
<< 5.0f << 2 << 1 << "as\"dfa'sdf" // guardDescent-structAppID
<< "71,0,40,44" << "0,0,0,0" << QColor(Qt::black) << QColor(Qt::white) << true // fgStr-cmyk
<< 0 << 0 << 2 << 3 << 0 // borderTypeIndex-fontSetting
<< true << false << false << false << false << 0 // showText-rotateAngle
<< 7 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
<< "zint -b 92 --bg=0,0,0,0 --cmyk --eci=7 -d '12345678Ж0%var%' --dotsize=0.9 --dotty --fg=71,0,40,44 --scale=4"
" --secure=1 --structapp='1,2,as\"dfa'\\''sdf' --vwhitesp=3 -w 2"
<< "zint.exe -b 92 --bg=0,0,0,0 --cmyk --eci=7 -d \"12345678Ж0%var%\" --dotsize=0.9 --dotty --fg=71,0,40,44 --scale=4"
" --secure=1 --structapp=\"1,2,as\\\"dfa'sdf\" --vwhitesp=3 -w 2"
<< "" << "" << "" << "";
QTest::newRow("BARCODE_C25INTER") << true << 0.0f << "" QTest::newRow("BARCODE_C25INTER") << true << 0.0f << ""
<< BARCODE_C25INTER << UNICODE_MODE // symbology-inputMode << BARCODE_C25INTER << UNICODE_MODE // symbology-inputMode
<< "12345" << "" // text-primary << "12345" << "" // text-primary
<< 0.0f << -1 << 2 << 0 << 1.0f << 0.0f << false << 0.8f // height-dotSize << 0.0f << -1 << 2 << 0 << 1.0f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor << 5.0f << 0 << 0 << "" // guardDescent-structAppID
<< false << 0 << 0 << 0 << 0 << SMALL_TEXT // cmyk-fontSetting << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
<< 0 << 0 << 0 << 0 << SMALL_TEXT // borderTypeIndex-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle << true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug << 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
@ -597,8 +639,41 @@ private slots:
<< BARCODE_CHANNEL << UNICODE_MODE // symbology-inputMode << BARCODE_CHANNEL << UNICODE_MODE // symbology-inputMode
<< "453678" << "" // text-primary << "453678" << "" // text-primary
<< 19.7f << -1 << 7 << 0 << 1.0f << 0.0f << false << 0.8f // height-dotSize << 19.7f << -1 << 7 << 0 << 1.0f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(255, 255, 255, 0) // guardDescent-bgColor << 5.0f << 0 << 0 << "" // guardDescent-structAppID
<< false << 1 << 2 << 0 << 0 << BOLD_TEXT // cmyk-fontSetting << "" << "" << QColor(Qt::black) << QColor(255, 255, 255, 0) << false // fgStr-cmyk
<< 1 << 2 << 0 << 0 << BOLD_TEXT // borderTypeIndex-fontSetting
<< true << false << true << false << false << 90 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << true // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
<< "zint -b 140 --bind --bold --border=2 -d '453678' --height=19.7 --nobackground --quietzones"
" --rotate=90 --verbose --vers=7"
<< "zint.exe -b 140 --bind --bold --border=2 -d \"453678\" --height=19.7 --nobackground --quietzones"
" --rotate=90 --verbose --vers=7"
<< "" << "" << "" << "";
QTest::newRow("BARCODE_CHANNEL") << false << 0.0f << ""
<< BARCODE_CHANNEL << UNICODE_MODE // symbology-inputMode
<< "453678" << "" // text-primary
<< 19.7f << -1 << 7 << 0 << 1.0f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" // guardDescent-structAppID
<< "" << "FFFFFF00" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
<< 1 << 2 << 0 << 0 << BOLD_TEXT // borderTypeIndex-fontSetting
<< true << false << true << false << false << 90 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << true // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
<< "zint -b 140 --bind --bold --border=2 -d '453678' --height=19.7 --nobackground --quietzones"
" --rotate=90 --verbose --vers=7"
<< "zint.exe -b 140 --bind --bold --border=2 -d \"453678\" --height=19.7 --nobackground --quietzones"
" --rotate=90 --verbose --vers=7"
<< "" << "" << "" << "";
QTest::newRow("BARCODE_CHANNEL") << false << 0.0f << ""
<< BARCODE_CHANNEL << UNICODE_MODE // symbology-inputMode
<< "453678" << "" // text-primary
<< 19.7f << -1 << 7 << 0 << 1.0f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" // guardDescent-structAppID
<< "" << "12345600" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
<< 1 << 2 << 0 << 0 << BOLD_TEXT // borderTypeIndex-fontSetting
<< true << false << true << false << false << 90 // showText-rotateAngle << true << false << true << false << false << 90 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << true // eci-debug << 0 << false << false << false << WARN_DEFAULT << true // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
@ -612,8 +687,9 @@ private slots:
<< BARCODE_CODE128 << (UNICODE_MODE | EXTRA_ESCAPE_MODE) // symbology-inputMode << BARCODE_CODE128 << (UNICODE_MODE | EXTRA_ESCAPE_MODE) // symbology-inputMode
<< "1234\\^A56" << "" // text-primary << "1234\\^A56" << "" // text-primary
<< 0.0f << -1 << 0 << 0 << 1.0f << 0.0f << false << 0.8f // height-dotSize << 0.0f << -1 << 0 << 0 << 1.0f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor << 5.0f << 0 << 0 << "" // guardDescent-structAppID
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
<< 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
<< false << false << true << false << true << 0 // showText-rotateAngle << false << false << true << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug << 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
@ -625,8 +701,9 @@ private slots:
<< BARCODE_GS1_128_CC << UNICODE_MODE // symbology-inputMode << BARCODE_GS1_128_CC << UNICODE_MODE // symbology-inputMode
<< "[01]12345678901231[15]121212" << "[11]901222[99]ABCDE" // text-primary << "[01]12345678901231[15]121212" << "[11]901222[99]ABCDE" // text-primary
<< 71.142f << 3 << 0 << 0 << 3.5f << 0.0f << false << 0.8f // height-dotSize << 71.142f << 3 << 0 << 0 << 3.5f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor << 5.0f << 0 << 0 << "" // guardDescent-structAppID
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
<< 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
<< false << false << true << false << true << 0 // showText-rotateAngle << false << false << true << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug << 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
@ -640,8 +717,9 @@ private slots:
<< BARCODE_CODE16K << (UNICODE_MODE | HEIGHTPERROW_MODE) // symbology-inputMode << BARCODE_CODE16K << (UNICODE_MODE | HEIGHTPERROW_MODE) // symbology-inputMode
<< "12345678901234567890123456789012" << "" // text-primary << "12345678901234567890123456789012" << "" // text-primary
<< 0.0f << 4 << 0 << 2 << 1.0f << 0.0f << false << 0.8f // height-dotSize << 0.0f << 4 << 0 << 2 << 1.0f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor << 5.0f << 0 << 0 << "" // guardDescent-structAppID
<< false << 1 << 1 << 0 << 0 << SMALL_TEXT // cmyk-fontSetting << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
<< 1 << 1 << 0 << 0 << SMALL_TEXT // borderTypeIndex-fontSetting
<< true << false << false << true << true << 0 // showText-rotateAngle << true << false << false << true << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug << 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
@ -655,8 +733,9 @@ private slots:
<< BARCODE_CODE49 << UNICODE_MODE // symbology-inputMode << BARCODE_CODE49 << UNICODE_MODE // symbology-inputMode
<< "12345678901234567890" << "" // text-primary << "12345678901234567890" << "" // text-primary
<< 30.0f << -1 << 0 << 0 << 1.0f << 0.0f << false << 0.8f // height-dotSize << 30.0f << -1 << 0 << 0 << 1.0f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor << 5.0f << 0 << 0 << "" // guardDescent-structAppID
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
<< 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle << true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug << 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
@ -668,8 +747,9 @@ private slots:
<< BARCODE_CODABLOCKF << (DATA_MODE | ESCAPE_MODE) // symbology-inputMode << BARCODE_CODABLOCKF << (DATA_MODE | ESCAPE_MODE) // symbology-inputMode
<< "T\\n\\xA0t\\\"" << "" // text-primary << "T\\n\\xA0t\\\"" << "" // text-primary
<< 0.0f << 2 << 5 << 3 << 3.0f << 0.0f << false << 0.8f // height-dotSize << 0.0f << 2 << 5 << 3 << 3.0f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor << 5.0f << 0 << 0 << "" // guardDescent-structAppID
<< false << 2 << 4 << 0 << 0 << 0 // cmyk-fontSetting << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
<< 2 << 4 << 0 << 0 << 0 // borderTypeIndex-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle << true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << true << WARN_DEFAULT << false // eci-debug << 0 << false << false << true << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
@ -683,8 +763,9 @@ private slots:
<< BARCODE_DAFT << UNICODE_MODE // symbology-inputMode << BARCODE_DAFT << UNICODE_MODE // symbology-inputMode
<< "daft" << "" // text-primary << "daft" << "" // text-primary
<< 9.2f << -1 << 251 << 0 << 1.0f << 0.0f << false << 0.7f // height-dotSize << 9.2f << -1 << 251 << 0 << 1.0f << 0.0f << false << 0.7f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(0x30, 0x31, 0x32, 0x33) << QColor(0xBF, 0xBE, 0xBD, 0xBC) // guardDescent-bgColor << 5.0f << 0 << 0 << "" // guardDescent-structAppID
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting << "" << "" << QColor(0x30, 0x31, 0x32, 0x33) << QColor(0xBF, 0xBE, 0xBD, 0xBC) << false // fgStr-cmyk
<< 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle << true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug << 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
@ -696,8 +777,9 @@ private slots:
<< BARCODE_DATAMATRIX << GS1_MODE // symbology-inputMode << BARCODE_DATAMATRIX << GS1_MODE // symbology-inputMode
<< "[20]12" << "" // text-primary << "[20]12" << "" // text-primary
<< 0.0f << -1 << 0 << DM_SQUARE << 1.0f << 0.0f << false << 0.7f // height-dotSize << 0.0f << -1 << 0 << DM_SQUARE << 1.0f << 0.0f << false << 0.7f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor << 5.0f << 0 << 0 << "" // guardDescent-structAppID
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
<< 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
<< true << true << false << false << true << 0 // showText-rotateAngle << true << true << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug << 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
@ -709,8 +791,9 @@ private slots:
<< BARCODE_DATAMATRIX << (DATA_MODE | ESCAPE_MODE | FAST_MODE) // symbology-inputMode << BARCODE_DATAMATRIX << (DATA_MODE | ESCAPE_MODE | FAST_MODE) // symbology-inputMode
<< "ABCDEFGH\\x01I" << "" // text-primary << "ABCDEFGH\\x01I" << "" // text-primary
<< 0.0f << -1 << 0 << 0 << 1.0f << 0.0f << false << 0.7f // height-dotSize << 0.0f << -1 << 0 << 0 << 1.0f << 0.0f << false << 0.7f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor << 5.0f << 0 << 0 << "" // guardDescent-structAppID
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
<< 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle << true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug << 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
@ -722,8 +805,9 @@ private slots:
<< BARCODE_DBAR_EXPSTK_CC << (DATA_MODE | HEIGHTPERROW_MODE) // symbology-inputMode << BARCODE_DBAR_EXPSTK_CC << (DATA_MODE | HEIGHTPERROW_MODE) // symbology-inputMode
<< "[91]ABCDEFGHIJKL" << "[11]901222[99]ABCDE" // text-primary << "[91]ABCDEFGHIJKL" << "[11]901222[99]ABCDE" // text-primary
<< 0.0f << -1 << 0 << 2 << 1.0f << 0.0f << true << 0.9f // height-dotSize << 0.0f << -1 << 0 << 2 << 1.0f << 0.0f << true << 0.9f // height-dotSize
<< 3.0f << 2 << 1 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor << 3.0f << 2 << 1 << "" // guardDescent-structAppID
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
<< 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle << true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug << 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
@ -737,8 +821,9 @@ private slots:
<< BARCODE_DOTCODE << GS1_MODE // symbology-inputMode << BARCODE_DOTCODE << GS1_MODE // symbology-inputMode
<< "[20]01" << "" // text-primary << "[20]01" << "" // text-primary
<< 30.0f << -1 << 8 << ((0 + 1) << 8) << 1.0f << 0.0f << false << 0.7f // height-dotSize << 30.0f << -1 << 8 << ((0 + 1) << 8) << 1.0f << 0.0f << false << 0.7f // height-dotSize
<< 0.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor << 0.0f << 0 << 0 << "" // guardDescent-structAppID
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
<< 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle << true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug << 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
@ -750,8 +835,9 @@ private slots:
<< BARCODE_DOTCODE << GS1_MODE // symbology-inputMode << BARCODE_DOTCODE << GS1_MODE // symbology-inputMode
<< "[20]01" << "" // text-primary << "[20]01" << "" // text-primary
<< 30.0f << -1 << 8 << ((0 + 1) << 8) << 1.0f << 0.0f << false << 0.7f // height-dotSize << 30.0f << -1 << 8 << ((0 + 1) << 8) << 1.0f << 0.0f << false << 0.7f // height-dotSize
<< 0.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor << 0.0f << 0 << 0 << "" // guardDescent-structAppID
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
<< 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle << true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug << 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
@ -763,8 +849,9 @@ private slots:
<< BARCODE_DPD << UNICODE_MODE // symbology-inputMode << BARCODE_DPD << UNICODE_MODE // symbology-inputMode
<< "1234567890123456789012345678" << "" // text-primary << "1234567890123456789012345678" << "" // text-primary
<< 0.0f << -1 << 0 << 0 << 4.5f << 24.0f << true << 0.8f // height-dotSize << 0.0f << -1 << 0 << 0 << 4.5f << 24.0f << true << 0.8f // height-dotSize
<< 0.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor << 0.0f << 0 << 0 << "" // guardDescent-structAppID
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
<< 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle << true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug << 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.375 << 0 << 600 << 1 << 0 << 0 // xdimdp << 0.375 << 0 << 600 << 1 << 0 << 0 // xdimdp
@ -777,8 +864,9 @@ private slots:
<< BARCODE_EANX << UNICODE_MODE // symbology-inputMode << BARCODE_EANX << UNICODE_MODE // symbology-inputMode
<< "123456789012+12" << "" // text-primary << "123456789012+12" << "" // text-primary
<< 0.0f << -1 << 8 << 0 << 1.0f << 0.0f << true << 0.8f // height-dotSize << 0.0f << -1 << 8 << 0 << 1.0f << 0.0f << true << 0.8f // height-dotSize
<< 0.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor << 0.0f << 0 << 0 << "" // guardDescent-structAppID
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
<< 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle << true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug << 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
@ -790,8 +878,9 @@ private slots:
<< BARCODE_GRIDMATRIX << UNICODE_MODE // symbology-inputMode << BARCODE_GRIDMATRIX << UNICODE_MODE // symbology-inputMode
<< "Your Data Here!" << "" // text-primary << "Your Data Here!" << "" // text-primary
<< 0.0f << 1 << 5 << 0 << 0.5f << 0.0f << false << 0.8f // height-dotSize << 0.0f << 1 << 5 << 0 << 0.5f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor << 5.0f << 0 << 0 << "" // guardDescent-structAppID
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
<< 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
<< true << false << true << false << true << 270 // showText-rotateAngle << true << false << true << false << true << 270 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug << 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
@ -803,8 +892,9 @@ private slots:
<< BARCODE_HANXIN << (UNICODE_MODE | ESCAPE_MODE) // symbology-inputMode << BARCODE_HANXIN << (UNICODE_MODE | ESCAPE_MODE) // symbology-inputMode
<< "éβÿ啊\\e\"'" << "" // text-primary << "éβÿ啊\\e\"'" << "" // text-primary
<< 30.0f << 2 << 5 << ((0 + 1) << 8) << 1.0f << 0.0f << false << 0.8f // height-dotSize << 30.0f << 2 << 5 << ((0 + 1) << 8) << 1.0f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor << 5.0f << 0 << 0 << "" // guardDescent-structAppID
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
<< 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle << true << false << false << false << true << 0 // showText-rotateAngle
<< 29 << false << false << false << WARN_DEFAULT << false // eci-debug << 29 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
@ -816,8 +906,9 @@ private slots:
<< BARCODE_HIBC_DM << UNICODE_MODE // symbology-inputMode << BARCODE_HIBC_DM << UNICODE_MODE // symbology-inputMode
<< "1234" << "" // text-primary << "1234" << "" // text-primary
<< 0.0f << -1 << 8 << DM_DMRE << 1.0f << 0.0f << false << 0.7f // height-dotSize << 0.0f << -1 << 8 << DM_DMRE << 1.0f << 0.0f << false << 0.7f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor << 5.0f << 0 << 0 << "" // guardDescent-structAppID
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
<< 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
<< true << true << false << false << true << 0 // showText-rotateAngle << true << true << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug << 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
@ -829,8 +920,9 @@ private slots:
<< BARCODE_HIBC_PDF << (DATA_MODE | HEIGHTPERROW_MODE) // symbology-inputMode << BARCODE_HIBC_PDF << (DATA_MODE | HEIGHTPERROW_MODE) // symbology-inputMode
<< "TEXT" << "" // text-primary << "TEXT" << "" // text-primary
<< 3.5f << 3 << 4 << 10 << 10.0f << 0.0f << false << 0.8f // height-dotSize << 3.5f << 3 << 4 << 10 << 10.0f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 2 << 1 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor << 5.0f << 2 << 1 << "" // guardDescent-structAppID
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
<< 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
<< true << false << true << false << true << 0 // showText-rotateAngle << true << false << true << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug << 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
@ -844,8 +936,9 @@ private slots:
<< BARCODE_ITF14 << UNICODE_MODE // symbology-inputMode << BARCODE_ITF14 << UNICODE_MODE // symbology-inputMode
<< "9212320967145" << "" // text-primary << "9212320967145" << "" // text-primary
<< 30.0f << -1 << 0 << 0 << 1.0f << 0.0f << false << 0.8f // height-dotSize << 30.0f << -1 << 0 << 0 << 1.0f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor << 5.0f << 0 << 0 << "" // guardDescent-structAppID
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
<< 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle << true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug << 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
@ -857,8 +950,9 @@ private slots:
<< BARCODE_ITF14 << UNICODE_MODE // symbology-inputMode << BARCODE_ITF14 << UNICODE_MODE // symbology-inputMode
<< "9212320967145" << "" // text-primary << "9212320967145" << "" // text-primary
<< 30.0f << -1 << 0 << 0 << 1.0f << 0.0f << false << 0.8f // height-dotSize << 30.0f << -1 << 0 << 0 << 1.0f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor << 5.0f << 0 << 0 << "" // guardDescent-structAppID
<< false << 0 << 1 << 0 << 0 << 0 // cmyk-fontSetting << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
<< 0 << 1 << 0 << 0 << 0 // borderTypeIndex-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle << true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug << 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
@ -871,8 +965,9 @@ private slots:
<< "152382802840001" << "152382802840001"
<< "1Z00004951\\GUPSN\\G06X610\\G159\\G1234567\\G1/1\\G\\GY\\G1 MAIN ST\\GTOWN\\GNY\\R\\E" // text-primary << "1Z00004951\\GUPSN\\G06X610\\G159\\G1234567\\G1/1\\G\\GY\\G1 MAIN ST\\GTOWN\\GNY\\R\\E" // text-primary
<< 0.0f << -1 << (96 + 1) << 0 << 2.5f << 0.0f << false << 0.8f // height-dotSize << 0.0f << -1 << (96 + 1) << 0 << 2.5f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor << 5.0f << 0 << 0 << "" // guardDescent-structAppID
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
<< 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
<< true << false << true << false << true << 0 // showText-rotateAngle << true << false << true << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug << 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
@ -886,8 +981,9 @@ private slots:
<< BARCODE_MICROQR << UNICODE_MODE // symbology-inputMode << BARCODE_MICROQR << UNICODE_MODE // symbology-inputMode
<< "1234" << "" // text-primary << "1234" << "" // text-primary
<< 30.0f << 2 << 3 << (ZINT_FULL_MULTIBYTE | (3 + 1) << 8) << 1.0f << 0.0f << false << 0.8f // height-dotSize << 30.0f << 2 << 3 << (ZINT_FULL_MULTIBYTE | (3 + 1) << 8) << 1.0f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor << 5.0f << 0 << 0 << "" // guardDescent-structAppID
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
<< 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle << true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug << 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
@ -899,8 +995,9 @@ private slots:
<< BARCODE_QRCODE << GS1_MODE // symbology-inputMode << BARCODE_QRCODE << GS1_MODE // symbology-inputMode
<< "(01)12" << "" // text-primary << "(01)12" << "" // text-primary
<< 0.0f << 1 << 5 << (ZINT_FULL_MULTIBYTE | (0 + 1) << 8) << 1.0f << 0.0f << false << 0.8f // height-dotSize << 0.0f << 1 << 5 << (ZINT_FULL_MULTIBYTE | (0 + 1) << 8) << 1.0f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor << 5.0f << 0 << 0 << "" // guardDescent-structAppID
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
<< 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
<< true << false << true << false << true << 0 // showText-rotateAngle << true << false << true << false << true << 0 // showText-rotateAngle
<< 0 << true << true << false << WARN_DEFAULT << false // eci-debug << 0 << true << true << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
@ -914,8 +1011,9 @@ private slots:
<< BARCODE_RMQR << UNICODE_MODE // symbology-inputMode << BARCODE_RMQR << UNICODE_MODE // symbology-inputMode
<< "" << "" // text-primary << "" << "" // text-primary
<< 30.0f << -1 << 8 << 0 << 1.0f << 0.0f << false << 0.8f // height-dotSize << 30.0f << -1 << 8 << 0 << 1.0f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor << 5.0f << 0 << 0 << "" // guardDescent-structAppID
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
<< 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
<< true << false << false << false << true << 180 // showText-rotateAngle << true << false << false << false << true << 180 // showText-rotateAngle
<< 20 << false << false << false << WARN_DEFAULT << false // eci-debug << 20 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
@ -927,8 +1025,9 @@ private slots:
<< BARCODE_ULTRA << (GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE) // symbology-inputMode << BARCODE_ULTRA << (GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE) // symbology-inputMode
<< "(01)1" << "" // text-primary << "(01)1" << "" // text-primary
<< 0.0f << 6 << 2 << 0 << 1.0f << 0.0f << true << 0.8f // height-dotSize << 0.0f << 6 << 2 << 0 << 1.0f << 0.0f << true << 0.8f // height-dotSize
<< 5.0f << 2 << 1 << "4" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor << 5.0f << 2 << 1 << "4" // guardDescent-structAppID
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
<< 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle << true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug << 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
@ -940,8 +1039,9 @@ private slots:
<< BARCODE_UPCE_CC << UNICODE_MODE // symbology-inputMode << BARCODE_UPCE_CC << UNICODE_MODE // symbology-inputMode
<< "12345670+1234" << "[11]901222[99]ABCDE" // text-primary << "12345670+1234" << "[11]901222[99]ABCDE" // text-primary
<< 0.0f << -1 << 0 << 0 << 1.0f << 0.0f << false << 0.8f // height-dotSize << 0.0f << -1 << 0 << 0 << 1.0f << 0.0f << false << 0.8f // height-dotSize
<< 6.5f << 0 << 0 << "" << QColor(0xEF, 0x29, 0x29) << QColor(Qt::white) // guardDescent-bgColor << 6.5f << 0 << 0 << "" // guardDescent-structAppID
<< false << 0 << 0 << 0 << 0 << (BOLD_TEXT | SMALL_TEXT) // cmyk-fontSetting << "" << "" << QColor(0xEF, 0x29, 0x29) << QColor(Qt::white) << false // fgStr-cmyk
<< 0 << 0 << 0 << 0 << (BOLD_TEXT | SMALL_TEXT) // borderTypeIndex-fontSetting
<< true << false << false << true << true << 0 // showText-rotateAngle << true << false << false << true << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_FAIL_ALL << false // eci-debug << 0 << false << false << false << WARN_FAIL_ALL << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
@ -961,8 +1061,9 @@ private slots:
<< BARCODE_VIN << UNICODE_MODE // symbology-inputMode << BARCODE_VIN << UNICODE_MODE // symbology-inputMode
<< "12345678701234567" << "" // text-primary << "12345678701234567" << "" // text-primary
<< 20.0f << -1 << 1 << 0 << 1.0f << 0.0f << false << 0.8f // height-dotSize << 20.0f << -1 << 1 << 0 << 1.0f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor << 5.0f << 0 << 0 << "" // guardDescent-structAppID
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
<< 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle << true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug << 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
@ -997,6 +1098,8 @@ private slots:
QFETCH(int, structAppCount); QFETCH(int, structAppCount);
QFETCH(int, structAppIndex); QFETCH(int, structAppIndex);
QFETCH(QString, structAppID); QFETCH(QString, structAppID);
QFETCH(QString, fgStr);
QFETCH(QString, bgStr);
QFETCH(QColor, fgColor); QFETCH(QColor, fgColor);
QFETCH(QColor, bgColor); QFETCH(QColor, bgColor);
QFETCH(bool, cmyk); QFETCH(bool, cmyk);
@ -1050,8 +1153,16 @@ private slots:
bc.setDotSize(dotSize); bc.setDotSize(dotSize);
bc.setGuardDescent(guardDescent); bc.setGuardDescent(guardDescent);
bc.setStructApp(structAppCount, structAppIndex, structAppID); bc.setStructApp(structAppCount, structAppIndex, structAppID);
bc.setFgColor(fgColor); if (fgStr.isEmpty()) {
bc.setBgColor(bgColor); bc.setFgColor(fgColor);
} else {
bc.setFgStr(fgStr);
}
if (bgStr.isEmpty()) {
bc.setBgColor(bgColor);
} else {
bc.setBgStr(bgStr);
}
bc.setCMYK(cmyk); bc.setCMYK(cmyk);
bc.setBorderType(borderTypeIndex); bc.setBorderType(borderTypeIndex);
bc.setBorderWidth(borderWidth); bc.setBorderWidth(borderWidth);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 313 KiB

After

Width:  |  Height:  |  Size: 277 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 226 KiB

After

Width:  |  Height:  |  Size: 200 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 274 KiB

After

Width:  |  Height:  |  Size: 244 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 KiB

After

Width:  |  Height:  |  Size: 208 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 256 KiB

After

Width:  |  Height:  |  Size: 256 KiB

View File

@ -330,14 +330,16 @@ Printing Scale" dialog - see [4.9 Adjusting Image Size] for further details.
![Adjusting the Print Size](images/gui_set_printing_scale.png) ![Adjusting the Print Size](images/gui_set_printing_scale.png)
The foreground and background colours can be set either using the text boxes The foreground and background colours can be set either using the text boxes
which accept RRGGBBAA hexadecimal values or by clicking the foreground eye which accept `"RRGGBBAA"` hexadecimal values and `"C,M,Y,K"` decimal percentage
![eye](images/gui_black_eye.png) and background eye values, or by clicking the foreground eye ![eye](images/gui_black_eye.png) and
![eye](images/gui_white_eye.png) buttons which invoke a colour picker. background eye ![eye](images/gui_white_eye.png) buttons which invoke a colour
picker.
![The colour picker tool](images/gui_colour.png) ![The colour picker tool](images/gui_colour.png)
(Note that to change the colours visually, the luminence slider, the long narrow (Note that to change the colours visually, the luminence slider, the long narrow
column on the right, must be adjusted.) column on the right, must be adjusted.) The color picker only deals in RGB(A),
and will overwrite any CMYK values with RGB(A) values once `"OK"` is selected.
Back in the Appearance tab, the colours can be reset to black-on-white using the Back in the Appearance tab, the colours can be reset to black-on-white using the
`"Reset"` button, and exchanged one for the other using the swap `"Reset"` button, and exchanged one for the other using the swap
@ -924,8 +926,10 @@ but white-on-black is allowed by the Aztec Code, Data Matrix, DotCode, Han Xin
Code, Grid Matrix and QR Code symbology specifications. Code, Grid Matrix and QR Code symbology specifications.
For more specific needs the foreground (ink) and background (paper) colours can For more specific needs the foreground (ink) and background (paper) colours can
be specified using the `--fg` and `--bg` options followed by a number in RRGGBB be specified using the `--fg` and `--bg` options followed by a number in
hexadecimal notation (the same system used in HTML). For example the command `"RRGGBB"` hexadecimal notation (the same system used in HTML) or in `"C,M,Y,K"`
decimal percentages format (the latter normally used with the `--cmyk` option -
see below). For example the command
```bash ```bash
zint --fg=00FF00 -d "This Text" zint --fg=00FF00 -d "This Text"
@ -935,9 +939,10 @@ alters the symbol to a bright green.
![`zint -d "This Text" --fg=00FF00`](images/code128_green.svg) ![`zint -d "This Text" --fg=00FF00`](images/code128_green.svg)
Zint also supports RGBA colour information for some output file formats which Zint also supports RGBA colour information for those output file formats which
support alpha channels (currently only PNG, SVG and TIF) in a RRGGBBAA format. support alpha channels (currently only GIF, PCX, PNG, SVG and TIF, with GIF
For example: supporting either a background or foreground alpha but not both) in a
`"RRGGBBAA"` format. For example:
```bash ```bash
zint --fg=00ff0055 -d "This Text" zint --fg=00ff0055 -d "This Text"
@ -946,8 +951,9 @@ zint --fg=00ff0055 -d "This Text"
![`zint -d "This Text" --fg=00FF0055`](images/code128_green_alpha.svg) ![`zint -d "This Text" --fg=00FF0055`](images/code128_green_alpha.svg)
will produce a semi-transparent green foreground with standard (white) will produce a semi-transparent green foreground with standard (white)
background. Note that transparency is handled differently for raster and background. Note that transparency is treated differently by raster and vector
vector files so that... (SVG) output formats, as for vector output the background will "shine through"
a transparent foreground. For instance
```bash ```bash
zint --bg=ff0000 --fg=ffffff00 ... zint --bg=ff0000 --fg=ffffff00 ...
@ -955,8 +961,18 @@ zint --bg=ff0000 --fg=ffffff00 ...
will give different results for PNG and SVG. Experimentation is advised! will give different results for PNG and SVG. Experimentation is advised!
In addition the `--nobackground` option will simply remove the background from In addition the `--nobackground` option will remove the background from all
EMF, EPS, GIF, PNG, SVG and TIF files. output formats except BMP.[^4]
The `--cmyk` option is specific to output in Encapsulated PostScript (EPS) and
TIF, and selects the CMYK colour space. Custom colours should then usually be
given in the comma-separated `"C,M,Y,K"` format, where `C`, `M`, `Y` and `K` are
expressed as decimal percentage values from 0 to 100. RGB values may still be
used, in which case they will be converted formulaically to CMYK approximations.
[^4]: The background is omitted for vector outputs EMF, EPS and SVG when
`--nobackground` is given. For raster outputs GIF, PCX, PNG and TIF, the
background's alpha channel is set to zero (fully transparent).
## 4.8 Rotating the Symbol ## 4.8 Rotating the Symbol
@ -1091,7 +1107,7 @@ Grid Matrix GB 2312 (includes ASCII) N/A
Han Xin Latin-1 GB 18030 (includes ASCII) Han Xin Latin-1 GB 18030 (includes ASCII)
MaxiCode Latin-1 None MaxiCode Latin-1 None
MicroPDF417 Latin-1 None MicroPDF417 Latin-1 None
Micro QR Code Latin-1 Shift JIS (includes ASCII[^4]) Micro QR Code Latin-1 Shift JIS (includes ASCII[^5])
PDF417 Latin-1 None PDF417 Latin-1 None
QR Code Latin-1 Shift JIS (see above) QR Code Latin-1 Shift JIS (see above)
rMQR Latin-1 Shift JIS (see above) rMQR Latin-1 Shift JIS (see above)
@ -1101,7 +1117,7 @@ All others ASCII N/A
Table: {#tbl:default_character_sets tag=": Default Character Sets"} Table: {#tbl:default_character_sets tag=": Default Character Sets"}
[^4]: Shift JIS (JIS X 0201 Roman) re-maps two ASCII characters: backslash (`\`) [^5]: Shift JIS (JIS X 0201 Roman) re-maps two ASCII characters: backslash (`\`)
to the yen sign (¥), and tilde (`~`) to overline (U+203E). to the yen sign (¥), and tilde (`~`) to overline (U+203E).
If Zint encounters characters which can not be encoded using the default If Zint encounters characters which can not be encoded using the default
@ -1196,12 +1212,12 @@ ECI Code Character Encoding Scheme (ISO/IEC 8859 schemes include ASCII)
33 UTF-16LE (Low order byte first) 33 UTF-16LE (Low order byte first)
34 UTF-32BE (High order bytes first) 34 UTF-32BE (High order bytes first)
35 UTF-32LE (Low order bytes first) 35 UTF-32LE (Low order bytes first)
170 ISO/IEC 646 Invariant[^5] 170 ISO/IEC 646 Invariant[^6]
899 8-bit binary data 899 8-bit binary data
Table: {#tbl:eci_codes tag=": ECI Codes"} Table: {#tbl:eci_codes tag=": ECI Codes"}
[^5]: ISO/IEC 646 Invariant is a subset of ASCII with 12 characters undefined: [^6]: ISO/IEC 646 Invariant is a subset of ASCII with 12 characters undefined:
`#`, `$`, `@`, `[`, `\`, `]`, `^`, `` ` ``, `{`, `|`, `}`, `~`. `#`, `$`, `@`, `[`, `\`, `]`, `^`, `` ` ``, `{`, `|`, `}`, `~`.
An ECI value of 0 does not encode any ECI information in the code symbol (unless An ECI value of 0 does not encode any ECI information in the code symbol (unless
@ -1480,10 +1496,6 @@ Zint can output a representation of the symbol data as a set of hexadecimal
values if asked to output to a text file (`"*.txt"`) or if given the option values if asked to output to a text file (`"*.txt"`) or if given the option
`--filetype=txt`. This can be used for test and diagnostic purposes. `--filetype=txt`. This can be used for test and diagnostic purposes.
The `--cmyk` option is specific to output in Encapsulated PostScript and TIF,
and converts the RGB colours used to the CMYK colour space. Setting custom
colours at the command line will still need to be done in RRGGBB format.
Additional options are available which are specific to certain symbologies. Additional options are available which are specific to certain symbologies.
These may, for example, control the amount of error correction data or the These may, for example, control the amount of error correction data or the
size of the symbol. These options are discussed in section [6. Types of size of the symbol. These options are discussed in section [6. Types of
@ -1700,7 +1712,7 @@ struct zint_vector_string *string;
struct zint_vector_circle *circle; struct zint_vector_circle *circle;
prepare_canvas(my_symbol->vector->width, my_symbol->vector->height, prepare_canvas(my_symbol->vector->width, my_symbol->vector->height,
my_symbol->scale, my_symbol->fgcolour, my_symbol->bgcolor, my_symbol->scale, my_symbol->fgcolour, my_symbol->bgcolour,
rotate_angle); rotate_angle);
for (rect = my_symbol->vector->rectangles; rect; rect = rect->next) { for (rect = my_symbol->vector->rectangles; rect; rect = rect->next) {
@ -1739,7 +1751,7 @@ Variable Name Type Meaning Default Value
`height` float Symbol height, excluding Symbol dependent `height` float Symbol height, excluding Symbol dependent
fixed width-to-height fixed width-to-height
symbols.[^6] symbols.[^7]
`scale` float Scale factor for adjusting 1.0 `scale` float Scale factor for adjusting 1.0
size of image. size of image.
@ -1757,15 +1769,17 @@ Variable Name Type Meaning Default Value
`fgcolour` character Foreground (ink) `"000000"` `fgcolour` character Foreground (ink) `"000000"`
string colour as RGB/RGBA string colour as RGB/RGBA
hexadecimal string. Must be hexadecimal string or
6 or 8 characters followed `"C,M,Y,K"` decimal
by a terminating `NUL`. percentages string, with a
terminating `NUL`.
`bgcolour` character Background (paper) `"ffffff"` `bgcolour` character Background (paper) `"ffffff"`
string colour as RGB/RGBA string colour as RGB/RGBA
hexadecimal string. Must be hexadecimal string or
6 or 8 characters followed `"C,M,Y,K"` decimal
by a terminating `NUL`. percentages string, with a
terminating `NUL`.
`fgcolor` pointer Points to fgcolour allowing `fgcolor` pointer Points to fgcolour allowing
alternate spelling. alternate spelling.
@ -1869,7 +1883,7 @@ Variable Name Type Meaning Default Value
Table: API Structure `zint_symbol` {#tbl:api_structure_zint_symbol tag="$ $"} Table: API Structure `zint_symbol` {#tbl:api_structure_zint_symbol tag="$ $"}
[^6]: The `height` value is ignored for Aztec (including HIBC and Aztec Rune), [^7]: The `height` value is ignored for Aztec (including HIBC and Aztec Rune),
Code One, Data Matrix (including HIBC), DotCode, Grid Matrix, Han Xin, MaxiCode, Code One, Data Matrix (including HIBC), DotCode, Grid Matrix, Han Xin, MaxiCode,
QR Code (including HIBC, Micro QR, rMQR and UPNQR), and Ultracode - all of which QR Code (including HIBC, Micro QR, rMQR and UPNQR), and Ultracode - all of which
have a fixed width-to-height ratio (or, in the case of Code One, a fixed have a fixed width-to-height ratio (or, in the case of Code One, a fixed
@ -1894,12 +1908,11 @@ int main(int argc, char **argv)
} }
``` ```
Background removal for EMF, EPS, GIF, PNG, SVG and TIF files can be achieved by Background removal for all outputs except BMP can be achieved by setting the
setting the background alpha to `"00"` where the values for R, G and B will be background alpha to `"00"` where the values for R, G and B will be ignored:
ignored:
```c ```c
strcpy(my_symbol->bgcolour, "55555500"); strcpy(my_symbol->bgcolour, "55555500");
``` ```
## 5.7 Handling Errors ## 5.7 Handling Errors
@ -1998,7 +2011,7 @@ int main(int argc, char **argv)
This code will exit with the appropriate message: This code will exit with the appropriate message:
``` ```
Error 653: Malformed foreground colour 'NONSENSE' (hexadecimal only) Error 691: Malformed foreground RGB colour 'nonsense' (hexadecimal only)
``` ```
To treat all warnings as errors, set `symbol->warn_level` to `WARN_FAIL_ALL`. To treat all warnings as errors, set `symbol->warn_level` to `WARN_FAIL_ALL`.
@ -2033,10 +2046,10 @@ Value Effect
------------------------- ----------------------------------------------------- ------------------------- -----------------------------------------------------
0 No options selected. 0 No options selected.
`BARCODE_BIND_TOP` Boundary bar above the symbol only.[^7] `BARCODE_BIND_TOP` Boundary bar above the symbol only.[^8]
`BARCODE_BIND` Boundary bars above and below the symbol and between `BARCODE_BIND` Boundary bars above and below the symbol and between
rows if stacking multiple symbols.[^8] rows if stacking multiple symbols.[^9]
`BARCODE_BOX` Add a box surrounding the symbol and whitespace. `BARCODE_BOX` Add a box surrounding the symbol and whitespace.
@ -2061,7 +2074,7 @@ Value Effect
separate colour channels (`OUT_BUFFER` only). separate colour channels (`OUT_BUFFER` only).
`BARCODE_QUIET_ZONES` Add compliant quiet zones (additional to any `BARCODE_QUIET_ZONES` Add compliant quiet zones (additional to any
specified whitespace).[^9] specified whitespace).[^10]
`BARCODE_NO_QUIET_ZONES` Disable quiet zones, notably those with defaults. `BARCODE_NO_QUIET_ZONES` Disable quiet zones, notably those with defaults.
@ -2071,13 +2084,13 @@ Value Effect
Table: API `output_options` Values {#tbl:api_output_options tag="$ $"} Table: API `output_options` Values {#tbl:api_output_options tag="$ $"}
[^7]: The `BARCODE_BIND_TOP` flag is set by default for DPD - see [6.1.10.7 DPD [^8]: The `BARCODE_BIND_TOP` flag is set by default for DPD - see [6.1.10.7 DPD
Code]. Code].
[^8]: The `BARCODE_BIND` flag is always set for Codablock-F, Code 16K and Code [^9]: The `BARCODE_BIND` flag is always set for Codablock-F, Code 16K and Code
49. Special considerations apply to ITF-14 - see [6.1.2.6 ITF-14]. 49. Special considerations apply to ITF-14 - see [6.1.2.6 ITF-14].
[^9]: Codablock-F, Code 16K, Code 49, EAN-2 to EAN-13, ISBN, ITF-14, UPC-A and [^10]: Codablock-F, Code 16K, Code 49, EAN-2 to EAN-13, ISBN, ITF-14, UPC-A and
UPC-E have compliant quiet zones added by default. UPC-E have compliant quiet zones added by default.
\clearpage \clearpage
@ -2831,13 +2844,13 @@ Alphabet No. 1 (ISO/IEC 8859-1)].
![`zint -b CODE128AB -d "130170X178"`](images/code128ab.svg) ![`zint -b CODE128AB -d "130170X178"`](images/code128ab.svg)
It is sometimes advantageous to stop Code 128 from using Code Set C which It is sometimes advantageous to stop Code 128 from using Code Set C which
compresses numerical data. The `BARCODE_CODE128AB`[^10] variant (symbology 60) compresses numerical data. The `BARCODE_CODE128AB`[^11] variant (symbology 60)
suppresses Code Set C in favour of Code Sets A and B. suppresses Code Set C in favour of Code Sets A and B.
Note that the special escapes to manually switch Code Sets mentioned above are Note that the special escapes to manually switch Code Sets mentioned above are
not available for this variant (nor for any other). not available for this variant (nor for any other).
[^10]: `BARCODE_CODE128AB` previously used the name `BARCODE_CODE128B`, which is [^11]: `BARCODE_CODE128AB` previously used the name `BARCODE_CODE128B`, which is
still recognised. still recognised.
#### 6.1.10.3 GS1-128 #### 6.1.10.3 GS1-128

View File

@ -493,13 +493,15 @@ Adjusting Image Size for further details.
[Adjusting the Print Size] [Adjusting the Print Size]
The foreground and background colours can be set either using the text boxes The foreground and background colours can be set either using the text boxes
which accept RRGGBBAA hexadecimal values or by clicking the foreground eye [eye] which accept "RRGGBBAA" hexadecimal values and "C,M,Y,K" decimal percentage
and background eye [eye] buttons which invoke a colour picker. values, or by clicking the foreground eye [eye] and background eye [eye] buttons
which invoke a colour picker.
[The colour picker tool] [The colour picker tool]
(Note that to change the colours visually, the luminence slider, the long narrow (Note that to change the colours visually, the luminence slider, the long narrow
column on the right, must be adjusted.) column on the right, must be adjusted.) The color picker only deals in RGB(A),
and will overwrite any CMYK values with RGB(A) values once "OK" is selected.
Back in the Appearance tab, the colours can be reset to black-on-white using the Back in the Appearance tab, the colours can be reset to black-on-white using the
"Reset" button, and exchanged one for the other using the swap [swap] button "Reset" button, and exchanged one for the other using the swap [swap] button
@ -1032,8 +1034,10 @@ but white-on-black is allowed by the Aztec Code, Data Matrix, DotCode, Han Xin
Code, Grid Matrix and QR Code symbology specifications. Code, Grid Matrix and QR Code symbology specifications.
For more specific needs the foreground (ink) and background (paper) colours can For more specific needs the foreground (ink) and background (paper) colours can
be specified using the --fg and --bg options followed by a number in RRGGBB be specified using the --fg and --bg options followed by a number in "RRGGBB"
hexadecimal notation (the same system used in HTML). For example the command hexadecimal notation (the same system used in HTML) or in "C,M,Y,K" decimal
percentages format (the latter normally used with the --cmyk option - see
below). For example the command
zint --fg=00FF00 -d "This Text" zint --fg=00FF00 -d "This Text"
@ -1041,24 +1045,32 @@ alters the symbol to a bright green.
[zint -d "This Text" --fg=00FF00] [zint -d "This Text" --fg=00FF00]
Zint also supports RGBA colour information for some output file formats which Zint also supports RGBA colour information for those output file formats which
support alpha channels (currently only PNG, SVG and TIF) in a RRGGBBAA format. support alpha channels (currently only GIF, PCX, PNG, SVG and TIF, with GIF
For example: supporting either a background or foreground alpha but not both) in a "RRGGBBAA"
format. For example:
zint --fg=00ff0055 -d "This Text" zint --fg=00ff0055 -d "This Text"
[zint -d "This Text" --fg=00FF0055] [zint -d "This Text" --fg=00FF0055]
will produce a semi-transparent green foreground with standard (white) will produce a semi-transparent green foreground with standard (white)
background. Note that transparency is handled differently for raster and vector background. Note that transparency is treated differently by raster and vector
files so that… (SVG) output formats, as for vector output the background will “shine through” a
transparent foreground. For instance
zint --bg=ff0000 --fg=ffffff00 ... zint --bg=ff0000 --fg=ffffff00 ...
will give different results for PNG and SVG. Experimentation is advised! will give different results for PNG and SVG. Experimentation is advised!
In addition the --nobackground option will simply remove the background from In addition the --nobackground option will remove the background from all output
EMF, EPS, GIF, PNG, SVG and TIF files. formats except BMP.[4]
The --cmyk option is specific to output in Encapsulated PostScript (EPS) and
TIF, and selects the CMYK colour space. Custom colours should then usually be
given in the comma-separated "C,M,Y,K" format, where C, M, Y and K are expressed
as decimal percentage values from 0 to 100. RGB values may still be used, in
which case they will be converted formulaically to CMYK approximations.
4.8 Rotating the Symbol 4.8 Rotating the Symbol
@ -1178,7 +1190,7 @@ Latin-2 (ISO/IEC 8859-2 plus ASCII).
Han Xin Latin-1 GB 18030 (includes ASCII) Han Xin Latin-1 GB 18030 (includes ASCII)
MaxiCode Latin-1 None MaxiCode Latin-1 None
MicroPDF417 Latin-1 None MicroPDF417 Latin-1 None
Micro QR Code Latin-1 Shift JIS (includes ASCII[4]) Micro QR Code Latin-1 Shift JIS (includes ASCII[5])
PDF417 Latin-1 None PDF417 Latin-1 None
QR Code Latin-1 Shift JIS (see above) QR Code Latin-1 Shift JIS (see above)
rMQR Latin-1 Shift JIS (see above) rMQR Latin-1 Shift JIS (see above)
@ -1280,7 +1292,7 @@ formatted. Zint automatically translates the data into the target encoding.
33 UTF-16LE (Low order byte first) 33 UTF-16LE (Low order byte first)
34 UTF-32BE (High order bytes first) 34 UTF-32BE (High order bytes first)
35 UTF-32LE (Low order bytes first) 35 UTF-32LE (Low order bytes first)
170 ISO/IEC 646 Invariant[5] 170 ISO/IEC 646 Invariant[6]
899 8-bit binary data 899 8-bit binary data
: Table : ECI Codes: : Table : ECI Codes:
@ -1537,10 +1549,6 @@ Zint can output a representation of the symbol data as a set of hexadecimal
values if asked to output to a text file ("*.txt") or if given the option values if asked to output to a text file ("*.txt") or if given the option
--filetype=txt. This can be used for test and diagnostic purposes. --filetype=txt. This can be used for test and diagnostic purposes.
The --cmyk option is specific to output in Encapsulated PostScript and TIF, and
converts the RGB colours used to the CMYK colour space. Setting custom colours
at the command line will still need to be done in RRGGBB format.
Additional options are available which are specific to certain symbologies. Additional options are available which are specific to certain symbologies.
These may, for example, control the amount of error correction data or the size These may, for example, control the amount of error correction data or the size
of the symbol. These options are discussed in section 6. Types of Symbology of of the symbol. These options are discussed in section 6. Types of Symbology of
@ -1735,7 +1743,7 @@ routines available:
struct zint_vector_circle *circle; struct zint_vector_circle *circle;
prepare_canvas(my_symbol->vector->width, my_symbol->vector->height, prepare_canvas(my_symbol->vector->width, my_symbol->vector->height,
my_symbol->scale, my_symbol->fgcolour, my_symbol->bgcolor, my_symbol->scale, my_symbol->fgcolour, my_symbol->bgcolour,
rotate_angle); rotate_angle);
for (rect = my_symbol->vector->rectangles; rect; rect = rect->next) { for (rect = my_symbol->vector->rectangles; rect; rect = rect->next) {
@ -1772,7 +1780,7 @@ encoding stages. The zint_symbol structure consists of the following variables:
height float Symbol height, excluding Symbol dependent height float Symbol height, excluding Symbol dependent
fixed width-to-height fixed width-to-height
symbols.[6] symbols.[7]
scale float Scale factor for adjusting 1.0 scale float Scale factor for adjusting 1.0
size of image. size of image.
@ -1789,16 +1797,16 @@ encoding stages. The zint_symbol structure consists of the following variables:
Options). Options).
fgcolour character Foreground (ink) colour as "000000" fgcolour character Foreground (ink) colour as "000000"
string RGB/RGBA hexadecimal string. string RGB/RGBA hexadecimal string
Must be 6 or 8 characters or "C,M,Y,K" decimal
followed by a terminating percentages string, with a
NUL. terminating NUL.
bgcolour character Background (paper) colour as "ffffff" bgcolour character Background (paper) colour as "ffffff"
string RGB/RGBA hexadecimal string. string RGB/RGBA hexadecimal string
Must be 6 or 8 characters or "C,M,Y,K" decimal
followed by a terminating percentages string, with a
NUL. terminating NUL.
fgcolor pointer Points to fgcolour allowing fgcolor pointer Points to fgcolour allowing
alternate spelling. alternate spelling.
@ -1918,11 +1926,10 @@ plotted in green.
return 0; return 0;
} }
Background removal for EMF, EPS, GIF, PNG, SVG and TIF files can be achieved by Background removal for all outputs except BMP can be achieved by setting the
setting the background alpha to "00" where the values for R, G and B will be background alpha to "00" where the values for R, G and B will be ignored:
ignored:
strcpy(my_symbol->bgcolour, "55555500"); strcpy(my_symbol->bgcolour, "55555500");
5.7 Handling Errors 5.7 Handling Errors
@ -2020,7 +2027,7 @@ To catch errors use an integer variable as shown in the code below:
This code will exit with the appropriate message: This code will exit with the appropriate message:
Error 653: Malformed foreground colour 'NONSENSE' (hexadecimal only) Error 691: Malformed foreground RGB colour 'nonsense' (hexadecimal only)
To treat all warnings as errors, set symbol->warn_level to WARN_FAIL_ALL. To treat all warnings as errors, set symbol->warn_level to WARN_FAIL_ALL.
@ -2048,10 +2055,10 @@ together when adjusting this value:
-------------------------- ---------------------------------------------------- -------------------------- ----------------------------------------------------
0 No options selected. 0 No options selected.
BARCODE_BIND_TOP Boundary bar above the symbol only.[7] BARCODE_BIND_TOP Boundary bar above the symbol only.[8]
BARCODE_BIND Boundary bars above and below the symbol and between BARCODE_BIND Boundary bars above and below the symbol and between
rows if stacking multiple symbols.[8] rows if stacking multiple symbols.[9]
BARCODE_BOX Add a box surrounding the symbol and whitespace. BARCODE_BOX Add a box surrounding the symbol and whitespace.
@ -2076,7 +2083,7 @@ together when adjusting this value:
separate colour channels (OUT_BUFFER only). separate colour channels (OUT_BUFFER only).
BARCODE_QUIET_ZONES Add compliant quiet zones (additional to any BARCODE_QUIET_ZONES Add compliant quiet zones (additional to any
specified whitespace).[9] specified whitespace).[10]
BARCODE_NO_QUIET_ZONES Disable quiet zones, notably those with defaults. BARCODE_NO_QUIET_ZONES Disable quiet zones, notably those with defaults.
@ -2777,7 +2784,7 @@ Alphabet No. 1 (ISO/IEC 8859-1).
[zint -b CODE128AB -d "130170X178"] [zint -b CODE128AB -d "130170X178"]
It is sometimes advantageous to stop Code 128 from using Code Set C which It is sometimes advantageous to stop Code 128 from using Code Set C which
compresses numerical data. The BARCODE_CODE128AB[10] variant (symbology 60) compresses numerical data. The BARCODE_CODE128AB[11] variant (symbology 60)
suppresses Code Set C in favour of Code Sets A and B. suppresses Code Set C in favour of Code Sets A and B.
Note that the special escapes to manually switch Code Sets mentioned above are Note that the special escapes to manually switch Code Sets mentioned above are
@ -4428,8 +4435,8 @@ OPTIONS
“00002.png” etc., which can be changed by using the -o | --output option. “00002.png” etc., which can be changed by using the -o | --output option.
--bg=COLOUR --bg=COLOUR
Specify a background (paper) colour where COLOUR is in hex RRGGBB or Specify a background (paper) colour where COLOUR is in hexadecimal RRGGBB or
RRGGBBAA format. RRGGBBAA format or in decimal C,M,Y,K percentages format.
--binary --binary
Treat input data as raw 8-bit binary data instead of the default UTF-8. Treat input data as raw 8-bit binary data instead of the default UTF-8.
@ -4558,8 +4565,8 @@ OPTIONS
--fg=COLOUR --fg=COLOUR
Specify a foreground (ink) colour where COLOUR is in hex RRGGBB or RRGGBBAA Specify a foreground (ink) colour where COLOUR is in hexadecimal RRGGBB or
format. RRGGBBAA format or in decimal C,M,Y,K percentages format.
--filetype=TYPE --filetype=TYPE
@ -4947,25 +4954,29 @@ Not to be confused with the Windows Bitmap file format BMP!
now deprecated but are still recognised by Zint and will continue to be now deprecated but are still recognised by Zint and will continue to be
supported in future versions. supported in future versions.
[4] Shift JIS (JIS X 0201 Roman) re-maps two ASCII characters: backslash (\) to [4] The background is omitted for vector outputs EMF, EPS and SVG when
--nobackground is given. For raster outputs GIF, PCX, PNG and TIF, the
backgrounds alpha channel is set to zero (fully transparent).
[5] Shift JIS (JIS X 0201 Roman) re-maps two ASCII characters: backslash (\) to
the yen sign (¥), and tilde (~) to overline (U+203E). the yen sign (¥), and tilde (~) to overline (U+203E).
[5] ISO/IEC 646 Invariant is a subset of ASCII with 12 characters undefined: #, [6] ISO/IEC 646 Invariant is a subset of ASCII with 12 characters undefined: #,
$, @, [, \, ], ^, `, {, |, }, ~. $, @, [, \, ], ^, `, {, |, }, ~.
[6] The height value is ignored for Aztec (including HIBC and Aztec Rune), Code [7] The height value is ignored for Aztec (including HIBC and Aztec Rune), Code
One, Data Matrix (including HIBC), DotCode, Grid Matrix, Han Xin, MaxiCode, QR One, Data Matrix (including HIBC), DotCode, Grid Matrix, Han Xin, MaxiCode, QR
Code (including HIBC, Micro QR, rMQR and UPNQR), and Ultracode - all of which Code (including HIBC, Micro QR, rMQR and UPNQR), and Ultracode - all of which
have a fixed width-to-height ratio (or, in the case of Code One, a fixed have a fixed width-to-height ratio (or, in the case of Code One, a fixed
height). height).
[7] The BARCODE_BIND_TOP flag is set by default for DPD - see 6.1.10.7 DPD Code. [8] The BARCODE_BIND_TOP flag is set by default for DPD - see 6.1.10.7 DPD Code.
[8] The BARCODE_BIND flag is always set for Codablock-F, Code 16K and Code 49. [9] The BARCODE_BIND flag is always set for Codablock-F, Code 16K and Code 49.
Special considerations apply to ITF-14 - see 6.1.2.6 ITF-14. Special considerations apply to ITF-14 - see 6.1.2.6 ITF-14.
[9] Codablock-F, Code 16K, Code 49, EAN-2 to EAN-13, ISBN, ITF-14, UPC-A and [10] Codablock-F, Code 16K, Code 49, EAN-2 to EAN-13, ISBN, ITF-14, UPC-A and
UPC-E have compliant quiet zones added by default. UPC-E have compliant quiet zones added by default.
[10] BARCODE_CODE128AB previously used the name BARCODE_CODE128B, which is still [11] BARCODE_CODE128AB previously used the name BARCODE_CODE128B, which is still
recognised. recognised.

View File

@ -72,8 +72,9 @@ starting with \[lq]00001.png\[rq], \[lq]00002.png\[rq] etc., which can
be changed by using the \f[V]-o\f[R] | \f[V]--output\f[R] option. be changed by using the \f[V]-o\f[R] | \f[V]--output\f[R] option.
.TP .TP
\f[V]--bg=COLOUR\f[R] \f[V]--bg=COLOUR\f[R]
Specify a background (paper) colour where \f[I]COLOUR\f[R] is in hex Specify a background (paper) colour where \f[I]COLOUR\f[R] is in
\f[V]RRGGBB\f[R] or \f[V]RRGGBBAA\f[R] format. hexadecimal \f[V]RRGGBB\f[R] or \f[V]RRGGBBAA\f[R] format or in decimal
\f[V]C,M,Y,K\f[R] percentages format.
.TP .TP
\f[V]--binary\f[R] \f[V]--binary\f[R]
Treat input data as raw 8-bit binary data instead of the default UTF-8. Treat input data as raw 8-bit binary data instead of the default UTF-8.
@ -211,8 +212,9 @@ Use faster if less optimal encodation or other shortcuts (affects Data
Matrix, MicroPDF417, PDF417, QRCODE & UPNQR only). Matrix, MicroPDF417, PDF417, QRCODE & UPNQR only).
.TP .TP
\f[V]--fg=COLOUR\f[R] \f[V]--fg=COLOUR\f[R]
Specify a foreground (ink) colour where \f[I]COLOUR\f[R] is in hex Specify a foreground (ink) colour where \f[I]COLOUR\f[R] is in
\f[V]RRGGBB\f[R] or \f[V]RRGGBBAA\f[R] format. hexadecimal \f[V]RRGGBB\f[R] or \f[V]RRGGBBAA\f[R] format or in decimal
\f[V]C,M,Y,K\f[R] percentages format.
.TP .TP
\f[V]--filetype=TYPE\f[R] \f[V]--filetype=TYPE\f[R]
Set the output file type to \f[I]TYPE\f[R], which is one of Set the output file type to \f[I]TYPE\f[R], which is one of

View File

@ -44,7 +44,8 @@ Paintbrush (`PCX`), Portable Network Format (`PNG`), Scalable Vector Graphic (`S
"00002.png" etc., which can be changed by using the `-o` | `--output` option. "00002.png" etc., which can be changed by using the `-o` | `--output` option.
`--bg=COLOUR` `--bg=COLOUR`
: Specify a background (paper) colour where *COLOUR* is in hex `RRGGBB` or `RRGGBBAA` format. : Specify a background (paper) colour where *COLOUR* is in hexadecimal `RRGGBB` or `RRGGBBAA` format or in decimal
`C,M,Y,K` percentages format.
`--binary` `--binary`
: Treat input data as raw 8-bit binary data instead of the default UTF-8. Automatic code page translation to an ECI : Treat input data as raw 8-bit binary data instead of the default UTF-8. Automatic code page translation to an ECI
@ -160,7 +161,8 @@ Paintbrush (`PCX`), Portable Network Format (`PNG`), Scalable Vector Graphic (`S
`--fg=COLOUR` `--fg=COLOUR`
: Specify a foreground (ink) colour where *COLOUR* is in hex `RRGGBB` or `RRGGBBAA` format. : Specify a foreground (ink) colour where *COLOUR* is in hexadecimal `RRGGBB` or `RRGGBBAA` format or in decimal
`C,M,Y,K` percentages format.
`--filetype=TYPE` `--filetype=TYPE`

View File

@ -1,7 +1,7 @@
/* main.c - Command line handling routines for Zint */ /* main.c - Command line handling routines for Zint */
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2008-2022 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2008-2023 Robin Stuart <rstuart114@gmail.com>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -146,7 +146,7 @@ static void usage(int no_png) {
fputs( " -b, --barcode=TYPE Number or name of barcode type. Default is 20 (CODE128)\n" fputs( " -b, --barcode=TYPE Number or name of barcode type. Default is 20 (CODE128)\n"
" --addongap=NUMBER Set add-on gap in multiples of X-dimension for EAN/UPC\n" " --addongap=NUMBER Set add-on gap in multiples of X-dimension for EAN/UPC\n"
" --batch Treat each line of input file as a separate data set\n" " --batch Treat each line of input file as a separate data set\n"
" --bg=COLOUR Specify a background colour (in hex RGB/RGBA)\n" " --bg=COLOUR Specify a background colour (as RGB(A) or \"C,M,Y,K\")\n"
" --binary Treat input as raw binary data\n", stdout); " --binary Treat input as raw binary data\n", stdout);
fputs( " --bind Add boundary bars\n" fputs( " --bind Add boundary bars\n"
" --bindtop Add top boundary bar only\n" " --bindtop Add top boundary bar only\n"
@ -167,7 +167,7 @@ static void usage(int no_png) {
" --esc Process escape sequences in input data\n" " --esc Process escape sequences in input data\n"
" --extraesc Process symbology-specific escape sequences (Code 128)\n" " --extraesc Process symbology-specific escape sequences (Code 128)\n"
" --fast Use faster encodation or other shortcuts if available\n" " --fast Use faster encodation or other shortcuts if available\n"
" --fg=COLOUR Specify a foreground colour (in hex RGB/RGBA)\n", stdout); " --fg=COLOUR Specify a foreground colour (as RGB(A) or \"C,M,Y,K\")\n", stdout);
printf(" --filetype=TYPE Set output file type BMP/EMF/EPS/GIF/PCX%s/SVG/TIF/TXT\n", no_png_type); printf(" --filetype=TYPE Set output file type BMP/EMF/EPS/GIF/PCX%s/SVG/TIF/TXT\n", no_png_type);
fputs( " --fullmultibyte Use multibyte for binary/Latin (QR/Han Xin/Grid Matrix)\n" fputs( " --fullmultibyte Use multibyte for binary/Latin (QR/Han Xin/Grid Matrix)\n"
" --gs1 Treat input as GS1 compatible data\n" " --gs1 Treat input as GS1 compatible data\n"
@ -863,7 +863,7 @@ static int batch_process(struct zint_symbol *symbol, const char *filename, const
if (mirror_start_o > 221) { /* Insist on leaving at least ~30 chars for filename */ if (mirror_start_o > 221) { /* Insist on leaving at least ~30 chars for filename */
fprintf(stderr, "Warning 188: directory for mirrored batch output too long (> 220), ignored\n"); fprintf(stderr, "Warning 188: directory for mirrored batch output too long (> 220), ignored\n");
fflush(stderr); fflush(stderr);
warn_number = ZINT_WARN_INVALID_OPTION; /* TODO: maybe new warning e.g. ZINT_WARN_INVALID_INPUT? */ warn_number = ZINT_WARN_INVALID_OPTION; /* TODO: maybe new warning ZINT_WARN_INVALID_INPUT? */
mirror_start_o = 0; mirror_start_o = 0;
} else { } else {
memcpy(output_file, symbol->outfile, mirror_start_o); memcpy(output_file, symbol->outfile, mirror_start_o);
@ -1201,6 +1201,8 @@ int main(int argc, char **argv) {
{"batch", 0, NULL, OPT_BATCH}, {"batch", 0, NULL, OPT_BATCH},
{"binary", 0, NULL, OPT_BINARY}, {"binary", 0, NULL, OPT_BINARY},
{"bg", 1, 0, OPT_BG}, {"bg", 1, 0, OPT_BG},
{"bgcolor", 1, 0, OPT_BG}, /* Synonym */
{"bgcolour", 1, 0, OPT_BG}, /* Synonym */
{"bind", 0, NULL, OPT_BIND}, {"bind", 0, NULL, OPT_BIND},
{"bindtop", 0, NULL, OPT_BIND_TOP}, {"bindtop", 0, NULL, OPT_BIND_TOP},
{"bold", 0, NULL, OPT_BOLD}, {"bold", 0, NULL, OPT_BOLD},
@ -1221,6 +1223,8 @@ int main(int argc, char **argv) {
{"extraesc", 0, NULL, OPT_EXTRAESC}, {"extraesc", 0, NULL, OPT_EXTRAESC},
{"fast", 0, NULL, OPT_FAST}, {"fast", 0, NULL, OPT_FAST},
{"fg", 1, 0, OPT_FG}, {"fg", 1, 0, OPT_FG},
{"fgcolor", 1, 0, OPT_FG}, /* Synonym */
{"fgcolour", 1, 0, OPT_FG}, /* Synonym */
{"filetype", 1, NULL, OPT_FILETYPE}, {"filetype", 1, NULL, OPT_FILETYPE},
{"fontsize", 1, NULL, OPT_FONTSIZE}, {"fontsize", 1, NULL, OPT_FONTSIZE},
{"fullmultibyte", 0, NULL, OPT_FULLMULTIBYTE}, {"fullmultibyte", 0, NULL, OPT_FULLMULTIBYTE},
@ -1300,7 +1304,7 @@ int main(int argc, char **argv) {
} }
break; break;
case OPT_BG: case OPT_BG:
strncpy(my_symbol->bgcolour, optarg, 9); strncpy(my_symbol->bgcolour, optarg, 15); /* Allow for "CCC,MMM,YYY,KKK" */
break; break;
case OPT_BINARY: case OPT_BINARY:
my_symbol->input_mode = (my_symbol->input_mode & ~0x07) | DATA_MODE; my_symbol->input_mode = (my_symbol->input_mode & ~0x07) | DATA_MODE;
@ -1401,7 +1405,7 @@ int main(int argc, char **argv) {
my_symbol->input_mode |= FAST_MODE; my_symbol->input_mode |= FAST_MODE;
break; break;
case OPT_FG: case OPT_FG:
strncpy(my_symbol->fgcolour, optarg, 9); strncpy(my_symbol->fgcolour, optarg, 15); /* Allow for "CCC,MMM,YYY,KKK" */
break; break;
case OPT_FILETYPE: case OPT_FILETYPE:
/* Select the type of output file */ /* Select the type of output file */

View File

@ -1150,62 +1150,67 @@ static void test_other_opts(const testCtx *const p_ctx) {
/* 0*/ { BARCODE_CODE128, "1", -1, " --bg=", "EF9900", "", 0 }, /* 0*/ { BARCODE_CODE128, "1", -1, " --bg=", "EF9900", "", 0 },
/* 1*/ { BARCODE_CODE128, "1", -1, " -bg=", "EF9900", "", 0 }, /* 1*/ { BARCODE_CODE128, "1", -1, " -bg=", "EF9900", "", 0 },
/* 2*/ { BARCODE_CODE128, "1", -1, " --bg=", "EF9900AA", "", 0 }, /* 2*/ { BARCODE_CODE128, "1", -1, " --bg=", "EF9900AA", "", 0 },
/* 3*/ { BARCODE_CODE128, "1", -1, " --bg=", "GF9900", "Error 654: Malformed background colour 'GF9900' (hexadecimal only)", 0 }, /* 3*/ { BARCODE_CODE128, "1", -1, " --bg=", "GF9900", "Error 691: Malformed background RGB colour 'GF9900' (hexadecimal only)", 0 },
/* 4*/ { BARCODE_CODE128, "1", -1, " --fg=", "000000", "", 0 }, /* 4*/ { BARCODE_CODE128, "1", -1, " --bgcolor=", "EF9900", "", 0 },
/* 5*/ { BARCODE_CODE128, "1", -1, " --fg=", "00000000", "", 0 }, /* 5*/ { BARCODE_CODE128, "1", -1, " --bgcolour=", "EF9900", "", 0 },
/* 6*/ { BARCODE_CODE128, "1", -1, " --fg=", "000000F", "Error 651: Malformed foreground colour (6 or 8 characters only)", 0 }, /* 6*/ { BARCODE_CODE128, "1", -1, " --fg=", "000000", "", 0 },
/* 7*/ { BARCODE_CODE128, "1", -1, " --fg=", "000000FG", "Error 653: Malformed foreground colour '000000FG' (hexadecimal only)", 0 }, /* 7*/ { BARCODE_CODE128, "1", -1, " --fg=", "00000000", "", 0 },
/* 8*/ { BARCODE_CODE128, "1", -1, " --compliantheight", "", "", 0 }, /* 8*/ { BARCODE_CODE128, "1", -1, " --fg=", "000000F", "Error 690: Malformed foreground RGB colour (6 or 8 characters only)", 0 },
/* 9*/ { BARCODE_CODE128, "1", -1, " --fontsize=", "10", "", 0 }, /* 9*/ { BARCODE_CODE128, "1", -1, " --fg=", "000000FG", "Error 691: Malformed foreground RGB colour '000000FG' (hexadecimal only)", 0 },
/* 10*/ { BARCODE_CODE128, "1", -1, " --fontsize=", "101", "Warning 126: Font size out of range (0 to 100), ignoring", 0 }, /* 10*/ { BARCODE_CODE128, "1", -1, " --fg=", "0,0,0,100", "", 0 },
/* 11*/ { BARCODE_CODE128, "1", -1, " --nobackground", "", "", 0 }, /* 11*/ { BARCODE_CODE128, "1", -1, " --fgcolor=", "111111", "", 0 },
/* 12*/ { BARCODE_CODE128, "1", -1, " --noquietzones", "", "", 0 }, /* 12*/ { BARCODE_CODE128, "1", -1, " --fgcolour=", "111111", "", 0 },
/* 13*/ { BARCODE_CODE128, "1", -1, " --notext", "", "", 0 }, /* 13*/ { BARCODE_CODE128, "1", -1, " --compliantheight", "", "", 0 },
/* 14*/ { BARCODE_CODE128, "1", -1, " --quietzones", "", "", 0 }, /* 14*/ { BARCODE_CODE128, "1", -1, " --fontsize=", "10", "", 0 },
/* 15*/ { BARCODE_CODE128, "1", -1, " --reverse", "", "", 0 }, /* 15*/ { BARCODE_CODE128, "1", -1, " --fontsize=", "101", "Warning 126: Font size out of range (0 to 100), ignoring", 0 },
/* 16*/ { BARCODE_CODE128, "1", -1, " --werror", NULL, "", 0 }, /* 16*/ { BARCODE_CODE128, "1", -1, " --nobackground", "", "", 0 },
/* 17*/ { 19, "1", -1, " --werror", NULL, "Error 207: Codabar 18 not supported", 0 }, /* 17*/ { BARCODE_CODE128, "1", -1, " --noquietzones", "", "", 0 },
/* 18*/ { BARCODE_GS1_128, "[01]12345678901231", -1, "", NULL, "", 0 }, /* 18*/ { BARCODE_CODE128, "1", -1, " --notext", "", "", 0 },
/* 19*/ { BARCODE_GS1_128, "0112345678901231", -1, "", NULL, "Error 252: Data does not start with an AI", 0 }, /* 19*/ { BARCODE_CODE128, "1", -1, " --quietzones", "", "", 0 },
/* 20*/ { BARCODE_GS1_128, "0112345678901231", -1, " --gs1nocheck", NULL, "Error 252: Data does not start with an AI", 0 }, /* 20*/ { BARCODE_CODE128, "1", -1, " --reverse", "", "", 0 },
/* 21*/ { BARCODE_GS1_128, "[00]376104250021234569", -1, "", NULL, "", 0 }, /* 21*/ { BARCODE_CODE128, "1", -1, " --werror", NULL, "", 0 },
/* 22*/ { BARCODE_GS1_128, "[00]376104250021234568", -1, "", NULL, "Warning 261: AI (00) position 18: Bad checksum '8', expected '9'", 0 }, /* 22*/ { 19, "1", -1, " --werror", NULL, "Error 207: Codabar 18 not supported", 0 },
/* 23*/ { BARCODE_GS1_128, "[00]376104250021234568", -1, " --gs1nocheck", NULL, "", 0 }, /* 23*/ { BARCODE_GS1_128, "[01]12345678901231", -1, "", NULL, "", 0 },
/* 24*/ { BARCODE_GS1_128, "[00]376104250021234568", -1, " --werror", NULL, "Error 261: AI (00) position 18: Bad checksum '8', expected '9'", 0 }, /* 24*/ { BARCODE_GS1_128, "0112345678901231", -1, "", NULL, "Error 252: Data does not start with an AI", 0 },
/* 25*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "1", "Error 155: Invalid Structured Append argument, expect \"index,count[,ID]\"", 0 }, /* 25*/ { BARCODE_GS1_128, "0112345678901231", -1, " --gs1nocheck", NULL, "Error 252: Data does not start with an AI", 0 },
/* 26*/ { BARCODE_AZTEC, "1", -1, " --structapp=", ",", "Error 156: Structured Append index too short", 0 }, /* 26*/ { BARCODE_GS1_128, "[00]376104250021234569", -1, "", NULL, "", 0 },
/* 27*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "1234567890,", "Error 156: Structured Append index too long", 0 }, /* 27*/ { BARCODE_GS1_128, "[00]376104250021234568", -1, "", NULL, "Warning 261: AI (00) position 18: Bad checksum '8', expected '9'", 0 },
/* 28*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "123456789,", "Error 159: Structured Append count too short", 0 }, /* 28*/ { BARCODE_GS1_128, "[00]376104250021234568", -1, " --gs1nocheck", NULL, "", 0 },
/* 29*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "123456789,1234567890", "Error 159: Structured Append count too long", 0 }, /* 29*/ { BARCODE_GS1_128, "[00]376104250021234568", -1, " --werror", NULL, "Error 261: AI (00) position 18: Bad checksum '8', expected '9'", 0 },
/* 30*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "123456789,123456789,", "Error 158: Structured Append ID too short", 0 }, /* 30*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "1", "Error 155: Invalid Structured Append argument, expect \"index,count[,ID]\"", 0 },
/* 31*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "123456789,1234567890,", "Error 157: Structured Append count too long", 0 }, /* 31*/ { BARCODE_AZTEC, "1", -1, " --structapp=", ",", "Error 156: Structured Append index too short", 0 },
/* 32*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "123456789,123456789,123456789012345678901234567890123", "Error 158: Structured Append ID too long", 0 }, /* 32*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "1234567890,", "Error 156: Structured Append index too long", 0 },
/* 33*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "123456789,123456789,12345678901234567890123456789012", "Error 701: Structured Append count out of range (2-26)", 0 }, /* 33*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "123456789,", "Error 159: Structured Append count too short", 0 },
/* 34*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "26,26,12345678901234567890123456789012", "", 0 }, /* 34*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "123456789,1234567890", "Error 159: Structured Append count too long", 0 },
/* 35*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "A,26,12345678901234567890123456789012", "Error 160: Invalid Structured Append index (digits only)", 0 }, /* 35*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "123456789,123456789,", "Error 158: Structured Append ID too short", 0 },
/* 36*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "26,A,12345678901234567890123456789012", "Error 161: Invalid Structured Append count (digits only)", 0 }, /* 36*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "123456789,1234567890,", "Error 157: Structured Append count too long", 0 },
/* 37*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "26,1,12345678901234567890123456789012", "Error 162: Invalid Structured Append count, must be >= 2", 0 }, /* 37*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "123456789,123456789,123456789012345678901234567890123", "Error 158: Structured Append ID too long", 0 },
/* 38*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "0,2,12345678901234567890123456789012", "Error 163: Structured Append index out of range (1-2)", 0 }, /* 38*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "123456789,123456789,12345678901234567890123456789012", "Error 701: Structured Append count out of range (2-26)", 0 },
/* 39*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "3,2,12345678901234567890123456789012", "Error 163: Structured Append index out of range (1-2)", 0 }, /* 39*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "26,26,12345678901234567890123456789012", "", 0 },
/* 40*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "2,3,12345678901234567890123456789012", "", 0 }, /* 40*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "A,26,12345678901234567890123456789012", "Error 160: Invalid Structured Append index (digits only)", 0 },
/* 41*/ { BARCODE_PDF417, "1", -1, " --heightperrow", "", "", 0 }, /* 41*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "26,A,12345678901234567890123456789012", "Error 161: Invalid Structured Append count (digits only)", 0 },
/* 42*/ { -1, NULL, -1, " -v", NULL, "Zint version ", 1 }, /* 42*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "26,1,12345678901234567890123456789012", "Error 162: Invalid Structured Append count, must be >= 2", 0 },
/* 43*/ { -1, NULL, -1, " --version", NULL, "Zint version ", 1 }, /* 43*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "0,2,12345678901234567890123456789012", "Error 163: Structured Append index out of range (1-2)", 0 },
/* 44*/ { -1, NULL, -1, " -h", NULL, "Encode input data in a barcode ", 1 }, /* 44*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "3,2,12345678901234567890123456789012", "Error 163: Structured Append index out of range (1-2)", 0 },
/* 45*/ { -1, NULL, -1, " -e", NULL, "3: ISO/IEC 8859-1 ", 1 }, /* 45*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "2,3,12345678901234567890123456789012", "", 0 },
/* 46*/ { -1, NULL, -1, " -t", NULL, "1 CODE11 ", 1 }, /* 46*/ { BARCODE_PDF417, "1", -1, " --heightperrow", "", "", 0 },
/* 47*/ { BARCODE_EANX, "501234567890", -1, " --scalexdimdp=", "12345678", "Error 178: scalexdimdp X-dim invalid floating point (integer part must be 7 digits maximum)", 0 }, /* 47*/ { -1, NULL, -1, " -v", NULL, "Zint version ", 1 },
/* 48*/ { BARCODE_EANX, "501234567890", -1, " --scalexdimdp=", "1234567890123", "Error 176: scalexdimdp X-dim too long", 0 }, /* 48*/ { -1, NULL, -1, " --version", NULL, "Zint version ", 1 },
/* 49*/ { BARCODE_EANX, "501234567890", -1, " --scalexdimdp=", "123456.12", "Error 178: scalexdimdp X-dim invalid floating point (7 significant digits maximum)", 0 }, /* 49*/ { -1, NULL, -1, " -h", NULL, "Encode input data in a barcode ", 1 },
/* 50*/ { BARCODE_EANX, "501234567890", -1, " --scalexdimdp=", ",12.34", "Error 174: scalexdimdp X-dim too short", 0 }, /* 50*/ { -1, NULL, -1, " -e", NULL, "3: ISO/IEC 8859-1 ", 1 },
/* 51*/ { BARCODE_EANX, "501234567890", -1, " --scalexdimdp=", "12.34,", "Error 175: scalexdimdp resolution too short", 0 }, /* 51*/ { -1, NULL, -1, " -t", NULL, "1 CODE11 ", 1 },
/* 52*/ { BARCODE_EANX, "501234567890", -1, " --scalexdimdp=", "12mm1", "Error 177: scalexdimdp X-dim units must occur at end", 0 }, /* 52*/ { BARCODE_EANX, "501234567890", -1, " --scalexdimdp=", "12345678", "Error 178: scalexdimdp X-dim invalid floating point (integer part must be 7 digits maximum)", 0 },
/* 53*/ { BARCODE_EANX, "501234567890", -1, " --scalexdimdp=", "1inc", "Error 177: scalexdimdp X-dim units must occur at end", 0 }, /* 53*/ { BARCODE_EANX, "501234567890", -1, " --scalexdimdp=", "1234567890123", "Error 176: scalexdimdp X-dim too long", 0 },
/* 54*/ { BARCODE_EANX, "501234567890", -1, " --scalexdimdp=", "1234x", "Error 178: scalexdimdp X-dim invalid floating point (integer part must be digits only)", 0 }, /* 54*/ { BARCODE_EANX, "501234567890", -1, " --scalexdimdp=", "123456.12", "Error 178: scalexdimdp X-dim invalid floating point (7 significant digits maximum)", 0 },
/* 55*/ { BARCODE_EANX, "501234567890", -1, " --scalexdimdp=", "12.34in,123x", "Error 180: scalexdimdp resolution invalid floating point (integer part must be digits only)", 0 }, /* 55*/ { BARCODE_EANX, "501234567890", -1, " --scalexdimdp=", ",12.34", "Error 174: scalexdimdp X-dim too short", 0 },
/* 56*/ { BARCODE_EANX, "501234567890", -1, " --scalexdimdp=", "12,123.45678", "Error 180: scalexdimdp resolution invalid floating point (7 significant digits maximum)", 0 }, /* 56*/ { BARCODE_EANX, "501234567890", -1, " --scalexdimdp=", "12.34,", "Error 175: scalexdimdp resolution too short", 0 },
/* 57*/ { BARCODE_EANX, "501234567890", -1, " --scalexdimdp=", "10.1,1000", "Warning 185: scalexdimdp X-dim (10.1) out of range (> 10), ignoring", 0 }, /* 57*/ { BARCODE_EANX, "501234567890", -1, " --scalexdimdp=", "12mm1", "Error 177: scalexdimdp X-dim units must occur at end", 0 },
/* 58*/ { BARCODE_EANX, "501234567890", -1, " --scalexdimdp=", "10,1000.1", "Warning 186: scalexdimdp resolution (1000.1) out of range (> 1000), ignoring", 0 }, /* 58*/ { BARCODE_EANX, "501234567890", -1, " --scalexdimdp=", "1inc", "Error 177: scalexdimdp X-dim units must occur at end", 0 },
/* 59*/ { BARCODE_EANX, "501234567890", -1, " --scalexdimdp=", "1234x", "Error 178: scalexdimdp X-dim invalid floating point (integer part must be digits only)", 0 },
/* 60*/ { BARCODE_EANX, "501234567890", -1, " --scalexdimdp=", "12.34in,123x", "Error 180: scalexdimdp resolution invalid floating point (integer part must be digits only)", 0 },
/* 61*/ { BARCODE_EANX, "501234567890", -1, " --scalexdimdp=", "12,123.45678", "Error 180: scalexdimdp resolution invalid floating point (7 significant digits maximum)", 0 },
/* 62*/ { BARCODE_EANX, "501234567890", -1, " --scalexdimdp=", "10.1,1000", "Warning 185: scalexdimdp X-dim (10.1) out of range (> 10), ignoring", 0 },
/* 63*/ { BARCODE_EANX, "501234567890", -1, " --scalexdimdp=", "10,1000.1", "Warning 186: scalexdimdp resolution (1000.1) out of range (> 1000), ignoring", 0 },
}; };
int data_size = ARRAY_SIZE(data); int data_size = ARRAY_SIZE(data);
int i; int i;

View File

@ -178,7 +178,7 @@
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>24</height> <height>26</height>
</size> </size>
</property> </property>
<property name="toolTip"> <property name="toolTip">
@ -195,7 +195,7 @@ or import from file</string>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>22</width> <width>22</width>
<height>16777215</height> <height>26</height>
</size> </size>
</property> </property>
<property name="toolTip"> <property name="toolTip">
@ -468,7 +468,7 @@ or import from file</string>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>22</width> <width>22</width>
<height>16777215</height> <height>26</height>
</size> </size>
</property> </property>
<property name="toolTip"> <property name="toolTip">
@ -626,7 +626,7 @@ Remember to place [square brackets] around AI identifiers</string>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>22</width> <width>22</width>
<height>16777215</height> <height>26</height>
</size> </size>
</property> </property>
<property name="toolTip"> <property name="toolTip">
@ -929,7 +929,7 @@ Extended Channel Interpretation (ECI)</string>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>24</height> <height>26</height>
</size> </size>
</property> </property>
<property name="toolTip"> <property name="toolTip">
@ -946,7 +946,7 @@ or import from file</string>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>22</width> <width>22</width>
<height>16777215</height> <height>26</height>
</size> </size>
</property> </property>
<property name="toolTip"> <property name="toolTip">
@ -1190,7 +1190,7 @@ or import from file</string>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>24</height> <height>26</height>
</size> </size>
</property> </property>
<property name="toolTip"> <property name="toolTip">
@ -1207,7 +1207,7 @@ or import from file</string>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>22</width> <width>22</width>
<height>16777215</height> <height>26</height>
</size> </size>
</property> </property>
<property name="toolTip"> <property name="toolTip">
@ -1451,7 +1451,7 @@ or import from file</string>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>24</height> <height>26</height>
</size> </size>
</property> </property>
<property name="toolTip"> <property name="toolTip">
@ -1468,7 +1468,7 @@ or import from file</string>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>22</width> <width>22</width>
<height>16777215</height> <height>26</height>
</size> </size>
</property> </property>
<property name="toolTip"> <property name="toolTip">
@ -1693,41 +1693,6 @@ and use standard height (if any) for default
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="lblBorderWidth">
<property name="toolTip">
<string>Width of boundary bars or border in X-dimensions</string>
</property>
<property name="text">
<string>B&amp;order Width:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>bwidth</cstring>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QSpinBox" name="bwidth">
<property name="toolTip">
<string>Width of boundary bars or border in X-dimensions</string>
</property>
<property name="suffix">
<string> X</string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>16</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lblBorderType"> <widget class="QLabel" name="lblBorderType">
<property name="toolTip"> <property name="toolTip">
<string>Add border or box</string> <string>Add border or box</string>
@ -1743,7 +1708,7 @@ and use standard height (if any) for default
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1" colspan="2"> <item row="2" column="1" colspan="2">
<widget class="QComboBox" name="btype"> <widget class="QComboBox" name="btype">
<property name="toolTip"> <property name="toolTip">
<string>Add border or box</string> <string>Add border or box</string>
@ -1773,6 +1738,41 @@ and use standard height (if any) for default
</item> </item>
</widget> </widget>
</item> </item>
<item row="3" column="0">
<widget class="QLabel" name="lblBorderWidth">
<property name="toolTip">
<string>Width of boundary bars or border in X-dimensions</string>
</property>
<property name="text">
<string>B&amp;order Width:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>bwidth</cstring>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<widget class="QSpinBox" name="bwidth">
<property name="toolTip">
<string>Width of boundary bars or border in X-dimensions</string>
</property>
<property name="suffix">
<string> X</string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>16</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="4" column="0"> <item row="4" column="0">
<widget class="QLabel" name="lblWhitespace"> <widget class="QLabel" name="lblWhitespace">
<property name="toolTip"> <property name="toolTip">
@ -1794,8 +1794,8 @@ and use standard height (if any) for default
<item row="0" column="0"> <item row="0" column="0">
<widget class="QSpinBox" name="spnWhitespace"> <widget class="QSpinBox" name="spnWhitespace">
<property name="toolTip"> <property name="toolTip">
<string>Width of horizontal whitespace on either side of barcode <string>Width of horizontal whitespace on either side
in X-dimensions</string> of barcode in X-dimensions</string>
</property> </property>
<property name="suffix"> <property name="suffix">
<string> X</string> <string> X</string>
@ -1808,8 +1808,8 @@ in X-dimensions</string>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QSpinBox" name="spnVWhitespace"> <widget class="QSpinBox" name="spnVWhitespace">
<property name="toolTip"> <property name="toolTip">
<string>Height of vertical whitespace above and below the barcode <string>Height of vertical whitespace above and below
in X-dimensions</string> the barcode in X-dimensions</string>
</property> </property>
<property name="suffix"> <property name="suffix">
<string> X</string> <string> X</string>
@ -1821,89 +1821,21 @@ in X-dimensions</string>
</item> </item>
</layout> </layout>
</item> </item>
<item row="5" column="0"> <item row="5" column="0" colspan="2">
<widget class="QLabel" name="lblScale"> <widget class="QCheckBox" name="chkHRTShow">
<property name="toolTip"> <property name="toolTip">
<string>Image scale when output to file <string>Show Human Readable Text in image
(adjusts the X-dimension)</string> (ignored if disabled)</string>
</property> </property>
<property name="text"> <property name="text">
<string>&amp;Printing Scale:</string> <string>Show Te&amp;xt</string>
</property> </property>
<property name="alignment"> <property name="checked">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> <bool>true</bool>
</property>
<property name="buddy">
<cstring>spnScale</cstring>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QDoubleSpinBox" name="spnScale">
<property name="toolTip">
<string>Image scale when output to file
(adjusts the X-dimension)</string>
</property>
<property name="suffix">
<string/>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="minimum">
<double>0.100000000000000</double>
</property>
<property name="maximum">
<double>100.000000000000000</double>
</property>
<property name="singleStep">
<double>0.500000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QPushButton" name="btnScale">
<property name="maximumSize">
<size>
<width>22</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Set Printing Scale by X-dimension and resolution</string>
</property>
<property name="text">
<string/>
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="0"> <item row="6" column="0">
<widget class="QLabel" name="lblSize">
<property name="toolTip">
<string>Image size (width x height) of barcode at given dot density</string>
</property>
<property name="text">
<string>Print Size:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="6" column="1" colspan="5">
<widget class="QLabel" name="lblSizeMsg">
<property name="toolTip">
<string>Image size (width x height) of barcode at given dot density</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="lblFontSetting"> <widget class="QLabel" name="lblFontSetting">
<property name="toolTip"> <property name="toolTip">
<string>Set font characteristics <string>Set font characteristics
@ -1920,7 +1852,7 @@ in X-dimensions</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="1" colspan="2"> <item row="6" column="1" colspan="2">
<widget class="QComboBox" name="cmbFontSetting"> <widget class="QComboBox" name="cmbFontSetting">
<property name="toolTip"> <property name="toolTip">
<string>Set font characteristics <string>Set font characteristics
@ -1948,17 +1880,87 @@ in X-dimensions</string>
</item> </item>
</widget> </widget>
</item> </item>
<item row="8" column="0" colspan="2"> <item row="7" column="0">
<widget class="QCheckBox" name="chkHRTShow"> <widget class="QLabel" name="lblScale">
<property name="toolTip"> <property name="toolTip">
<string>Show Human Readable Text in image <string>Image scale when output to file
(ignored if disabled)</string> (adjusts the X-dimension)</string>
</property> </property>
<property name="text"> <property name="text">
<string>Show Te&amp;xt</string> <string>&amp;Printing Scale:</string>
</property> </property>
<property name="checked"> <property name="alignment">
<bool>true</bool> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>spnScale</cstring>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QDoubleSpinBox" name="spnScale">
<property name="toolTip">
<string>Image scale when output to file
(adjusts the X-dimension)</string>
</property>
<property name="suffix">
<string/>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="minimum">
<double>0.100000000000000</double>
</property>
<property name="maximum">
<double>100.000000000000000</double>
</property>
<property name="singleStep">
<double>0.500000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QPushButton" name="btnScale">
<property name="maximumSize">
<size>
<width>22</width>
<height>26</height>
</size>
</property>
<property name="toolTip">
<string>Set Printing Scale by X-dimension and resolution</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="lblSize">
<property name="toolTip">
<string>Image size (width x height) of barcode
at given dot density</string>
</property>
<property name="text">
<string>Print Size:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="8" column="1" colspan="5">
<widget class="QLabel" name="lblSizeMsg">
<property name="toolTip">
<string>Image size (width x height) of barcode
at given dot density</string>
</property>
<property name="text">
<string/>
</property> </property>
</widget> </widget>
</item> </item>
@ -1990,12 +1992,12 @@ in X-dimensions</string>
</size> </size>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Change ink colour, format <string>Change ink colour, format is
is hexadecimal &quot;RRGGBB&quot; hexadecimal &quot;RRGGBB&quot; or &quot;RRGGBBAA&quot; (alpha)
or &quot;RRGGBBAA&quot; (alpha)</string> or decimal &quot;C,M,Y,K&quot; percentages (0-100)</string>
</property> </property>
<property name="maxLength"> <property name="maxLength">
<number>8</number> <number>15</number>
</property> </property>
</widget> </widget>
</item> </item>
@ -2004,7 +2006,7 @@ or &quot;RRGGBBAA&quot; (alpha)</string>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>22</width> <width>22</width>
<height>16777215</height> <height>26</height>
</size> </size>
</property> </property>
<property name="toolTip"> <property name="toolTip">
@ -2043,12 +2045,14 @@ or &quot;RRGGBBAA&quot; (alpha)</string>
</size> </size>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Change paper colour, format <string>Change paper colour, format is
is hexadecimal &quot;RRGGBB&quot; hexadecimal &quot;RRGGBB&quot; or &quot;RRGGBBAA&quot; (alpha)
or &quot;RRGGBBAA&quot; (alpha)</string> or decimal &quot;C,M,Y,K&quot; percentages (0-100).
For no background, set alpha channel to zero,
e.g. &quot;FFFFFF00&quot;</string>
</property> </property>
<property name="maxLength"> <property name="maxLength">
<number>8</number> <number>15</number>
</property> </property>
</widget> </widget>
</item> </item>
@ -2057,7 +2061,7 @@ or &quot;RRGGBBAA&quot; (alpha)</string>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>22</width> <width>22</width>
<height>16777215</height> <height>26</height>
</size> </size>
</property> </property>
<property name="toolTip"> <property name="toolTip">
@ -2108,7 +2112,7 @@ or &quot;RRGGBBAA&quot; (alpha)</string>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>22</width> <width>22</width>
<height>16777215</height> <height>26</height>
</size> </size>
</property> </property>
<property name="toolTip"> <property name="toolTip">
@ -2190,7 +2194,7 @@ or &quot;RRGGBBAA&quot; (alpha)</string>
</item> </item>
</widget> </widget>
</item> </item>
<item row="7" column="4" colspan="2"> <item row="6" column="4" colspan="2">
<widget class="QCheckBox" name="chkDotty"> <widget class="QCheckBox" name="chkDotty">
<property name="toolTip"> <property name="toolTip">
<string>Use dots instead of squares for matrix symbols <string>Use dots instead of squares for matrix symbols
@ -2204,7 +2208,7 @@ or &quot;RRGGBBAA&quot; (alpha)</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="3"> <item row="7" column="3">
<widget class="QLabel" name="lblDotSize"> <widget class="QLabel" name="lblDotSize">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
@ -2224,7 +2228,7 @@ or &quot;RRGGBBAA&quot; (alpha)</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="4" colspan="2"> <item row="7" column="4" colspan="2">
<widget class="QDoubleSpinBox" name="spnDotSize"> <widget class="QDoubleSpinBox" name="spnDotSize">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
@ -2284,7 +2288,7 @@ or &quot;RRGGBBAA&quot; (alpha)</string>
<string>Show menu</string> <string>Show menu</string>
</property> </property>
<property name="text"> <property name="text">
<string>Men&amp;u</string> <string> Men&amp;u</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -2327,7 +2331,7 @@ or &quot;RRGGBBAA&quot; (alpha)</string>
<string>Output image to file (BMP/EMF/EPS/GIF/PCX/PNG/SVG/TIF)</string> <string>Output image to file (BMP/EMF/EPS/GIF/PCX/PNG/SVG/TIF)</string>
</property> </property>
<property name="text"> <property name="text">
<string>&amp;Save As…</string> <string> &amp;Save...</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -2337,7 +2341,7 @@ or &quot;RRGGBBAA&quot; (alpha)</string>
<string>Exit Zint Barcode Studio</string> <string>Exit Zint Barcode Studio</string>
</property> </property>
<property name="text"> <property name="text">
<string>&amp;Quit</string> <string> &amp;Quit</string>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -57,10 +57,48 @@ static const QKeySequence copyTIFSeq(Qt::SHIFT | Qt::CTRL | Qt::Key_T);
static const QKeySequence factoryResetSeq(Qt::SHIFT | Qt::CTRL | Qt::Key_R); static const QKeySequence factoryResetSeq(Qt::SHIFT | Qt::CTRL | Qt::Key_R);
static const QRegularExpression colorRE(QSL("^[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?$")); // RGB hexadecimal 6 or 8 in length or CMYK comma-separated decimal percentages "C,M,Y,K"
static const QRegularExpression colorRE(
QSL("^([0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?)|(((100|[0-9]{0,2}),){3}(100|[0-9]{0,2}))$"));
static const QColor fgcolorDefault(0, 0, 0, 0xff); static const QString fgDefault(QSL("000000"));
static const QColor bgcolorDefault(0xff, 0xff, 0xff, 0xff); static const QString bgDefault(QSL("FFFFFF"));
static const QString fgDefaultAlpha(QSL("000000FF"));
static const QString bgDefaultAlpha(QSL("FFFFFFFF"));
static QString qcolor_to_str(const QColor &color)
{
if (color.alpha() == 0xFF) {
return QString::asprintf("%02X%02X%02X", color.red(), color.green(), color.blue());
}
return QString::asprintf("%02X%02X%02X%02X", color.red(), color.green(), color.blue(), color.alpha());
}
static QColor str_to_qcolor(const QString &str)
{
QColor color;
int r, g, b, a;
if (str.contains(',')) {
int comma1 = str.indexOf(',');
int comma2 = str.indexOf(',', comma1 + 1);
int comma3 = str.indexOf(',', comma2 + 1);
int black = 100 - str.mid(comma3 + 1).toInt();
int val = 100 - str.mid(0, comma1).toInt();
r = (int) roundf((0xFF * val * black) / 10000.0f);
val = 100 - str.mid(comma1 + 1, comma2 - comma1 - 1).toInt();
g = (int) roundf((0xFF * val * black) / 10000.0f);
val = 100 - str.mid(comma2 + 1, comma3 - comma2 - 1).toInt();
b = (int) roundf((0xFF * val * black) / 10000.0f);
a = 0xFF;
} else {
r = str.mid(0, 2).toInt(nullptr, 16);
g = str.mid(2, 2).toInt(nullptr, 16);
b = str.mid(4, 2).toInt(nullptr, 16);
a = str.length() == 8 ? str.mid(6, 2).toInt(nullptr, 16) : 0xFF;
}
color.setRgb(r, g, b, a);
return color;
}
struct bstyle_item { struct bstyle_item {
const QString text; const QString text;
@ -402,14 +440,8 @@ MainWindow::~MainWindow()
settings.setValue(QSL("studio/bgcolor_geometry"), m_bgcolor_geometry); settings.setValue(QSL("studio/bgcolor_geometry"), m_bgcolor_geometry);
settings.setValue(QSL("studio/tab_index"), tabMain->currentIndex()); settings.setValue(QSL("studio/tab_index"), tabMain->currentIndex());
settings.setValue(QSL("studio/symbology"), bstyle->currentIndex()); settings.setValue(QSL("studio/symbology"), bstyle->currentIndex());
settings.setValue(QSL("studio/ink/red"), m_fgcolor.red()); settings.setValue(QSL("studio/ink/text"), m_fgstr);
settings.setValue(QSL("studio/ink/green"), m_fgcolor.green()); settings.setValue(QSL("studio/paper/text"), m_bgstr);
settings.setValue(QSL("studio/ink/blue"), m_fgcolor.blue());
settings.setValue(QSL("studio/ink/alpha"), m_fgcolor.alpha());
settings.setValue(QSL("studio/paper/red"), m_bgcolor.red());
settings.setValue(QSL("studio/paper/green"), m_bgcolor.green());
settings.setValue(QSL("studio/paper/blue"), m_bgcolor.blue());
settings.setValue(QSL("studio/paper/alpha"), m_bgcolor.alpha());
settings.setValue(QSL("studio/data"), txtData->text()); settings.setValue(QSL("studio/data"), txtData->text());
/* Seg data not saved so don't restore */ /* Seg data not saved so don't restore */
settings.setValue(QSL("studio/composite_text"), txtComposite->toPlainText()); settings.setValue(QSL("studio/composite_text"), txtComposite->toPlainText());
@ -451,14 +483,28 @@ void MainWindow::load_settings(QSettings &settings)
bool initial_load = m_symbology == 0; bool initial_load = m_symbology == 0;
QString initialData(initial_load ? tr("Your Data Here!") : ""); QString initialData(initial_load ? tr("Your Data Here!") : "");
m_fgcolor.setRgb(settings.value(QSL("studio/ink/red"), 0).toInt(), m_fgstr = settings.value(QSL("studio/ink/text"), QSL("")).toString();
if (m_fgstr.isEmpty()) {
QColor color(settings.value(QSL("studio/ink/red"), 0).toInt(),
settings.value(QSL("studio/ink/green"), 0).toInt(), settings.value(QSL("studio/ink/green"), 0).toInt(),
settings.value(QSL("studio/ink/blue"), 0).toInt(), settings.value(QSL("studio/ink/blue"), 0).toInt(),
settings.value(QSL("studio/ink/alpha"), 0xff).toInt()); settings.value(QSL("studio/ink/alpha"), 0xff).toInt());
m_bgcolor.setRgb(settings.value(QSL("studio/paper/red"), 0xff).toInt(), m_fgstr = qcolor_to_str(color);
settings.value(QSL("studio/paper/green"), 0xff).toInt(), }
settings.value(QSL("studio/paper/blue"), 0xff).toInt(), if (m_fgstr.indexOf(colorRE) != 0) {
m_fgstr = fgDefault;
}
m_bgstr = settings.value(QSL("studio/paper/text"), QSL("")).toString();
if (m_bgstr.isEmpty()) {
QColor color(settings.value(QSL("studio/paper/red"), 0).toInt(),
settings.value(QSL("studio/paper/green"), 0).toInt(),
settings.value(QSL("studio/paper/blue"), 0).toInt(),
settings.value(QSL("studio/paper/alpha"), 0xff).toInt()); settings.value(QSL("studio/paper/alpha"), 0xff).toInt());
m_bgstr = qcolor_to_str(color);
}
if (m_bgstr.indexOf(colorRE) != 0) {
m_bgstr = bgDefault;
}
txtData->setText(settings.value(QSL("studio/data"), initialData).toString()); txtData->setText(settings.value(QSL("studio/data"), initialData).toString());
/* Don't save seg data */ /* Don't save seg data */
@ -556,9 +602,9 @@ bool MainWindow::eventFilter(QObject *watched, QEvent *event)
QFocusEvent *focusEvent = static_cast<QFocusEvent *>(event); QFocusEvent *focusEvent = static_cast<QFocusEvent *>(event);
if (focusEvent->reason() != Qt::PopupFocusReason) { if (focusEvent->reason() != Qt::PopupFocusReason) {
if (watched == txt_fgcolor) { if (watched == txt_fgcolor) {
setColorTxtBtn(m_fgcolor, txt_fgcolor, fgcolor); setColorTxtBtn(m_fgstr, txt_fgcolor, fgcolor);
} else { } else {
setColorTxtBtn(m_bgcolor, txt_bgcolor, bgcolor); setColorTxtBtn(m_bgstr, txt_bgcolor, bgcolor);
} }
} }
} }
@ -568,41 +614,30 @@ bool MainWindow::eventFilter(QObject *watched, QEvent *event)
void MainWindow::reset_colours() void MainWindow::reset_colours()
{ {
m_fgcolor = fgcolorDefault; m_fgstr = fgDefault;
m_bgcolor = bgcolorDefault; m_bgstr = bgDefault;
setColorTxtBtn(m_fgcolor, txt_fgcolor, fgcolor); setColorTxtBtn(m_fgstr, txt_fgcolor, fgcolor);
setColorTxtBtn(m_bgcolor, txt_bgcolor, bgcolor); setColorTxtBtn(m_bgstr, txt_bgcolor, bgcolor);
update_preview(); update_preview();
} }
void MainWindow::reverse_colours() void MainWindow::reverse_colours()
{ {
QColor temp = m_fgcolor; QString temp = m_fgstr;
m_fgcolor = m_bgcolor; m_fgstr = m_bgstr;
m_bgcolor = temp; m_bgstr = temp;
setColorTxtBtn(m_fgcolor, txt_fgcolor, fgcolor); setColorTxtBtn(m_fgstr, txt_fgcolor, fgcolor);
setColorTxtBtn(m_bgcolor, txt_bgcolor, bgcolor); setColorTxtBtn(m_bgstr, txt_bgcolor, bgcolor);
update_preview(); update_preview();
} }
QString MainWindow::getColorStr(const QColor color, bool alpha_always) { void MainWindow::setColorTxtBtn(const QString &colorStr, QLineEdit *txt, QPushButton* btn) {
QString ret;
if (color.alpha() != 0xFF || alpha_always) {
ret = QString::asprintf("%02X%02X%02X%02X", color.red(), color.green(), color.blue(), color.alpha());
} else {
ret = QString::asprintf("%02X%02X%02X", color.red(), color.green(), color.blue());
}
return ret;
}
void MainWindow::setColorTxtBtn(const QColor color, QLineEdit *txt, QPushButton* btn) {
QString colorStr = getColorStr(color);
if (colorStr != txt->text()) { if (colorStr != txt->text()) {
int cursorPos = txt->cursorPosition(); int cursorPos = txt->cursorPosition();
txt->setText(colorStr); txt->setText(colorStr);
txt->setCursorPosition(cursorPos); txt->setCursorPosition(cursorPos);
} }
btn->setStyleSheet(QSL("QPushButton {background-color:") + color.name() + QSL(";}")); btn->setStyleSheet(QSL("QPushButton {background-color:") + str_to_qcolor(colorStr).name() + QSL(";}"));
} }
bool MainWindow::save() bool MainWindow::save()
@ -718,13 +753,14 @@ void MainWindow::factory_reset()
int symbology = bstyle_items[bstyle->currentIndex()].symbology; int symbology = bstyle_items[bstyle->currentIndex()].symbology;
load_settings(settings); load_settings(settings);
setColorTxtBtn(m_fgcolor, txt_fgcolor, fgcolor);
setColorTxtBtn(m_bgcolor, txt_bgcolor, bgcolor);
load_sub_settings(settings, symbology); load_sub_settings(settings, symbology);
settings.sync(); settings.sync();
setColorTxtBtn(m_fgstr, txt_fgcolor, fgcolor);
setColorTxtBtn(m_bgstr, txt_bgcolor, bgcolor);
txtData->setFocus(Qt::OtherFocusReason); txtData->setFocus(Qt::OtherFocusReason);
update_preview(); update_preview();
} }
@ -937,15 +973,15 @@ void MainWindow::zap()
load_settings(settings); load_settings(settings);
setColorTxtBtn(m_fgcolor, txt_fgcolor, fgcolor);
setColorTxtBtn(m_bgcolor, txt_bgcolor, bgcolor);
m_xdimdpVars.x_dim = 0.0f; m_xdimdpVars.x_dim = 0.0f;
m_xdimdpVars.x_dim_units = 0; m_xdimdpVars.x_dim_units = 0;
m_xdimdpVars.set = 0; m_xdimdpVars.set = 0;
load_sub_settings(settings, symbology); load_sub_settings(settings, symbology);
setColorTxtBtn(m_fgstr, txt_fgcolor, fgcolor);
setColorTxtBtn(m_bgstr, txt_bgcolor, bgcolor);
txtData->setFocus(Qt::OtherFocusReason); txtData->setFocus(Qt::OtherFocusReason);
update_preview(); update_preview();
} }
@ -999,45 +1035,45 @@ void MainWindow::open_scale_dialog()
void MainWindow::on_fgcolor_clicked() void MainWindow::on_fgcolor_clicked()
{ {
color_clicked(m_fgcolor, txt_fgcolor, fgcolor, tr("Set foreground colour"), m_fgcolor_geometry, color_clicked(m_fgstr, txt_fgcolor, fgcolor, tr("Set foreground colour"), m_fgcolor_geometry,
SLOT(fgcolor_changed(const QColor&))); SLOT(fgcolor_changed(const QColor&)));
} }
void MainWindow::on_bgcolor_clicked() void MainWindow::on_bgcolor_clicked()
{ {
color_clicked(m_bgcolor, txt_bgcolor, bgcolor, tr("Set background colour"), m_bgcolor_geometry, color_clicked(m_bgstr, txt_bgcolor, bgcolor, tr("Set background colour"), m_bgcolor_geometry,
SLOT(bgcolor_changed(const QColor&))); SLOT(bgcolor_changed(const QColor&)));
} }
void MainWindow::color_clicked(QColor &color, QLineEdit *txt, QPushButton *btn, const QString& title, void MainWindow::color_clicked(QString &colorStr, QLineEdit *txt, QPushButton *btn, const QString& title,
QByteArray& geometry, const char *color_changed) QByteArray& geometry, const char *color_changed)
{ {
QColor original = color; QString original = colorStr;
QColorDialog color_dialog(nullptr /*parent*/); QColorDialog color_dialog(nullptr /*parent*/);
color_dialog.setWindowTitle(title); color_dialog.setWindowTitle(title);
color_dialog.setOptions(QColorDialog::DontUseNativeDialog | QColorDialog::ShowAlphaChannel); color_dialog.setOptions(QColorDialog::DontUseNativeDialog | QColorDialog::ShowAlphaChannel);
color_dialog.setCurrentColor(color); color_dialog.setCurrentColor(str_to_qcolor(colorStr));
color_dialog.restoreGeometry(geometry); color_dialog.restoreGeometry(geometry);
connect(&color_dialog, SIGNAL(currentColorChanged(const QColor &)), this, color_changed); connect(&color_dialog, SIGNAL(currentColorChanged(const QColor &)), this, color_changed);
if (color_dialog.exec() && color_dialog.selectedColor().isValid()) { if (color_dialog.exec() && color_dialog.selectedColor().isValid()) {
color = color_dialog.selectedColor(); colorStr = qcolor_to_str(color_dialog.selectedColor());
} else { } else {
color = original; colorStr = original;
} }
geometry = color_dialog.saveGeometry(); geometry = color_dialog.saveGeometry();
disconnect(&color_dialog, SIGNAL(currentColorChanged(const QColor &)), this, color_changed); disconnect(&color_dialog, SIGNAL(currentColorChanged(const QColor &)), this, color_changed);
setColorTxtBtn(color, txt, btn); setColorTxtBtn(colorStr, txt, btn);
update_preview(); update_preview();
} }
void MainWindow::fgcolor_changed(const QColor& color) void MainWindow::fgcolor_changed(const QColor& color)
{ {
if (color.isValid()) { if (color.isValid()) {
m_fgcolor = color; m_fgstr = qcolor_to_str(color);
setColorTxtBtn(m_fgcolor, txt_fgcolor, fgcolor); setColorTxtBtn(m_fgstr, txt_fgcolor, fgcolor);
update_preview(); update_preview();
} }
} }
@ -1045,39 +1081,30 @@ void MainWindow::fgcolor_changed(const QColor& color)
void MainWindow::bgcolor_changed(const QColor& color) void MainWindow::bgcolor_changed(const QColor& color)
{ {
if (color.isValid()) { if (color.isValid()) {
m_bgcolor = color; m_bgstr = qcolor_to_str(color);
setColorTxtBtn(m_bgcolor, txt_bgcolor, bgcolor); setColorTxtBtn(m_bgstr, txt_bgcolor, bgcolor);
update_preview(); update_preview();
} }
} }
void MainWindow::fgcolor_edited() void MainWindow::fgcolor_edited()
{ {
color_edited(m_fgcolor, txt_fgcolor, fgcolor); color_edited(m_fgstr, txt_fgcolor, fgcolor);
} }
void MainWindow::bgcolor_edited() void MainWindow::bgcolor_edited()
{ {
color_edited(m_bgcolor, txt_bgcolor, bgcolor); color_edited(m_bgstr, txt_bgcolor, bgcolor);
} }
void MainWindow::color_edited(QColor &color, QLineEdit *txt, QPushButton *btn) void MainWindow::color_edited(QString &colorStr, QLineEdit *txt, QPushButton *btn)
{ {
QColor new_color; QString new_str = txt->text().trimmed();
QString new_text = txt->text().trimmed(); if (new_str.indexOf(colorRE) != 0) {
if (new_text.indexOf(colorRE) != 0) {
return; return;
} }
int r = new_text.mid(0, 2).toInt(nullptr, 16); colorStr = new_str;
int g = new_text.mid(2, 2).toInt(nullptr, 16); setColorTxtBtn(colorStr, txt, btn);
int b = new_text.mid(4, 2).toInt(nullptr, 16);
int a = new_text.length() == 8 ? new_text.mid(6, 2).toInt(nullptr, 16) : 0xFF;
new_color.setRgb(r, g, b, a);
if (!new_color.isValid()) {
return;
}
color = new_color;
setColorTxtBtn(color, txt, btn);
update_preview(); update_preview();
} }
@ -1545,8 +1572,8 @@ void MainWindow::change_options()
m_btnHeightPerRowDisable = nullptr; m_btnHeightPerRowDisable = nullptr;
m_btnHeightPerRowDefault = nullptr; m_btnHeightPerRowDefault = nullptr;
setColorTxtBtn(m_fgcolor, txt_fgcolor, fgcolor); setColorTxtBtn(m_fgstr, txt_fgcolor, fgcolor);
setColorTxtBtn(m_bgcolor, txt_bgcolor, bgcolor); setColorTxtBtn(m_bgstr, txt_bgcolor, bgcolor);
m_xdimdpVars.x_dim = 0.0f; m_xdimdpVars.x_dim = 0.0f;
m_xdimdpVars.x_dim_units = 0; m_xdimdpVars.x_dim_units = 0;
@ -2199,8 +2226,8 @@ void MainWindow::change_options()
chkQuietZones->setEnabled(!m_bc.bc.hasDefaultQuietZones(symbology)); chkQuietZones->setEnabled(!m_bc.bc.hasDefaultQuietZones(symbology));
chkDotty->setEnabled(m_bc.bc.isDotty(symbology)); chkDotty->setEnabled(m_bc.bc.isDotty(symbology));
setColorTxtBtn(m_fgcolor, txt_fgcolor, fgcolor); setColorTxtBtn(m_fgstr, txt_fgcolor, fgcolor);
setColorTxtBtn(m_bgcolor, txt_bgcolor, bgcolor); setColorTxtBtn(m_bgstr, txt_bgcolor, bgcolor);
data_ui_set(); data_ui_set();
composite_ui_set(); composite_ui_set();
@ -2513,7 +2540,8 @@ void MainWindow::update_preview()
m_bc.bc.setText(txtData->text()); m_bc.bc.setText(txtData->text());
} }
} }
btnReset->setEnabled(m_fgcolor != fgcolorDefault || m_bgcolor != bgcolorDefault); btnReset->setEnabled((m_fgstr != fgDefault && m_fgstr != fgDefaultAlpha)
|| (m_bgstr != bgDefault && m_bgstr != bgDefaultAlpha));
m_bc.bc.setOption1(-1); m_bc.bc.setOption1(-1);
m_bc.bc.setOption2(0); m_bc.bc.setOption2(0);
m_bc.bc.setOption3(0); m_bc.bc.setOption3(0);
@ -3143,8 +3171,8 @@ void MainWindow::update_preview()
if (m_symbology == BARCODE_DOTCODE || (chkDotty->isEnabled() && chkDotty->isChecked())) { if (m_symbology == BARCODE_DOTCODE || (chkDotty->isEnabled() && chkDotty->isChecked())) {
m_bc.bc.setDotSize(spnDotSize->value()); m_bc.bc.setDotSize(spnDotSize->value());
} }
m_bc.bc.setFgColor(m_fgcolor); m_bc.bc.setFgStr(m_fgstr);
m_bc.bc.setBgColor(m_bgcolor); m_bc.bc.setBgStr(m_bgstr);
m_bc.bc.setScale((float) spnScale->value()); m_bc.bc.setScale((float) spnScale->value());
change_cmyk(); change_cmyk();
m_bc.setSize(width - 10, height - 10); m_bc.setSize(width - 10, height - 10);
@ -3169,7 +3197,7 @@ void MainWindow::createActions()
btnMenu->setIcon(menuIcon); btnMenu->setIcon(menuIcon);
btnCopyBMP->setIcon(copyIcon); btnCopyBMP->setIcon(copyIcon);
btnCopySVG->setIcon(copyIcon); btnCopySVG->setIcon(copyIcon);
//btnSave->setIcon(saveIcon); // Makes it too big btnSave->setIcon(saveIcon); // Makes it (too) big but live with it for a while after "Save As..." -> "Save..."
btnExit->setIcon(quitIcon); btnExit->setIcon(quitIcon);
m_copyBMPAct = new QAction(copyIcon, tr("Copy as &BMP"), this); m_copyBMPAct = new QAction(copyIcon, tr("Copy as &BMP"), this);
@ -3236,7 +3264,7 @@ void MainWindow::createActions()
m_helpAct->setShortcut(QKeySequence::HelpContents); m_helpAct->setShortcut(QKeySequence::HelpContents);
connect(m_helpAct, SIGNAL(triggered()), this, SLOT(help())); connect(m_helpAct, SIGNAL(triggered()), this, SLOT(help()));
m_aboutAct = new QAction(aboutIcon, tr("&About"), this); m_aboutAct = new QAction(aboutIcon, tr("&About..."), this);
m_aboutAct->setStatusTip(tr("About Zint Barcode Studio")); m_aboutAct->setStatusTip(tr("About Zint Barcode Studio"));
connect(m_aboutAct, SIGNAL(triggered()), this, SLOT(about())); connect(m_aboutAct, SIGNAL(triggered()), this, SLOT(about()));
@ -3922,14 +3950,8 @@ void MainWindow::save_sub_settings(QSettings &settings, int symbology)
settings.setValue(QSL("studio/bc/%1/appearance/chk_dotty").arg(name), chkDotty->isChecked() ? 1 : 0); settings.setValue(QSL("studio/bc/%1/appearance/chk_dotty").arg(name), chkDotty->isChecked() ? 1 : 0);
settings.setValue(QSL("studio/bc/%1/appearance/dot_size").arg(name), spnDotSize->value()); settings.setValue(QSL("studio/bc/%1/appearance/dot_size").arg(name), spnDotSize->value());
} }
settings.setValue(QSL("studio/bc/%1/ink/red").arg(name), m_fgcolor.red()); settings.setValue(QSL("studio/bc/%1/ink/text").arg(name), m_fgstr);
settings.setValue(QSL("studio/bc/%1/ink/green").arg(name), m_fgcolor.green()); settings.setValue(QSL("studio/bc/%1/paper/text").arg(name), m_bgstr);
settings.setValue(QSL("studio/bc/%1/ink/blue").arg(name), m_fgcolor.blue());
settings.setValue(QSL("studio/bc/%1/ink/alpha").arg(name), m_fgcolor.alpha());
settings.setValue(QSL("studio/bc/%1/paper/red").arg(name), m_bgcolor.red());
settings.setValue(QSL("studio/bc/%1/paper/green").arg(name), m_bgcolor.green());
settings.setValue(QSL("studio/bc/%1/paper/blue").arg(name), m_bgcolor.blue());
settings.setValue(QSL("studio/bc/%1/paper/alpha").arg(name), m_bgcolor.alpha());
settings.setValue(QSL("studio/bc/%1/xdimdpvars/x_dim").arg(name), m_xdimdpVars.x_dim); settings.setValue(QSL("studio/bc/%1/xdimdpvars/x_dim").arg(name), m_xdimdpVars.x_dim);
settings.setValue(QSL("studio/bc/%1/xdimdpvars/x_dim_units").arg(name), m_xdimdpVars.x_dim_units); settings.setValue(QSL("studio/bc/%1/xdimdpvars/x_dim_units").arg(name), m_xdimdpVars.x_dim_units);
settings.setValue(QSL("studio/bc/%1/xdimdpvars/set").arg(name), m_xdimdpVars.set); settings.setValue(QSL("studio/bc/%1/xdimdpvars/set").arg(name), m_xdimdpVars.set);
@ -4095,7 +4117,8 @@ void MainWindow::save_sub_settings(QSettings &settings, int symbology)
case BARCODE_MAILMARK_2D: case BARCODE_MAILMARK_2D:
settings.setValue(QSL("studio/bc/mailmark2d/size"), get_cmb_index(QSL("cmbMailmark2DSize"))); settings.setValue(QSL("studio/bc/mailmark2d/size"), get_cmb_index(QSL("cmbMailmark2DSize")));
settings.setValue(QSL("studio/bc/mailmark2d/chk_suppress_rect"), get_chk_val(QSL("chkMailmark2DRectangle"))); settings.setValue(
QSL("studio/bc/mailmark2d/chk_suppress_rect"), get_chk_val(QSL("chkMailmark2DRectangle")));
break; break;
case BARCODE_ITF14: case BARCODE_ITF14:
@ -4314,7 +4337,8 @@ void MainWindow::load_sub_settings(QSettings &settings, int symbology)
chkHRTShow->setChecked(settings.value( chkHRTShow->setChecked(settings.value(
QSL("studio/bc/%1/appearance/chk_hrt_show").arg(name), 1).toInt() ? true : false); QSL("studio/bc/%1/appearance/chk_hrt_show").arg(name), 1).toInt() ? true : false);
} }
chkCMYK->setChecked(settings.value(QSL("studio/bc/%1/appearance/cmyk").arg(name), 0).toInt() ? true : false); chkCMYK->setChecked(settings.value(
QSL("studio/bc/%1/appearance/chk_cmyk").arg(name), 0).toInt() ? true : false);
chkQuietZones->setChecked(settings.value( chkQuietZones->setChecked(settings.value(
QSL("studio/bc/%1/appearance/chk_quietzones").arg(name), 0).toInt() ? true : false); QSL("studio/bc/%1/appearance/chk_quietzones").arg(name), 0).toInt() ? true : false);
cmbRotate->setCurrentIndex(settings.value(QSL("studio/bc/%1/appearance/rotate").arg(name), 0).toInt()); cmbRotate->setCurrentIndex(settings.value(QSL("studio/bc/%1/appearance/rotate").arg(name), 0).toInt());
@ -4324,15 +4348,28 @@ void MainWindow::load_sub_settings(QSettings &settings, int symbology)
spnDotSize->setValue(settings.value( spnDotSize->setValue(settings.value(
QSL("studio/bc/%1/appearance/dot_size").arg(name), 0.4f / 0.5f).toFloat()); QSL("studio/bc/%1/appearance/dot_size").arg(name), 0.4f / 0.5f).toFloat());
} }
m_fgcolor.setRgb(settings.value(QSL("studio/bc/%1/ink/red").arg(name), 0).toInt(), m_fgstr = settings.value(QSL("studio/bc/%1/ink/text").arg(name), QSL("")).toString();
if (m_fgstr.isEmpty()) {
QColor color(settings.value(QSL("studio/bc/%1/ink/red").arg(name), 0).toInt(),
settings.value(QSL("studio/bc/%1/ink/green").arg(name), 0).toInt(), settings.value(QSL("studio/bc/%1/ink/green").arg(name), 0).toInt(),
settings.value(QSL("studio/bc/%1/ink/blue").arg(name), 0).toInt(), settings.value(QSL("studio/bc/%1/ink/blue").arg(name), 0).toInt(),
settings.value(QSL("studio/bc/%1/ink/alpha").arg(name), 0xff).toInt()); settings.value(QSL("studio/bc/%1/ink/alpha").arg(name), 0xff).toInt());
m_bgcolor.setRgb(settings.value(QSL("studio/bc/%1/paper/red").arg(name), 0xff).toInt(), m_fgstr = qcolor_to_str(color);
}
if (m_fgstr.indexOf(colorRE) != 0) {
m_fgstr = fgDefault;
}
m_bgstr = settings.value(QSL("studio/bc/%1/paper/text").arg(name), QSL("")).toString();
if (m_bgstr.isEmpty()) {
QColor color(settings.value(QSL("studio/bc/%1/paper/red").arg(name), 0xff).toInt(),
settings.value(QSL("studio/bc/%1/paper/green").arg(name), 0xff).toInt(), settings.value(QSL("studio/bc/%1/paper/green").arg(name), 0xff).toInt(),
settings.value(QSL("studio/bc/%1/paper/blue").arg(name), 0xff).toInt(), settings.value(QSL("studio/bc/%1/paper/blue").arg(name), 0xff).toInt(),
settings.value(QSL("studio/bc/%1/paper/alpha").arg(name), 0xff).toInt()); settings.value(QSL("studio/bc/%1/paper/alpha").arg(name), 0xff).toInt());
m_bgstr = qcolor_to_str(color);
}
if (m_bgstr.indexOf(colorRE) != 0) {
m_bgstr = bgDefault;
}
m_xdimdpVars.x_dim = settings.value(QSL("studio/bc/%1/xdimdpvars/x_dim").arg(name), 0.0).toFloat(); m_xdimdpVars.x_dim = settings.value(QSL("studio/bc/%1/xdimdpvars/x_dim").arg(name), 0.0).toFloat();
m_xdimdpVars.x_dim_units = settings.value(QSL("studio/bc/%1/xdimdpvars/x_dim_units").arg(name), 0).toInt(); m_xdimdpVars.x_dim_units = settings.value(QSL("studio/bc/%1/xdimdpvars/x_dim_units").arg(name), 0).toInt();
m_xdimdpVars.set = settings.value(QSL("studio/bc/%1/xdimdpvars/set").arg(name), 0).toInt(); m_xdimdpVars.set = settings.value(QSL("studio/bc/%1/xdimdpvars/set").arg(name), 0).toInt();
@ -4507,7 +4544,8 @@ void MainWindow::load_sub_settings(QSettings &settings, int symbology)
case BARCODE_MAILMARK_2D: case BARCODE_MAILMARK_2D:
set_cmb_from_setting(settings, QSL("studio/bc/mailmark2d/size"), QSL("cmbMailmark2DSize")); set_cmb_from_setting(settings, QSL("studio/bc/mailmark2d/size"), QSL("cmbMailmark2DSize"));
set_chk_from_setting(settings, QSL("studio/bc/mailmark2d/chk_suppress_rect"), QSL("chkMailmark2DRectangle")); set_chk_from_setting(settings, QSL("studio/bc/mailmark2d/chk_suppress_rect"),
QSL("chkMailmark2DRectangle"));
break; break;
case BARCODE_ITF14: case BARCODE_ITF14:

View File

@ -1,6 +1,6 @@
/*************************************************************************** /***************************************************************************
* Copyright (C) 2008 by BogDan Vatra <bogdan@licentia.eu> * * Copyright (C) 2008 by BogDan Vatra <bogdan@licentia.eu> *
* Copyright (C) 2009-2022 by Robin Stuart <rstuart114@gmail.com> * * Copyright (C) 2009-2023 by Robin Stuart <rstuart114@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by * * it under the terms of the GNU General Public License as published by *
@ -129,11 +129,10 @@ protected:
bool clear_data_eci_seg(int seg_no); bool clear_data_eci_seg(int seg_no);
void color_clicked(QColor &color, QLineEdit *txt, QPushButton *btn, const QString& title, QByteArray& geometry, void color_clicked(QString &colorStr, QLineEdit *txt, QPushButton *btn, const QString& title,
const char *color_changed); QByteArray& geometry, const char *color_changed);
void color_edited(QColor &color, QLineEdit *txt, QPushButton *btn); void color_edited(QString &colorStr, QLineEdit *txt, QPushButton *btn);
QString getColorStr(const QColor color, bool alpha_always = false); void setColorTxtBtn(const QString &colorStr, QLineEdit *txt, QPushButton* btn);
void setColorTxtBtn(const QColor color, QLineEdit *txt, QPushButton* btn);
virtual void resizeEvent(QResizeEvent *event) override; virtual void resizeEvent(QResizeEvent *event) override;
virtual bool event(QEvent *event) override; virtual bool event(QEvent *event) override;
@ -201,7 +200,7 @@ protected:
const char *getFileType(const struct Zint::QZintXdimDpVars *vars, bool msg = false) const; const char *getFileType(const struct Zint::QZintXdimDpVars *vars, bool msg = false) const;
private: private:
QColor m_fgcolor, m_bgcolor; QString m_fgstr, m_bgstr;
QByteArray m_fgcolor_geometry, m_bgcolor_geometry; QByteArray m_fgcolor_geometry, m_bgcolor_geometry;
BarcodeItem m_bc; BarcodeItem m_bc;
QWidget *m_optionWidget; QWidget *m_optionWidget;