1
0
mirror of https://github.com/woo-j/zint.git synced 2024-12-23 13:33:55 +03:00

Bugfix: Ouput binding in raster images

Also: tidy up use of output_options
This commit is contained in:
Robin Stuart 2016-08-26 15:13:40 +01:00
parent 747faf85ed
commit 3cf8a142b8
10 changed files with 52 additions and 44 deletions

View File

@ -329,7 +329,9 @@ int code_49(struct zint_symbol *symbol, unsigned char source[], const int length
}
symbol->whitespace_width = 10;
if (!(symbol->output_options & BARCODE_BIND)) {
symbol->output_options += BARCODE_BIND;
}
symbol->border_width = 2;
return 0;

View File

@ -1249,7 +1249,9 @@ int dotcode(struct zint_symbol *symbol, unsigned char source[], int length) {
symbol->row_height[k] = 1;
}
if (!(symbol->output_options & BARCODE_DOTTY_MODE)) {
symbol->output_options += BARCODE_DOTTY_MODE;
}
return 0;
}

View File

@ -570,14 +570,18 @@ static int reduced_charset(struct zint_symbol *symbol, const unsigned char *sour
if (symbol->symbology == BARCODE_CODE16K) {
symbol->whitespace_width = 16;
symbol->border_width = 2;
if (!(symbol->output_options & BARCODE_BIND)) {
symbol->output_options += BARCODE_BIND;
}
}
if (symbol->symbology == BARCODE_ITF14) {
symbol->whitespace_width = 20;
symbol->border_width = 8;
if (!(symbol->output_options & BARCODE_BOX)) {
symbol->output_options += BARCODE_BOX;
}
}
switch (symbol->input_mode) {
case DATA_MODE:

View File

@ -180,7 +180,7 @@ int pcx_pixel_plot(struct zint_symbol *symbol, int image_height, int image_width
}
/* Open output file in binary mode */
if ((symbol->output_options & BARCODE_STDOUT) != 0) {
if (symbol->output_options & BARCODE_STDOUT) {
#ifdef _MSC_VER
if (-1 == _setmode(_fileno(stdout), _O_BINARY)) {
strcpy(symbol->errtxt, "Can't open output file");

View File

@ -131,7 +131,7 @@ int png_pixel_plot(struct zint_symbol *symbol, int image_height, int image_width
bgblu = (16 * ctoi(symbol->bgcolour[4])) + ctoi(symbol->bgcolour[5]);
/* Open output file in binary mode */
if ((symbol->output_options & BARCODE_STDOUT) != 0) {
if (symbol->output_options & BARCODE_STDOUT) {
#ifdef _MSC_VER
if (-1 == _setmode(_fileno(stdout), _O_BINARY)) {
strcpy(symbol->errtxt, "Can't open output file");

View File

@ -99,7 +99,7 @@ int ps_plot(struct zint_symbol *symbol) {
}
}
if ((symbol->output_options & BARCODE_STDOUT) != 0) {
if (symbol->output_options & BARCODE_STDOUT) {
feps = stdout;
} else {
feps = fopen(symbol->outfile, "w");
@ -848,7 +848,7 @@ int ps_plot(struct zint_symbol *symbol) {
/* Do nothing! (It's already been done) */
break;
default:
if ((symbol->output_options & BARCODE_BIND) != 0) {
if (symbol->output_options & BARCODE_BIND) {
if ((symbol->rows > 1) && (is_stackable(symbol->symbology) == 1)) {
/* row binding */
fprintf(feps, "TE\n");
@ -862,7 +862,7 @@ int ps_plot(struct zint_symbol *symbol) {
}
}
}
if (((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) {
if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) {
fprintf(feps, "TE\n");
if ((symbol->output_options & CMYK_COLOUR) == 0) {
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
@ -872,7 +872,7 @@ int ps_plot(struct zint_symbol *symbol) {
fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n", symbol->border_width * scaler, textoffset * scaler, 0.0, (symbol->width + xoffset + xoffset) * scaler);
fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n", symbol->border_width * scaler, (textoffset + symbol->height + symbol->border_width) * scaler, 0.0, (symbol->width + xoffset + xoffset) * scaler);
}
if ((symbol->output_options & BARCODE_BOX) != 0) {
if (symbol->output_options & BARCODE_BOX) {
/* side bars */
fprintf(feps, "TE\n");
if ((symbol->output_options & CMYK_COLOUR) == 0) {

View File

@ -292,7 +292,7 @@ int plot_raster_maxicode(struct zint_symbol *symbol, int rotate_angle, int data_
image_height = 300 + (2 * yoffset * 2);
if (!(pixelbuf = (char *) malloc(image_width * image_height))) {
printf("Insifficient memory for pixel buffer");
printf("Insufficient memory for pixel buffer");
return ZINT_ERROR_ENCODING_PROBLEM;
} else {
for (i = 0; i < (image_width * image_height); i++) {
@ -319,13 +319,13 @@ int plot_raster_maxicode(struct zint_symbol *symbol, int rotate_angle, int data_
}
}
if (((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) {
if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) {
/* boundary bars */
draw_bar(pixelbuf, 0, image_width, 0, symbol->border_width * 2, image_width, image_height);
draw_bar(pixelbuf, 0, image_width, 300 + (symbol->border_width * 2), symbol->border_width * 2, image_width, image_height);
}
if ((symbol->output_options & BARCODE_BOX) != 0) {
if (symbol->output_options & BARCODE_BOX) {
/* side bars */
draw_bar(pixelbuf, 0, symbol->border_width * 2, 0, image_height, image_width, image_height);
draw_bar(pixelbuf, 300 + ((symbol->border_width + symbol->whitespace_width + symbol->whitespace_width) * 2), symbol->border_width * 2, 0, image_height, image_width, image_height);
@ -619,7 +619,7 @@ int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int data_t
}
}
if (((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) {
if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) {
default_text_posn = image_height - 17;
} else {
default_text_posn = image_height - 17 - symbol->border_width - symbol->border_width;
@ -867,7 +867,7 @@ int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int data_t
xoffset -= comp_offset;
/* Put boundary bars or box around symbol */
if (((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) {
if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) {
/* boundary bars */
draw_bar(pixelbuf, 0, (symbol->width + xoffset + xoffset) * 2, textoffset * 2, symbol->border_width * 2, image_width, image_height);
draw_bar(pixelbuf, 0, (symbol->width + xoffset + xoffset) * 2, (textoffset + symbol->height + symbol->border_width) * 2, symbol->border_width * 2, image_width, image_height);
@ -881,7 +881,7 @@ int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int data_t
}
}
if ((symbol->output_options & BARCODE_BOX) != 0) {
if (symbol->output_options & BARCODE_BOX) {
/* side bars */
draw_bar(pixelbuf, 0, symbol->border_width * 2, textoffset * 2, (symbol->height + (2 * symbol->border_width)) * 2, image_width, image_height);
draw_bar(pixelbuf, (symbol->width + xoffset + xoffset - symbol->border_width) * 2, symbol->border_width * 2, textoffset * 2, (symbol->height + (2 * symbol->border_width)) * 2, image_width, image_height);
@ -931,7 +931,7 @@ int plot_raster(struct zint_symbol *symbol, int rotate_angle, int file_type) {
}
#endif /* NO_PNG */
if (symbol->output_options &= BARCODE_DOTTY_MODE) {
if (symbol->output_options & BARCODE_DOTTY_MODE) {
error = plot_raster_dotty(symbol, rotate_angle, file_type);
} else {
if (symbol->symbology == BARCODE_MAXICODE) {

View File

@ -248,7 +248,7 @@ int render_plot(struct zint_symbol *symbol, const float width, const float heigh
}
large_bar_height = (symbol->height - preset_height) / large_bar_count;
if (((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) {
if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) {
default_text_posn = (symbol->height + text_offset + symbol->border_width + symbol->border_width) * scaler;
} else {
default_text_posn = (symbol->height + text_offset + symbol->border_width) * scaler;
@ -643,13 +643,13 @@ int render_plot(struct zint_symbol *symbol, const float width, const float heigh
}
}
}
if (((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) {
if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) {
line = render_plot_create_line(0, 0, (symbol->width + xoffset + xoffset) * scaler, symbol->border_width * scaler);
render_plot_add_line(symbol, line, &last_line);
line = render_plot_create_line(0, (symbol->height + symbol->border_width) * scaler, (symbol->width + xoffset + xoffset) * scaler, symbol->border_width * scaler);
render_plot_add_line(symbol, line, &last_line);
}
if ((symbol->output_options & BARCODE_BOX) != 0) {
if (symbol->output_options & BARCODE_BOX) {
/* side bars */
line = render_plot_create_line(0, 0, symbol->border_width * scaler, (symbol->height + (2 * symbol->border_width)) * scaler);
render_plot_add_line(symbol, line, &last_line);

View File

@ -95,7 +95,7 @@ int svg_plot(struct zint_symbol *symbol) {
}
}
if ((symbol->output_options & BARCODE_STDOUT) != 0) {
if (symbol->output_options & BARCODE_STDOUT) {
fsvg = stdout;
} else {
fsvg = fopen(symbol->outfile, "w");
@ -230,7 +230,7 @@ int svg_plot(struct zint_symbol *symbol) {
fprintf(fsvg, " <rect x=\"0\" y=\"0\" width=\"%d\" height=\"%d\" fill=\"#%s\" />\n", (int)ceil((74.0F + xoffset + xoffset) * scaler), (int)ceil((72.0F + yoffset + yoffset) * scaler), symbol->bgcolour);
}
if (((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) {
if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) {
default_text_posn = (symbol->height + textoffset + symbol->border_width + symbol->border_width) * scaler;
} else {
default_text_posn = (symbol->height + textoffset + symbol->border_width) * scaler;
@ -242,11 +242,11 @@ int svg_plot(struct zint_symbol *symbol) {
textoffset = 0.0;
if (((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) {
if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) {
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", 0.0, 0.0, (74.0 + xoffset + xoffset) * scaler, symbol->border_width * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", 0.0, (72.0 + symbol->border_width) * scaler, (74.0 + xoffset + xoffset) * scaler, symbol->border_width * scaler);
}
if ((symbol->output_options & BARCODE_BOX) != 0) {
if (symbol->output_options & BARCODE_BOX) {
/* side bars */
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", 0.0, 0.0, symbol->border_width * scaler, (72.0 + (2 * symbol->border_width)) * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (74.0 + xoffset + xoffset - symbol->border_width) * scaler, 0.0, symbol->border_width * scaler, (72.0 + (2 * symbol->border_width)) * scaler);
@ -307,7 +307,7 @@ int svg_plot(struct zint_symbol *symbol) {
}
row_posn += yoffset;
if ((symbol->output_options & BARCODE_DOTTY_MODE) != 0) {
if (symbol->output_options & BARCODE_DOTTY_MODE) {
/* Use (currently undocumented) dot mode - see SF ticket #29 */
for (i = 0; i < symbol->width; i++) {
if (module_is_set(symbol, this_row, i)) {
@ -609,7 +609,7 @@ int svg_plot(struct zint_symbol *symbol) {
/* Do nothing! (It's already been done) */
break;
default:
if ((symbol->output_options & BARCODE_BIND) != 0) {
if (symbol->output_options & BARCODE_BIND) {
if ((symbol->rows > 1) && (is_stackable(symbol->symbology) == 1)) {
/* row binding */
for (r = 1; r < symbol->rows; r++) {
@ -617,11 +617,11 @@ int svg_plot(struct zint_symbol *symbol) {
}
}
}
if (((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) {
if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) {
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", 0.0, 0.0, (symbol->width + xoffset + xoffset) * scaler, symbol->border_width * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", 0.0, (symbol->height + symbol->border_width) * scaler, (symbol->width + xoffset + xoffset) * scaler, symbol->border_width * scaler);
}
if ((symbol->output_options & BARCODE_BOX) != 0) {
if (symbol->output_options & BARCODE_BOX) {
/* side bars */
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", 0.0, 0.0, symbol->border_width * scaler, (symbol->height + (2 * symbol->border_width)) * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (symbol->width + xoffset + xoffset - symbol->border_width) * scaler, 0.0, symbol->border_width * scaler, (symbol->height + (2 * symbol->border_width)) * scaler);

View File

@ -331,7 +331,7 @@ namespace Zint {
gwidth *= (maxi_width + 1);
}
if (m_zintSymbol->output_options &= BARCODE_DOTTY_MODE) {
if (m_zintSymbol->output_options & BARCODE_DOTTY_MODE) {
gwidth += 2.0;
gheight += 2.0;
}
@ -476,7 +476,7 @@ namespace Zint {
painter.drawEllipse(QPointF(14.5 * w, 16.5 * w * 0.868), w + w * 1.5, w + w * 1.5);
painter.drawEllipse(QPointF(14.5 * w, 16.5 * w * 0.868), w + w * 3, w + w * 3);
painter.restore();
} else if (m_zintSymbol->output_options &= BARCODE_DOTTY_MODE) {
} else if (m_zintSymbol->output_options & BARCODE_DOTTY_MODE) {
/* Draw with dots (circles) */
p.setColor(m_fgColor);