mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
raster.c: fix possible blank rows appearing in CODE16K, CODE49, PHARMA_TWO,
PDF417 & CODABLOCKF due to height/scale rounding by changing out_large_bar_height() to return scaled int values for raster, props codemonkey82 (#204) raster/vector.c: const some vars vector.c: rect_count, last_start_row UPC/EAN only library.c: check for stacking symbols >= 200
This commit is contained in:
parent
4e72a541f7
commit
f7ad0ed1e3
@ -46,9 +46,7 @@ Bugs
|
||||
- vector.c: enforce minimum scale >= 0.1 and allow in GUI
|
||||
- Suppress some pedantic warnings, props codemonkey82 (#204)
|
||||
- gs1.c: Allow 0-length AI data if GS1NOCHECK_MODE, props codemonkey82 (#204)
|
||||
- raster.c: Need ceilf(symbol->height * si) to avoid heap-buffer-overflow;
|
||||
also ceilf(large_bar_height * si);
|
||||
also avoid distributive multiplication with floats to lessen chances of
|
||||
- raster.c: avoid distributive multiplication with floats to lessen chances of
|
||||
platform variation (#204 ARM-Cortex crash)
|
||||
- common/emf/output/raster/vector.c: use new stripf() func to workaround
|
||||
float variations
|
||||
@ -56,6 +54,9 @@ Bugs
|
||||
- ISBNX: fix not returning error number (warning) correctly
|
||||
- *.rc: fix VER_FILEVERSION_STR format (, -> .), props Jeff Skaistis
|
||||
- PDF417: fix cols/rows calculation to require multiple <= 928 codewords
|
||||
- raster.c: fix possible blank rows appearing in CODE16K, CODE49, PHARMA_TWO,
|
||||
PDF417 & CODABLOCKF due to height/scale rounding, props codemonkey82 (#204)
|
||||
- library.c: check for stacking symbols >= 200
|
||||
|
||||
|
||||
Version 2.10.0 2021-08-14
|
||||
|
@ -908,6 +908,10 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
|
||||
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "768: Border width out of range (0 to 100)");
|
||||
}
|
||||
|
||||
if (symbol->rows >= 200) { /* Check for stacking too many symbols */
|
||||
return error_tag(symbol, ZINT_ERROR_TOO_LONG, "770: Too many stacked symbols");
|
||||
}
|
||||
|
||||
if ((symbol->input_mode & 0x07) > 2) {
|
||||
symbol->input_mode = DATA_MODE; /* Reset completely TODO: in future, warn/error */
|
||||
}
|
||||
|
@ -30,6 +30,7 @@
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include "common.h"
|
||||
#include "output.h"
|
||||
@ -589,17 +590,18 @@ INTERNAL int out_process_upcean(const struct zint_symbol *symbol, int *p_main_wi
|
||||
/* 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) {
|
||||
INTERNAL float out_large_bar_height(struct zint_symbol *symbol, int si, int *row_heights_si, int *symbol_height_si) {
|
||||
float fixed_height = 0.0f;
|
||||
int zero_count = 0;
|
||||
int round_rows = 0;
|
||||
int i;
|
||||
float large_bar_height;
|
||||
float large_bar_height = 0.0f; /* Not used if zero_count zero */
|
||||
|
||||
if (si) {
|
||||
for (i = 0; i < symbol->rows; i++) {
|
||||
if (symbol->row_height[i]) {
|
||||
fixed_height += symbol->row_height[i];
|
||||
if (!round_rows && si && !isfintf(symbol->row_height[i] * si)) {
|
||||
if (!round_rows && !isfintf(symbol->row_height[i] * si)) {
|
||||
round_rows = 1;
|
||||
}
|
||||
} else {
|
||||
@ -609,25 +611,49 @@ INTERNAL float out_large_bar_height(struct zint_symbol *symbol, int si) {
|
||||
|
||||
if (zero_count) {
|
||||
large_bar_height = stripf((symbol->height - fixed_height) / zero_count);
|
||||
if (large_bar_height <= 0.0f) { /* Shouldn't happen but protect against memory access violations */
|
||||
large_bar_height = 0.0078125f; /* Token positive value (exact float 2**-6) */
|
||||
}
|
||||
if (si && !isfintf(large_bar_height * si)) {
|
||||
assert(large_bar_height >= 0.5f); /* Min row height as set by `set_height()` */
|
||||
if (!isfintf(large_bar_height * si)) {
|
||||
large_bar_height = stripf(roundf(large_bar_height * si) / si);
|
||||
}
|
||||
symbol->height = stripf(large_bar_height * zero_count + fixed_height);
|
||||
/* Note should never happen that have both zero_count and round_rows */
|
||||
} else {
|
||||
large_bar_height = 0.0f; /* Not used if zero_count zero */
|
||||
if (round_rows) {
|
||||
fixed_height = 0.0f;
|
||||
float total_height = 0.0f;
|
||||
for (i = 0; i < symbol->rows; i++) {
|
||||
if (!isfintf(symbol->row_height[i] * si)) {
|
||||
symbol->row_height[i] = roundf(symbol->row_height[i] * si) / si;
|
||||
}
|
||||
fixed_height += symbol->row_height[i];
|
||||
total_height += symbol->row_height[i];
|
||||
}
|
||||
symbol->height = stripf(fixed_height);
|
||||
symbol->height = stripf(total_height);
|
||||
}
|
||||
}
|
||||
|
||||
if (row_heights_si) {
|
||||
assert(symbol_height_si);
|
||||
*symbol_height_si = 0;
|
||||
for (i = 0; i < symbol->rows; i++) {
|
||||
if (symbol->row_height[i]) {
|
||||
row_heights_si[i] = (int) roundf(symbol->row_height[i] * si);
|
||||
} else {
|
||||
row_heights_si[i] = (int) roundf(large_bar_height * si);
|
||||
}
|
||||
*symbol_height_si += row_heights_si[i];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < symbol->rows; i++) {
|
||||
if (symbol->row_height[i]) {
|
||||
fixed_height += symbol->row_height[i];
|
||||
} else {
|
||||
zero_count++;
|
||||
}
|
||||
}
|
||||
if (zero_count) {
|
||||
large_bar_height = stripf((symbol->height - fixed_height) / zero_count);
|
||||
assert(large_bar_height >= 0.5f); /* Min row height as set by `set_height()` */
|
||||
symbol->height = stripf(large_bar_height * zero_count + fixed_height);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,8 +30,8 @@
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
#ifndef OUTPUT_H
|
||||
#define OUTPUT_H
|
||||
#ifndef Z_OUTPUT_H
|
||||
#define Z_OUTPUT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -43,7 +43,7 @@ INTERNAL void out_set_whitespace_offsets(const struct zint_symbol *symbol, const
|
||||
int *xoffset_si, int *yoffset_si, int *roffset_si, int *boffset_si);
|
||||
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);
|
||||
INTERNAL float out_large_bar_height(struct zint_symbol *symbol, int si);
|
||||
INTERNAL float out_large_bar_height(struct zint_symbol *symbol, int si, int *row_heights_si, int *symbol_height_si);
|
||||
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 textpart4[2]);
|
||||
@ -52,4 +52,4 @@ INTERNAL void out_upcean_split_text(int upceanflag, unsigned char text[],
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* OUTPUT_H */
|
||||
#endif /* Z_OUTPUT_H */
|
||||
|
@ -904,7 +904,6 @@ static void to_iso8859_1(const unsigned char source[], unsigned char preprocesse
|
||||
|
||||
static int plot_raster_default(struct zint_symbol *symbol, const int rotate_angle, const int file_type) {
|
||||
int error_number;
|
||||
float large_bar_height;
|
||||
int main_width;
|
||||
int comp_xoffset = 0;
|
||||
unsigned char addon[6];
|
||||
@ -912,7 +911,6 @@ static int plot_raster_default(struct zint_symbol *symbol, const int rotate_angl
|
||||
float addon_text_yposn = 0.0f;
|
||||
float xoffset, yoffset, roffset, boffset;
|
||||
float textoffset;
|
||||
float yposn;
|
||||
int upceanflag = 0;
|
||||
int addon_latch = 0;
|
||||
unsigned char textpart1[5], textpart2[7], textpart3[7], textpart4[2];
|
||||
@ -926,12 +924,14 @@ static int plot_raster_default(struct zint_symbol *symbol, const int rotate_angl
|
||||
int textflags = 0;
|
||||
int xoffset_si, yoffset_si, roffset_si, boffset_si;
|
||||
int comp_xoffset_si;
|
||||
int row_heights_si[200];
|
||||
int symbol_height_si;
|
||||
int image_width, image_height;
|
||||
unsigned char *pixelbuf;
|
||||
float scaler = symbol->scale;
|
||||
int si;
|
||||
int half_int_scaling;
|
||||
int yposn_si;
|
||||
|
||||
/* Ignore scaling < 0.5 for raster as would drop modules */
|
||||
if (scaler < 0.5f) {
|
||||
@ -945,8 +945,7 @@ static int plot_raster_default(struct zint_symbol *symbol, const int rotate_angl
|
||||
si = 2;
|
||||
}
|
||||
|
||||
large_bar_height = out_large_bar_height(symbol, si /*Round to scale*/);
|
||||
symbol_height_si = (int) ceilf(symbol->height * si);
|
||||
(void) out_large_bar_height(symbol, si /*(scale and round)*/, row_heights_si, &symbol_height_si);
|
||||
|
||||
main_width = symbol->width;
|
||||
|
||||
@ -994,17 +993,15 @@ static int plot_raster_default(struct zint_symbol *symbol, const int rotate_angl
|
||||
}
|
||||
memset(pixelbuf, DEFAULT_PAPER, (size_t) image_width * image_height);
|
||||
|
||||
yposn = yoffset;
|
||||
yposn_si = yoffset_si;
|
||||
|
||||
/* Plot the body of the symbol to the pixel buffer */
|
||||
if (symbol->symbology == BARCODE_ULTRA) {
|
||||
for (r = 0; r < symbol->rows; r++) {
|
||||
int yposn_si = yposn * si;
|
||||
float row_height = symbol->row_height[r];
|
||||
int row_height_si = (int) ceilf(row_height * si);
|
||||
const int row_height_si = row_heights_si[r];
|
||||
|
||||
for (i = 0; i < symbol->width; i += block_width) {
|
||||
int fill = module_colour_is_set(symbol, r, i);
|
||||
const int fill = module_colour_is_set(symbol, r, i);
|
||||
for (block_width = 1; (i + block_width < symbol->width)
|
||||
&& module_colour_is_set(symbol, r, i + block_width) == fill; block_width++);
|
||||
if (fill) {
|
||||
@ -1015,33 +1012,32 @@ static int plot_raster_default(struct zint_symbol *symbol, const int rotate_angl
|
||||
}
|
||||
copy_bar_line(pixelbuf, xoffset_si, image_width - xoffset_si - roffset_si, yposn_si, row_height_si,
|
||||
image_width, image_height);
|
||||
yposn += row_height;
|
||||
yposn_si += row_height_si;
|
||||
}
|
||||
|
||||
} else if (upceanflag >= 6) { /* UPC-E, EAN-8, UPC-A, EAN-13 */
|
||||
for (r = 0; r < symbol->rows; r++) {
|
||||
int yposn_si = yposn * si;
|
||||
float row_height = symbol->row_height[r] ? symbol->row_height[r] : large_bar_height;
|
||||
int row_height_si = (int) ceilf(row_height * si);
|
||||
int row_height_si = row_heights_si[r];
|
||||
|
||||
for (i = 0; i < symbol->width; i += block_width) {
|
||||
int fill = module_is_set(symbol, r, i);
|
||||
const int fill = module_is_set(symbol, r, i);
|
||||
for (block_width = 1; (i + block_width < symbol->width)
|
||||
&& module_is_set(symbol, r, i + block_width) == fill; block_width++);
|
||||
if ((r == (symbol->rows - 1)) && (i > main_width) && (addon_latch == 0)) {
|
||||
float addon_row_height;
|
||||
int addon_row_height_si;
|
||||
const int text_offset_si = (text_height + text_gap) * si;
|
||||
copy_bar_line(pixelbuf, xoffset_si, main_width * si, yposn_si, row_height_si, image_width,
|
||||
image_height);
|
||||
yposn_si += (text_height + text_gap) * si;
|
||||
addon_text_yposn = yposn * si;
|
||||
addon_row_height = row_height - (text_height + text_gap);
|
||||
addon_text_yposn = yposn_si;
|
||||
yposn_si += text_offset_si;
|
||||
addon_row_height_si = row_height_si - text_offset_si;
|
||||
if (upceanflag != 12 && upceanflag != 6) { /* UPC-A/E add-ons don't descend */
|
||||
addon_row_height += guard_descent;
|
||||
addon_row_height_si += guard_descent * si;
|
||||
}
|
||||
if (addon_row_height < 0.5f) {
|
||||
addon_row_height = 0.5f;
|
||||
if (addon_row_height_si == 0) {
|
||||
addon_row_height_si = 1;
|
||||
}
|
||||
row_height_si = addon_row_height * si;
|
||||
row_height_si = addon_row_height_si;
|
||||
addon_latch = 1;
|
||||
}
|
||||
if (fill) {
|
||||
@ -1058,17 +1054,15 @@ static int plot_raster_default(struct zint_symbol *symbol, const int rotate_angl
|
||||
copy_bar_line(pixelbuf, xoffset_si, image_width - xoffset_si - roffset_si, yposn_si, row_height_si,
|
||||
image_width, image_height);
|
||||
}
|
||||
yposn += row_height;
|
||||
yposn_si += row_height_si;
|
||||
}
|
||||
|
||||
} else {
|
||||
for (r = 0; r < symbol->rows; r++) {
|
||||
int yposn_si = yposn * si;
|
||||
float row_height = symbol->row_height[r] ? symbol->row_height[r] : large_bar_height;
|
||||
int row_height_si = (int) ceilf(row_height * si);
|
||||
const int row_height_si = row_heights_si[r];
|
||||
|
||||
for (i = 0; i < symbol->width; i += block_width) {
|
||||
int fill = module_is_set(symbol, r, i);
|
||||
const int fill = module_is_set(symbol, r, i);
|
||||
for (block_width = 1; (i + block_width < symbol->width)
|
||||
&& module_is_set(symbol, r, i + block_width) == fill; block_width++);
|
||||
if (fill) {
|
||||
@ -1079,14 +1073,14 @@ static int plot_raster_default(struct zint_symbol *symbol, const int rotate_angl
|
||||
}
|
||||
copy_bar_line(pixelbuf, xoffset_si, image_width - xoffset_si - roffset_si, yposn_si, row_height_si,
|
||||
image_width, image_height);
|
||||
yposn += row_height;
|
||||
yposn_si += row_height_si;
|
||||
}
|
||||
}
|
||||
|
||||
if (guard_descent && upceanflag >= 6) { /* UPC-E, EAN-8, UPC-A, EAN-13 */
|
||||
/* Guard bar extension */
|
||||
int guard_yoffset_si = yoffset_si + symbol_height_si;
|
||||
int guard_descent_si = guard_descent * si;
|
||||
const int guard_yoffset_si = yoffset_si + symbol_height_si;
|
||||
const int guard_descent_si = guard_descent * si;
|
||||
|
||||
if (upceanflag == 6) { /* UPC-E */
|
||||
draw_bar_line(pixelbuf, 0 * si + comp_xoffset_si, 1 * si, guard_yoffset_si, image_width, DEFAULT_INK);
|
||||
@ -1105,7 +1099,7 @@ static int plot_raster_default(struct zint_symbol *symbol, const int rotate_angl
|
||||
|
||||
} else if (upceanflag == 12) { /* UPC-A */
|
||||
for (i = 0 + comp_xoffset; i < 11 + comp_xoffset; i += block_width) {
|
||||
int fill = module_is_set(symbol, symbol->rows - 1, i);
|
||||
const int fill = module_is_set(symbol, symbol->rows - 1, i);
|
||||
for (block_width = 1; (i + block_width < symbol->width)
|
||||
&& module_is_set(symbol, symbol->rows - 1, i + block_width) == fill;
|
||||
block_width++);
|
||||
@ -1117,7 +1111,7 @@ static int plot_raster_default(struct zint_symbol *symbol, const int rotate_angl
|
||||
draw_bar_line(pixelbuf, 46 * si + comp_xoffset_si, 1 * si, guard_yoffset_si, image_width, DEFAULT_INK);
|
||||
draw_bar_line(pixelbuf, 48 * si + comp_xoffset_si, 1 * si, guard_yoffset_si, image_width, DEFAULT_INK);
|
||||
for (i = 85 + comp_xoffset; i < 96 + comp_xoffset; i += block_width) {
|
||||
int fill = module_is_set(symbol, symbol->rows - 1, i);
|
||||
const int fill = module_is_set(symbol, symbol->rows - 1, i);
|
||||
for (block_width = 1; (i + block_width < symbol->width)
|
||||
&& module_is_set(symbol, symbol->rows - 1, i + block_width) == fill;
|
||||
block_width++);
|
||||
@ -1152,10 +1146,10 @@ static int plot_raster_default(struct zint_symbol *symbol, const int rotate_angl
|
||||
/* Note font sizes halved as in pixels */
|
||||
|
||||
/* Halved again to get middle position that draw_string() expects */
|
||||
int upcea_width_adj = (UPCEAN_SMALL_FONT_WIDTH + 3) / 4;
|
||||
int upcea_height_adj = (UPCEAN_FONT_HEIGHT - UPCEAN_SMALL_FONT_HEIGHT) * si / 2;
|
||||
const int upcea_width_adj = (UPCEAN_SMALL_FONT_WIDTH + 3) / 4;
|
||||
const int upcea_height_adj = (UPCEAN_FONT_HEIGHT - UPCEAN_SMALL_FONT_HEIGHT) * si / 2;
|
||||
/* Halved again to get middle position that draw_string() expects */
|
||||
int ean_width_adj = (UPCEAN_FONT_WIDTH + 3) / 4;
|
||||
const int ean_width_adj = (UPCEAN_FONT_WIDTH + 3) / 4;
|
||||
|
||||
out_upcean_split_text(upceanflag, symbol->text, textpart1, textpart2, textpart3, textpart4);
|
||||
|
||||
@ -1263,16 +1257,16 @@ static int plot_raster_default(struct zint_symbol *symbol, const int rotate_angl
|
||||
sep_height = symbol->option_3;
|
||||
}
|
||||
sep_height_si = (int) (sep_height * si);
|
||||
sep_yoffset_si = yoffset_si - sep_height_si / 2;
|
||||
sep_yoffset_si = yoffset_si + row_heights_si[0] - sep_height_si / 2;
|
||||
if (symbol->symbology == BARCODE_CODABLOCKF || symbol->symbology == BARCODE_HIBC_BLOCKF) {
|
||||
/* Avoid 11-module start and 13-module stop chars */
|
||||
sep_xoffset_si += 11 * si;
|
||||
sep_width_si -= (11 + 13) * si;
|
||||
}
|
||||
for (r = 1; r < symbol->rows; r++) {
|
||||
float row_height = symbol->row_height[r - 1] ? symbol->row_height[r - 1] : large_bar_height;
|
||||
draw_bar(pixelbuf, sep_xoffset_si, sep_width_si, (r * row_height) * si + sep_yoffset_si, sep_height_si,
|
||||
image_width, image_height, DEFAULT_INK);
|
||||
draw_bar(pixelbuf, sep_xoffset_si, sep_width_si, sep_yoffset_si, sep_height_si, image_width, image_height,
|
||||
DEFAULT_INK);
|
||||
sep_yoffset_si += row_heights_si[r];
|
||||
}
|
||||
}
|
||||
|
||||
@ -1282,8 +1276,8 @@ static int plot_raster_default(struct zint_symbol *symbol, const int rotate_angl
|
||||
if (!half_int_scaling) {
|
||||
size_t prev_image_row;
|
||||
unsigned char *scaled_pixelbuf;
|
||||
int scale_width = (int) stripf(image_width * scaler);
|
||||
int scale_height = (int) stripf(image_height * scaler);
|
||||
const int scale_width = (int) stripf(image_width * scaler);
|
||||
const int scale_height = (int) stripf(image_height * scaler);
|
||||
|
||||
/* Apply scale options by creating another pixel buffer */
|
||||
if (!(scaled_pixelbuf = (unsigned char *) malloc((size_t) scale_width * scale_height))) {
|
||||
|
BIN
backend/tests/data/png/pdf417_#204.png
Normal file
BIN
backend/tests/data/png/pdf417_#204.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 788 B |
@ -197,6 +197,7 @@ static void test_print(int index, int generate, int debug) {
|
||||
/* 53*/ { BARCODE_PDF417, -1, -1, -1, -1, -1, -1, -1, -1, 5.0, 0, { 0, 0, "" }, "", "", "Your Data Here!", "", ZINT_WARN_NONCOMPLIANT, "pdf417_height5.png", "" },
|
||||
/* 54*/ { BARCODE_USPS_IMAIL, -1, -1, -1, -1, -1, -1, -1, -1, 7.75, 0, { 0, 0, "" }, "", "", "12345678901234567890", "", 0, "imail_height7.75.png", "" },
|
||||
/* 55*/ { BARCODE_AZTEC, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, { 4, 7, "Z1.txt" }, "", "", "3456", "", 0, "aztec_z1_seq4of7.png", "" },
|
||||
/* 56*/ { 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" },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -393,7 +393,6 @@ static void vector_reduce_rectangles(struct zint_symbol *symbol) {
|
||||
|
||||
INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_type) {
|
||||
int error_number;
|
||||
float large_bar_height;
|
||||
int main_width;
|
||||
int comp_xoffset = 0;
|
||||
unsigned char addon[6];
|
||||
@ -401,7 +400,6 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
|
||||
float addon_text_yposn = 0.0f;
|
||||
float xoffset, yoffset, roffset, boffset;
|
||||
float textoffset;
|
||||
float yposn;
|
||||
int upceanflag = 0;
|
||||
int addon_latch = 0;
|
||||
unsigned char textpart1[5], textpart2[7], textpart3[7], textpart4[2];
|
||||
@ -412,11 +410,13 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
|
||||
float text_gap; /* Gap between barcode and text */
|
||||
float guard_descent;
|
||||
|
||||
float large_bar_height;
|
||||
int upcae_outside_text_height = 0; /* UPC-A/E outside digits font size */
|
||||
float digit_ascent_factor = 0.25f; /* Assuming digit ascent roughly 25% less than font size */
|
||||
float dot_overspill = 0.0f;
|
||||
float dot_offset = 0.0f;
|
||||
int rect_count = 0, last_row_start = 0;
|
||||
int rect_count = 0, last_row_start = 0; /* For UPC/EAN guard bars */
|
||||
float yposn;
|
||||
|
||||
struct zint_vector *vector;
|
||||
struct zint_vector_rect *rect, *last_rectangle = NULL;
|
||||
@ -444,7 +444,8 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
|
||||
vector->circles = NULL;
|
||||
vector->strings = NULL;
|
||||
|
||||
large_bar_height = out_large_bar_height(symbol, 0 /*No rounding to scale*/);
|
||||
large_bar_height = out_large_bar_height(symbol, 0 /*si (scale and round)*/, NULL /*row_heights_si*/,
|
||||
NULL /*symbol_height_si*/);
|
||||
|
||||
main_width = symbol->width;
|
||||
|
||||
@ -568,11 +569,10 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
|
||||
} else if (symbol->symbology == BARCODE_ULTRA) {
|
||||
yposn = yoffset;
|
||||
for (r = 0; r < symbol->rows; r++) {
|
||||
float row_height = symbol->row_height[r];
|
||||
last_row_start = rect_count;
|
||||
const float row_height = symbol->row_height[r];
|
||||
|
||||
for (i = 0; i < symbol->width; i += block_width) {
|
||||
int fill = module_colour_is_set(symbol, r, i);
|
||||
const int fill = module_colour_is_set(symbol, r, i);
|
||||
for (block_width = 1; (i + block_width < symbol->width)
|
||||
&& module_colour_is_set(symbol, r, i + block_width) == fill; block_width++);
|
||||
if (fill) {
|
||||
@ -581,7 +581,6 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
|
||||
if (!rect) return ZINT_ERROR_MEMORY;
|
||||
rect->colour = module_colour_is_set(symbol, r, i);
|
||||
vector_plot_add_rect(symbol, rect, &last_rectangle);
|
||||
rect_count++;
|
||||
}
|
||||
}
|
||||
yposn += row_height;
|
||||
@ -590,12 +589,12 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
|
||||
} else if (upceanflag >= 6) { /* UPC-E, EAN-8, UPC-A, EAN-13 */
|
||||
yposn = yoffset;
|
||||
for (r = 0; r < symbol->rows; r++) {
|
||||
float row_height = symbol->row_height[r] ? symbol->row_height[r] : large_bar_height;
|
||||
const float row_height = symbol->row_height[r] ? symbol->row_height[r] : large_bar_height;
|
||||
last_row_start = rect_count;
|
||||
|
||||
for (i = 0; i < symbol->width; i += block_width) {
|
||||
float addon_row_height;
|
||||
int fill = module_is_set(symbol, r, i);
|
||||
const int fill = module_is_set(symbol, r, i);
|
||||
for (block_width = 1; (i + block_width < symbol->width)
|
||||
&& module_is_set(symbol, r, i + block_width) == fill; block_width++);
|
||||
|
||||
@ -632,11 +631,10 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
|
||||
} else {
|
||||
yposn = yoffset;
|
||||
for (r = 0; r < symbol->rows; r++) {
|
||||
float row_height = symbol->row_height[r] ? symbol->row_height[r] : large_bar_height;
|
||||
last_row_start = rect_count;
|
||||
const float row_height = symbol->row_height[r] ? symbol->row_height[r] : large_bar_height;
|
||||
|
||||
for (i = 0; i < symbol->width; i += block_width) {
|
||||
int fill = module_is_set(symbol, r, i);
|
||||
const int fill = module_is_set(symbol, r, i);
|
||||
for (block_width = 1; (i + block_width < symbol->width)
|
||||
&& module_is_set(symbol, r, i + block_width) == fill; block_width++);
|
||||
if (fill) {
|
||||
@ -644,7 +642,6 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
|
||||
rect = vector_plot_create_rect(symbol, i + xoffset, yposn, block_width, row_height);
|
||||
if (!rect) return ZINT_ERROR_MEMORY;
|
||||
vector_plot_add_rect(symbol, rect, &last_rectangle);
|
||||
rect_count++;
|
||||
}
|
||||
}
|
||||
yposn += row_height;
|
||||
@ -872,7 +869,7 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
|
||||
sep_width -= 11 + 13;
|
||||
}
|
||||
for (r = 1; r < symbol->rows; r++) {
|
||||
float row_height = symbol->row_height[r - 1] ? symbol->row_height[r - 1] : large_bar_height;
|
||||
const float row_height = symbol->row_height[r - 1] ? symbol->row_height[r - 1] : large_bar_height;
|
||||
rect = vector_plot_create_rect(symbol, sep_xoffset, (r * row_height) + sep_yoffset,
|
||||
sep_width, sep_height);
|
||||
if (!rect) return ZINT_ERROR_MEMORY;
|
||||
@ -908,9 +905,9 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
|
||||
vector_plot_add_rect(symbol, rect, &last_rectangle);
|
||||
}
|
||||
if (symbol->output_options & BARCODE_BOX) {
|
||||
float xbox_right = vector->width - symbol->border_width;
|
||||
const float xbox_right = vector->width - symbol->border_width;
|
||||
// Following equivalent to symbol->height except for BARCODE_MAXICODE
|
||||
float box_height = vector->height - textoffset - dot_overspill - yoffset - boffset;
|
||||
const float box_height = vector->height - textoffset - dot_overspill - yoffset - boffset;
|
||||
// Left
|
||||
rect = vector_plot_create_rect(symbol, 0.0f, yoffset, symbol->border_width, box_height);
|
||||
if (!rect) return ZINT_ERROR_MEMORY;
|
||||
|
Loading…
Reference in New Issue
Block a user