mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
- API: add new zint_symbol dpmm
field for output resolution (BMP/
EMF/PCX/PNG/TIF only, i.e. excluding EPS, GIF & SVG) - Add support for specifying scale by X-dimension and resolution with new option `--scalexdimdp` for CLI/Tcl & new API function `ZBarcode_Scale_From_XdimDp()` (+ `ZBarcode_XdimDp_From_Scale()` & `ZBarcode_Default_Xdim()`) and new GUI popup; manual: document - BMP/EMF/PCX/PNG/TIF: use new `dpmm` resolution field (for EMF following Inkscape) - backend_qt: add `dpmm()`, `vectorWidth()`, `vectorHeight()`, `noPng()`, `getVersion()`, `takesGS1AIData()`, & `XdimDp` stuff incl. new `QZintXdimDp` struct for passing around scale vars & use in `getAsCLI()`; add comments - Raise `scale` limit to 200 (from 100) to allow for large dpmm - output: create directories & subdirectories as necessary for output path using new function `out_fopen()` and use in BMP/EMF/ EPS/GIF/PCX/PNG/SVG/TIF - DPLEIT/DPIDENT: format HRT according to (incomplete) documentation, and set default height to 72X (from 50X) - CODE128B renamed to CODE128AB as can use subsets A and/or B - CODABAR: fix minimum height calc - EMF: fix indexing of handles (zero-based not 1-based) - GUI: fix symbology zap (previous technique of clearing and re-loading settings without doing a sync no longer works); fix UPCEAN guard descent enable - MAILMARK: better error message if input < 14 characters - GUI: add "Default" button for DAFT tracker ratio & enable/disable various default buttons; use new `takesGS1AIData()` to enable/disable GS1-specific checkboxes - CLI: use new `validate_float()` to parse float options (7 significant digits allowed only, no scientific notation) - DATAMATRIX/GRIDMATRIX/PDF417/QR/ULTRA: micro-optimize structapp ID parse - library/CLI: fiddle with static asserts (make CHAR_BIT sensitive, supposedly) - win32/README: update building libpng (assembly removed) - README.linux: document incompatibility of Qt6 >= 6.3 - manual: expand Barcode Studio waffle - test suite: change range separator to hyphen and allow multiple excludes
This commit is contained in:
ChangeLogREADME.linux
backend
2of5.cbmp.ccodablock.ccode128.ccommon.cdmatrix.cemf.cgif.cgridmtx.clibrary.cmailmark.cmedical.coutput.coutput.hpcx.cpdf417.cpng.cps.cqr.craster.csvg.c
tests
READMEtest_2of5.ctest_bmp.ctest_code128.ctest_eci.ctest_emf.ctest_gif.ctest_library.ctest_mailmark.ctest_output.ctest_pcx.ctest_png.ctest_print.ctest_ps.ctest_qr.ctest_raster.ctest_svg.ctest_tif.ctest_vector.ctestcommon.ctestcommon.h
tif.cultra.czint.hdata
emf
code128_egrave_bold.emfcode128_egrave_bold_100dpi.emfcode128_egrave_bold_1200dpi.emfcode128_egrave_bold_150dpi.emfcode128_egrave_bold_300dpi.emfcode128_egrave_bold_400dpi.emfcode39_rotate_180.emfcode39_rotate_270.emfcode39_rotate_90.emfcode39_rotate_90_300dpi.emfean13_5addon_#185.emfean13_5addon_ggs_5.2.2.5.2-2.emfitf14_bold.emfitf14_bold_600dpi.emfmaxicode_#185.emfmaxicode_#185_150dpi.emfmaxicode_#185_600dpi.emfmaxicode_rotate_90_nobg.emfmaxicode_rotate_90_nobg_300dpi.emftelenum_fg_bg.emftelenum_fg_bg_150dpi.emfultracode_fg_bg.emfultracode_fg_bg_box2.emfultracode_fg_bg_box2_600dpi.emfupca_2addon_ggs_5.2.6.6-5.emfupce_2addon.emfupce_2addon_150dpi.emfupce_2addon_small_bold.emf
print
backend_qt
backend_tcl
docs
Makefile
images
code128ab.svgdpident.svgdpleit.svggui_appearance.pnggui_black_eye.pnggui_delete.pnggui_scaling.pnggui_set_printing_scale.pnggui_swap.pnggui_white_eye.pnggui_zap.png
manual.pmdmanual.txtzint.1zint.1.pmdzint_images.shfrontend
frontend_qt
CMakeLists.txtcliwindow.cppcliwindow.hextData.uiextExport.uiextScale.uifrontend_qt.profrontend_qt_zintdll.profrontend_vc8.progrpDAFT.uigrpUPCA.uigrpUPCEAN.uimainWindow.uimainwindow.cppmainwindow.h
res
resources.qrcscalewindow.cppscalewindow.hwin32
@ -207,7 +207,7 @@ static int c25_inter_common(struct zint_symbol *symbol, unsigned char source[],
|
||||
/* ISO/IEC 16390:2007 Section 4.4 min height 5mm or 15% of symbol width whichever greater where
|
||||
(P = character pairs, N = wide/narrow ratio = 3)
|
||||
width = (P(4N + 6) + N + 6)X = (length / 2) * 18 + 9 */
|
||||
/* Taking X = 0.330mm from Annex D.3.1 (application specification) */
|
||||
/* Taking min X = 0.330mm from Annex D.3.1 (application specification) */
|
||||
const float min_height_min = stripf(5.0f / 0.33f);
|
||||
float min_height = stripf((18.0f * (length / 2) + 9.0f) * 0.15f);
|
||||
if (min_height < min_height_min) {
|
||||
@ -281,8 +281,11 @@ INTERNAL int itf14(struct zint_symbol *symbol, unsigned char source[], int lengt
|
||||
}
|
||||
|
||||
/* Deutsche Post Leitcode */
|
||||
/* Documentation (of a very incomplete and non-technical type):
|
||||
https://www.deutschepost.de/content/dam/dpag/images/D_d/dialogpost-schwer/dp-dialogpost-schwer-broschuere-072021.pdf
|
||||
*/
|
||||
INTERNAL int dpleit(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
int i, error_number;
|
||||
int i, j, error_number;
|
||||
unsigned int count;
|
||||
int factor;
|
||||
unsigned char localstr[16] = {0};
|
||||
@ -311,16 +314,27 @@ INTERNAL int dpleit(struct zint_symbol *symbol, unsigned char source[], int leng
|
||||
localstr[13] = c25_check_digit(count);
|
||||
localstr[14] = '\0';
|
||||
error_number = c25_inter_common(symbol, localstr, 14, 1 /*dont_set_height*/);
|
||||
ustrcpy(symbol->text, localstr);
|
||||
|
||||
/* HRT formatting as per DIALOGPOST SCHWER brochure but TEC-IT differs as do examples at
|
||||
https://www.philaseiten.de/cgi-bin/index.pl?ST=8615&CP=0&F=1#M147 */
|
||||
for (i = 0, j = 0; i <= 14; i++) {
|
||||
symbol->text[j++] = localstr[i];
|
||||
if (i == 4 || i == 7 || i == 10) {
|
||||
symbol->text[j++] = '.';
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO: Find documentation on BARCODE_DPLEIT dimensions/height */
|
||||
/* Based on eyeballing DIALOGPOST SCHWER, using 72X as default */
|
||||
(void) set_height(symbol, 0.0f, 72.0f, 0.0f, 1 /*no_errtxt*/);
|
||||
|
||||
return error_number;
|
||||
}
|
||||
|
||||
/* Deutsche Post Identcode */
|
||||
/* See dpleit() for (sort of) documentation reference */
|
||||
INTERNAL int dpident(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
int i, error_number, zeroes;
|
||||
int i, j, error_number, zeroes;
|
||||
unsigned int count;
|
||||
int factor;
|
||||
unsigned char localstr[16] = {0};
|
||||
@ -348,9 +362,20 @@ INTERNAL int dpident(struct zint_symbol *symbol, unsigned char source[], int len
|
||||
localstr[11] = c25_check_digit(count);
|
||||
localstr[12] = '\0';
|
||||
error_number = c25_inter_common(symbol, localstr, 12, 1 /*dont_set_height*/);
|
||||
ustrcpy(symbol->text, localstr);
|
||||
|
||||
/* HRT formatting as per DIALOGPOST SCHWER brochure but TEC-IT differs as do other examples (see above) */
|
||||
for (i = 0, j = 0; i <= 12; i++) {
|
||||
symbol->text[j++] = localstr[i];
|
||||
if (i == 1 || i == 4 || i == 7) {
|
||||
symbol->text[j++] = '.';
|
||||
} else if (i == 3 || i == 10) {
|
||||
symbol->text[j++] = ' ';
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO: Find documentation on BARCODE_DPIDENT dimensions/height */
|
||||
/* Based on eyeballing DIALOGPOST SCHWER, using 72X as default */
|
||||
(void) set_height(symbol, 0.0f, 72.0f, 0.0f, 1 /*no_errtxt*/);
|
||||
|
||||
return error_number;
|
||||
}
|
||||
|
@ -31,12 +31,14 @@
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#include "common.h"
|
||||
#include "output.h"
|
||||
#include "bmp.h" /* Bitmap header structure */
|
||||
|
||||
INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) {
|
||||
@ -44,6 +46,7 @@ INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
|
||||
int row_size;
|
||||
int bits_per_pixel;
|
||||
int colour_count;
|
||||
int resolution;
|
||||
unsigned int data_offset, data_size, file_size;
|
||||
unsigned char *bitmap_file_start, *bmp_posn;
|
||||
unsigned char *bitmap;
|
||||
@ -157,8 +160,9 @@ INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
|
||||
info_header.bits_per_pixel = bits_per_pixel;
|
||||
info_header.compression_method = 0; /* BI_RGB */
|
||||
info_header.image_size = 0;
|
||||
info_header.horiz_res = 0;
|
||||
info_header.vert_res = 0;
|
||||
resolution = symbol->dpmm ? (int) roundf(stripf(symbol->dpmm * 1000.0f)) : 0; /* pixels per metre */
|
||||
info_header.horiz_res = resolution;
|
||||
info_header.vert_res = resolution;
|
||||
info_header.colours = colour_count;
|
||||
info_header.important_colours = colour_count;
|
||||
|
||||
@ -194,7 +198,7 @@ INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
|
||||
#endif
|
||||
bmp_file = stdout;
|
||||
} else {
|
||||
if (!(bmp_file = fopen(symbol->outfile, "wb"))) {
|
||||
if (!(bmp_file = out_fopen(symbol->outfile, "wb"))) {
|
||||
free(bitmap_file_start);
|
||||
sprintf(symbol->errtxt, "601: Could not open output file (%d: %.30s)", errno, strerror(errno));
|
||||
return ZINT_ERROR_FILE_ACCESS;
|
||||
|
@ -563,8 +563,8 @@ INTERNAL int codablockf(struct zint_symbol *symbol, unsigned char source[], int
|
||||
}
|
||||
symbol->text[0] = '\0'; /* Disable HRT for compatibility with CODABLOCKF */
|
||||
if (symbol->output_options & COMPLIANT_HEIGHT) {
|
||||
/* AIM ISS-X-24 Section 4.5.1 minimum row height 8 (for compatibility with CODABLOCKF, not specced for
|
||||
CODE128) */
|
||||
/* AIM ISS-X-24 Section 4.6.1 minimum row height 8X (for compatibility with CODABLOCKF, not specced
|
||||
for CODE128) */
|
||||
error_number = set_height(symbol, 8.0f, 10.0f, 0.0f, 0 /*no_errtxt*/);
|
||||
} else {
|
||||
(void) set_height(symbol, 0.0f, 5.0f, 0.0f, 1 /*no_errtxt*/);
|
||||
|
@ -448,7 +448,7 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len
|
||||
indexchaine = 0;
|
||||
|
||||
mode = c128_parunmodd(source[indexchaine]);
|
||||
if ((symbol->symbology == BARCODE_CODE128B) && (mode == C128_ABORC)) {
|
||||
if ((symbol->symbology == BARCODE_CODE128AB) && (mode == C128_ABORC)) {
|
||||
mode = C128_AORB;
|
||||
}
|
||||
|
||||
@ -461,7 +461,7 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len
|
||||
break;
|
||||
}
|
||||
mode = c128_parunmodd(source[indexchaine]);
|
||||
if ((symbol->symbology == BARCODE_CODE128B) && (mode == C128_ABORC)) {
|
||||
if ((symbol->symbology == BARCODE_CODE128AB) && (mode == C128_ABORC)) {
|
||||
mode = C128_AORB;
|
||||
}
|
||||
}
|
||||
@ -1169,7 +1169,8 @@ INTERNAL int dpd(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||
} else if (!is_sane(NEON_F, local_source + length - 6, 3)) { /* 3-digit Service Code */
|
||||
strcpy(symbol->errtxt, "832: Service Code (characters 6-4 from end) should be numeric");
|
||||
} else { /* Last 10 characters of Tracking No. */
|
||||
strcpy(symbol->errtxt, "833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric");
|
||||
strcpy(symbol->errtxt,
|
||||
"833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric");
|
||||
}
|
||||
error_number = ZINT_WARN_NONCOMPLIANT;
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ INTERNAL int is_stackable(const int symbology) {
|
||||
}
|
||||
|
||||
switch (symbology) {
|
||||
case BARCODE_CODE128B:
|
||||
case BARCODE_CODE128AB:
|
||||
case BARCODE_ISBNX:
|
||||
case BARCODE_EAN14:
|
||||
case BARCODE_NVE18:
|
||||
|
@ -1686,7 +1686,7 @@ static int dm_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], co
|
||||
if (symbol->structapp.id[0]) {
|
||||
int id, id_len, id1_err, id2_err;
|
||||
|
||||
for (id_len = 0; id_len < 32 && symbol->structapp.id[id_len]; id_len++);
|
||||
for (id_len = 1; id_len < 7 && symbol->structapp.id[id_len]; id_len++);
|
||||
|
||||
if (id_len > 6) { /* ID1 * 1000 + ID2 */
|
||||
strcpy(symbol->errtxt, "722: Structured Append ID too long (6 digit maximum)");
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#include "common.h"
|
||||
#include "output.h"
|
||||
#include "emf.h"
|
||||
|
||||
/* Multiply truncating to 3 decimal places (avoids rounding differences on various platforms) */
|
||||
@ -180,6 +181,16 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
|
||||
int rectangle_bycolour[9] = {0};
|
||||
|
||||
int width, height;
|
||||
int bounds_pxx, bounds_pxy; /* Pixels */
|
||||
int frame_cmmx, frame_cmmy; /* Hundredths of a mm, i.e. "centi-millimeters" */
|
||||
int device_pxx, device_pxy; /* Pixels */
|
||||
int mmx, mmy; /* Millimeters */
|
||||
int micronx, microny; /* Micrometers */
|
||||
const float dpmm = symbol->dpmm ? stripf(symbol->dpmm)
|
||||
: ZBarcode_XdimDp_From_Scale(symbol->symbology, symbol->scale,
|
||||
ZBarcode_Default_Xdim(symbol->symbology), "EMF");
|
||||
const int sideways = rotate_angle == 90 || rotate_angle == 270;
|
||||
|
||||
int draw_background = 1;
|
||||
int bold;
|
||||
const int output_to_stdout = symbol->output_options & BARCODE_STDOUT;
|
||||
@ -230,6 +241,8 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
|
||||
emr_ellipse_t *circle;
|
||||
emr_polygon_t *hexagon;
|
||||
|
||||
const int ih_ultra_offset = symbol->symbology == BARCODE_ULTRA ? 8 : 0;
|
||||
|
||||
if (symbol->vector == NULL) {
|
||||
strcpy(symbol->errtxt, "643: Vector header NULL");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
@ -281,39 +294,54 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
|
||||
width = (int) ceilf(symbol->vector->width);
|
||||
height = (int) ceilf(symbol->vector->height);
|
||||
|
||||
bounds_pxx = width - 1; /* Following Inkscape, bounds "inclusive-inclusive", so size 1 less */
|
||||
bounds_pxy = height - 1;
|
||||
device_pxx = width; /* device */
|
||||
device_pxy = height;
|
||||
|
||||
if (dpmm) {
|
||||
frame_cmmx = (int) roundf(stripf(width * 100.0f / dpmm)) - 1; /* frame also "inclusive-inclusive" */
|
||||
frame_cmmy = (int) roundf(stripf(height * 100.0f / dpmm)) - 1;
|
||||
mmx = (int) roundf(stripf(width / dpmm)); /* millimeters */
|
||||
mmy = (int) roundf(stripf(height / dpmm));
|
||||
micronx = (int) roundf(stripf(width * 1000.0f / dpmm)); /* micrometers */
|
||||
microny = (int) roundf(stripf(height * 1000.0f / dpmm));
|
||||
} else { /* Should only happen if `symbol->scale` zero. */
|
||||
frame_cmmx = (int) roundf(stripf(width * 100.0f)) - 1;
|
||||
frame_cmmy = (int) roundf(stripf(height * 100.0f)) - 1;
|
||||
mmx = (int) roundf(stripf(width));
|
||||
mmy = (int) roundf(stripf(height));
|
||||
micronx = (int) roundf(stripf(width * 1000.0f));
|
||||
microny = (int) roundf(stripf(height * 1000.0f));
|
||||
}
|
||||
|
||||
/* Header */
|
||||
emr_header.type = 0x00000001; /* EMR_HEADER */
|
||||
emr_header.size = 108; /* Including extensions */
|
||||
emr_header.emf_header.bounds.left = 0;
|
||||
emr_header.emf_header.bounds.right = rotate_angle == 90 || rotate_angle == 270 ? height : width;
|
||||
emr_header.emf_header.bounds.bottom = rotate_angle == 90 || rotate_angle == 270 ? width : height;
|
||||
emr_header.emf_header.bounds.top = 0;
|
||||
emr_header.emf_header.frame.left = 0;
|
||||
emr_header.emf_header.frame.right = emr_header.emf_header.bounds.right * 30;
|
||||
emr_header.emf_header.frame.top = 0;
|
||||
emr_header.emf_header.frame.bottom = emr_header.emf_header.bounds.bottom * 30;
|
||||
emr_header.emf_header.bounds.left = emr_header.emf_header.bounds.top = 0;
|
||||
emr_header.emf_header.bounds.right = sideways ? bounds_pxy : bounds_pxx;
|
||||
emr_header.emf_header.bounds.bottom = sideways ? bounds_pxx : bounds_pxy;
|
||||
emr_header.emf_header.frame.left = emr_header.emf_header.frame.top = 0;
|
||||
emr_header.emf_header.frame.right = sideways ? frame_cmmy : frame_cmmx;
|
||||
emr_header.emf_header.frame.bottom = sideways ? frame_cmmx : frame_cmmy;
|
||||
emr_header.emf_header.record_signature = 0x464d4520; /* ENHMETA_SIGNATURE */
|
||||
emr_header.emf_header.version = 0x00010000;
|
||||
if (symbol->symbology == BARCODE_ULTRA) {
|
||||
emr_header.emf_header.handles = 12; /* Number of graphics objects */
|
||||
} else {
|
||||
emr_header.emf_header.handles = fsize2 != 0.0f ? 5 : 4;
|
||||
}
|
||||
emr_header.emf_header.handles = (fsize2 != 0.0f ? 5 : 4) + ih_ultra_offset; /* Number of graphics objects */
|
||||
emr_header.emf_header.reserved = 0x0000;
|
||||
emr_header.emf_header.n_description = 0;
|
||||
emr_header.emf_header.off_description = 0;
|
||||
emr_header.emf_header.n_pal_entries = 0;
|
||||
emr_header.emf_header.device.cx = 1000;
|
||||
emr_header.emf_header.device.cy = 1000;
|
||||
emr_header.emf_header.millimeters.cx = 300;
|
||||
emr_header.emf_header.millimeters.cy = 300;
|
||||
emr_header.emf_header.device.cx = sideways ? device_pxy : device_pxx;
|
||||
emr_header.emf_header.device.cy = sideways ? device_pxx : device_pxy;
|
||||
emr_header.emf_header.millimeters.cx = sideways ? mmy : mmx;
|
||||
emr_header.emf_header.millimeters.cy = sideways ? mmx : mmy;
|
||||
/* HeaderExtension1 */
|
||||
emr_header.emf_header.cb_pixel_format = 0x0000; /* None set */
|
||||
emr_header.emf_header.off_pixel_format = 0x0000; /* None set */
|
||||
emr_header.emf_header.b_open_gl = 0x0000; /* OpenGL not present */
|
||||
/* HeaderExtension2 */
|
||||
emr_header.emf_header.micrometers.cx = 0;
|
||||
emr_header.emf_header.micrometers.cy = 0;
|
||||
emr_header.emf_header.micrometers.cx = sideways ? microny : micronx;
|
||||
emr_header.emf_header.micrometers.cy = sideways ? micronx : microny;
|
||||
bytecount = 108;
|
||||
recordcount = 1;
|
||||
|
||||
@ -339,7 +367,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
|
||||
/* Create Brushes */
|
||||
emr_createbrushindirect_bg.type = 0x00000027; /* EMR_CREATEBRUSHINDIRECT */
|
||||
emr_createbrushindirect_bg.size = 24;
|
||||
emr_createbrushindirect_bg.ih_brush = 1;
|
||||
emr_createbrushindirect_bg.ih_brush = 0;
|
||||
emr_createbrushindirect_bg.log_brush.brush_style = 0x0000; /* BS_SOLID */
|
||||
emr_createbrushindirect_bg.log_brush.color.red = bgred;
|
||||
emr_createbrushindirect_bg.log_brush.color.green = bggrn;
|
||||
@ -353,7 +381,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
|
||||
for (i = 0; i < 9; i++) {
|
||||
emr_createbrushindirect_colour[i].type = 0x00000027; /* EMR_CREATEBRUSHINDIRECT */
|
||||
emr_createbrushindirect_colour[i].size = 24;
|
||||
emr_createbrushindirect_colour[i].ih_brush = 2 + i;
|
||||
emr_createbrushindirect_colour[i].ih_brush = 1 + i;
|
||||
emr_createbrushindirect_colour[i].log_brush.brush_style = 0x0000; /* BS_SOLID */
|
||||
if (i == 0) {
|
||||
emr_createbrushindirect_colour[i].log_brush.color.red = fgred;
|
||||
@ -372,7 +400,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
|
||||
} else {
|
||||
emr_createbrushindirect_fg.type = 0x00000027; /* EMR_CREATEBRUSHINDIRECT */
|
||||
emr_createbrushindirect_fg.size = 24;
|
||||
emr_createbrushindirect_fg.ih_brush = 2;
|
||||
emr_createbrushindirect_fg.ih_brush = 1;
|
||||
emr_createbrushindirect_fg.log_brush.brush_style = 0x0000; /* BS_SOLID */
|
||||
emr_createbrushindirect_fg.log_brush.color.red = fgred;
|
||||
emr_createbrushindirect_fg.log_brush.color.green = fggrn;
|
||||
@ -385,7 +413,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
|
||||
|
||||
emr_selectobject_bgbrush.type = 0x00000025; /* EMR_SELECTOBJECT */
|
||||
emr_selectobject_bgbrush.size = 12;
|
||||
emr_selectobject_bgbrush.ih_object = 1;
|
||||
emr_selectobject_bgbrush.ih_object = emr_createbrushindirect_bg.ih_brush;
|
||||
bytecount += 12;
|
||||
recordcount++;
|
||||
|
||||
@ -393,14 +421,14 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
|
||||
for (i = 0; i < 9; i++) {
|
||||
emr_selectobject_colour[i].type = 0x00000025; /* EMR_SELECTOBJECT */
|
||||
emr_selectobject_colour[i].size = 12;
|
||||
emr_selectobject_colour[i].ih_object = 2 + i;
|
||||
emr_selectobject_colour[i].ih_object = emr_createbrushindirect_colour[i].ih_brush;
|
||||
}
|
||||
bytecount += colours_used * 12;
|
||||
recordcount += colours_used;
|
||||
} else {
|
||||
emr_selectobject_fgbrush.type = 0x00000025; /* EMR_SELECTOBJECT */
|
||||
emr_selectobject_fgbrush.size = 12;
|
||||
emr_selectobject_fgbrush.ih_object = 2;
|
||||
emr_selectobject_fgbrush.ih_object = emr_createbrushindirect_fg.ih_brush;
|
||||
bytecount += 12;
|
||||
recordcount++;
|
||||
}
|
||||
@ -408,7 +436,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
|
||||
/* Create Pens */
|
||||
emr_createpen.type = 0x00000026; /* EMR_CREATEPEN */
|
||||
emr_createpen.size = 28;
|
||||
emr_createpen.ih_pen = 11;
|
||||
emr_createpen.ih_pen = 2 + ih_ultra_offset;
|
||||
emr_createpen.log_pen.pen_style = 0x00000005; /* PS_NULL */
|
||||
emr_createpen.log_pen.width.x = 1;
|
||||
emr_createpen.log_pen.width.y = 0; /* ignored */
|
||||
@ -421,7 +449,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
|
||||
|
||||
emr_selectobject_pen.type = 0x00000025; /* EMR_SELECTOBJECT */
|
||||
emr_selectobject_pen.size = 12;
|
||||
emr_selectobject_pen.ih_object = 11;
|
||||
emr_selectobject_pen.ih_object = emr_createpen.ih_pen;
|
||||
bytecount += 12;
|
||||
recordcount++;
|
||||
|
||||
@ -431,8 +459,8 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
|
||||
background.size = 24;
|
||||
background.box.top = 0;
|
||||
background.box.left = 0;
|
||||
background.box.right = emr_header.emf_header.bounds.right;
|
||||
background.box.bottom = emr_header.emf_header.bounds.bottom;
|
||||
background.box.right = width;
|
||||
background.box.bottom = height;
|
||||
bytecount += 24;
|
||||
recordcount++;
|
||||
}
|
||||
@ -537,7 +565,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
|
||||
memset(&emr_extcreatefontindirectw, 0, sizeof(emr_extcreatefontindirectw));
|
||||
emr_extcreatefontindirectw.type = 0x00000052; /* EMR_EXTCREATEFONTINDIRECTW */
|
||||
emr_extcreatefontindirectw.size = 104;
|
||||
emr_extcreatefontindirectw.ih_fonts = 12;
|
||||
emr_extcreatefontindirectw.ih_fonts = 3 + ih_ultra_offset;
|
||||
emr_extcreatefontindirectw.elw.height = (int32_t) fsize;
|
||||
emr_extcreatefontindirectw.elw.width = 0; /* automatic */
|
||||
emr_extcreatefontindirectw.elw.weight = bold ? 700 : 400;
|
||||
@ -551,20 +579,20 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
|
||||
|
||||
emr_selectobject_font.type = 0x00000025; /* EMR_SELECTOBJECT */
|
||||
emr_selectobject_font.size = 12;
|
||||
emr_selectobject_font.ih_object = 12;
|
||||
emr_selectobject_font.ih_object = emr_extcreatefontindirectw.ih_fonts;
|
||||
bytecount += 12;
|
||||
recordcount++;
|
||||
|
||||
if (fsize2) {
|
||||
memcpy(&emr_extcreatefontindirectw2, &emr_extcreatefontindirectw, sizeof(emr_extcreatefontindirectw));
|
||||
emr_extcreatefontindirectw2.ih_fonts = 13;
|
||||
emr_extcreatefontindirectw2.ih_fonts = 4 + ih_ultra_offset;
|
||||
emr_extcreatefontindirectw2.elw.height = (int32_t) fsize2;
|
||||
bytecount += 104;
|
||||
recordcount++;
|
||||
|
||||
emr_selectobject_font2.type = 0x00000025; /* EMR_SELECTOBJECT */
|
||||
emr_selectobject_font2.size = 12;
|
||||
emr_selectobject_font2.ih_object = 13;
|
||||
emr_selectobject_font2.ih_object = emr_extcreatefontindirectw2.ih_fonts;
|
||||
bytecount += 12;
|
||||
recordcount++;
|
||||
}
|
||||
@ -684,7 +712,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
|
||||
#endif
|
||||
emf_file = stdout;
|
||||
} else {
|
||||
if (!(emf_file = fopen(symbol->outfile, "wb"))) {
|
||||
if (!(emf_file = out_fopen(symbol->outfile, "wb"))) {
|
||||
sprintf(symbol->errtxt, "640: Could not open output file (%d: %.30s)", errno, strerror(errno));
|
||||
return ZINT_ERROR_FILE_ACCESS;
|
||||
}
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#include "common.h"
|
||||
#include "output.h"
|
||||
|
||||
/* Limit initial LZW buffer size to this in expectation that compressed data will fit for typical scalings */
|
||||
#define GIF_LZW_PAGE_SIZE 0x100000 /* Megabyte */
|
||||
@ -474,7 +475,7 @@ INTERNAL int gif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
|
||||
#endif
|
||||
gif_file = stdout;
|
||||
} else {
|
||||
if (!(gif_file = fopen(symbol->outfile, "wb"))) {
|
||||
if (!(gif_file = out_fopen(symbol->outfile, "wb"))) {
|
||||
sprintf(symbol->errtxt, "611: Could not open output file (%d: %.30s)", errno, strerror(errno));
|
||||
return ZINT_ERROR_FILE_ACCESS;
|
||||
}
|
||||
|
@ -1079,7 +1079,7 @@ INTERNAL int gridmatrix(struct zint_symbol *symbol, struct zint_seg segs[], cons
|
||||
if (symbol->structapp.id[0]) {
|
||||
int id, id_len;
|
||||
|
||||
for (id_len = 0; id_len < 32 && symbol->structapp.id[id_len]; id_len++);
|
||||
for (id_len = 1; id_len < 4 && symbol->structapp.id[id_len]; id_len++);
|
||||
|
||||
if (id_len > 3) { /* 255 (8 bits) */
|
||||
strcpy(symbol->errtxt, "538: Structured Append ID too long (3 digit maximum)");
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include "common.h"
|
||||
#include "eci.h"
|
||||
@ -41,12 +42,12 @@
|
||||
|
||||
/* It's assumed that int is at least 32 bits, the following will compile-time fail if not
|
||||
* https://stackoverflow.com/a/1980056 */
|
||||
typedef char static_assert_int_at_least_32bits[CHAR_BIT != 8 || sizeof(int) < 4 ? -1 : 1];
|
||||
typedef char static_assert_int_at_least_32bits[sizeof(int) * CHAR_BIT < 32 ? -1 : 1];
|
||||
|
||||
typedef char static_assert_uint16_is_16bits[sizeof(uint16_t) != 2 ? -1 : 1];
|
||||
typedef char static_assert_int32_is_32bits[sizeof(int32_t) != 4 ? -1 : 1];
|
||||
typedef char static_assert_uint32_is_32bits[sizeof(uint32_t) != 4 ? -1 : 1];
|
||||
typedef char static_assert_uint64_at_least_64bits[sizeof(uint64_t) < 8 ? -1 : 1];
|
||||
typedef char static_assert_uint16_is_16bits[sizeof(uint16_t) * CHAR_BIT != 16 ? -1 : 1];
|
||||
typedef char static_assert_int32_is_32bits[sizeof(int32_t) * CHAR_BIT != 32 ? -1 : 1];
|
||||
typedef char static_assert_uint32_is_32bits[sizeof(uint32_t) * CHAR_BIT != 32 ? -1 : 1];
|
||||
typedef char static_assert_uint64_at_least_64bits[sizeof(uint64_t) * CHAR_BIT < 64 ? -1 : 1];
|
||||
|
||||
/* Create and initialize a symbol structure */
|
||||
struct zint_symbol *ZBarcode_Create(void) {
|
||||
@ -203,8 +204,10 @@ INTERNAL int dpd(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||
INTERNAL int bc412(struct zint_symbol *symbol, unsigned char source[], int length); /* BC412 */
|
||||
|
||||
/* Output handlers */
|
||||
INTERNAL int plot_raster(struct zint_symbol *symbol, int rotate_angle, int file_type); /* Plot to PNG/BMP/PCX */
|
||||
INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_type); /* Plot to EPS/EMF/SVG */
|
||||
/* Plot to BMP/GIF/PCX/PNG/TIF */
|
||||
INTERNAL int plot_raster(struct zint_symbol *symbol, int rotate_angle, int file_type);
|
||||
/* Plot to EMF/EPS/SVG */
|
||||
INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_type);
|
||||
|
||||
/* Prefix error message with Error/Warning */
|
||||
static int error_tag(struct zint_symbol *symbol, int error_number, const char *error_string) {
|
||||
@ -1047,8 +1050,8 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[
|
||||
}
|
||||
|
||||
/* Check other symbol fields */
|
||||
if ((symbol->scale < 0.01f) || (symbol->scale > 100.0f)) {
|
||||
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "227: Scale out of range (0.01 to 100)");
|
||||
if ((symbol->scale < 0.01f) || (symbol->scale > 200.0f)) {
|
||||
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "227: Scale out of range (0.01 to 200)");
|
||||
}
|
||||
if ((symbol->dot_size < 0.01f) || (symbol->dot_size > 20.0f)) {
|
||||
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "221: Dot size out of range (0.01 to 20)");
|
||||
@ -1207,6 +1210,33 @@ static int check_output_args(struct zint_symbol *symbol, int rotate_angle) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct zint_filetypes { const char extension[4]; int is_raster; int filetype; };
|
||||
static const struct zint_filetypes filetypes[] = {
|
||||
{ "BMP", 1, OUT_BMP_FILE }, { "EMF", 0, OUT_EMF_FILE }, { "EPS", 0, OUT_EPS_FILE },
|
||||
{ "GIF", 1, OUT_GIF_FILE }, { "PCX", 1, OUT_PCX_FILE }, { "PNG", 1, OUT_PNG_FILE },
|
||||
{ "SVG", 0, OUT_SVG_FILE }, { "TIF", 1, OUT_TIF_FILE }, { "TXT", 0, 0 }
|
||||
};
|
||||
|
||||
/* Return index of `extension` in `filetypes`, or -1 if not found */
|
||||
static int filetype_idx(const char *extension) {
|
||||
char uc_extension[4] = {0};
|
||||
int i;
|
||||
|
||||
if (strlen(extension) != 3) {
|
||||
return -1;
|
||||
}
|
||||
memcpy(uc_extension, extension, 3);
|
||||
to_upper((unsigned char *) uc_extension, 3);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(filetypes); i++) {
|
||||
if (strcmp(uc_extension, filetypes[i].extension) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return i == ARRAY_SIZE(filetypes) ? -1 : i;
|
||||
}
|
||||
|
||||
/* Output a previously encoded symbol to file `symbol->outfile` */
|
||||
int ZBarcode_Print(struct zint_symbol *symbol, int rotate_angle) {
|
||||
int error_number;
|
||||
@ -1218,40 +1248,17 @@ int ZBarcode_Print(struct zint_symbol *symbol, int rotate_angle) {
|
||||
|
||||
len = (int) strlen(symbol->outfile);
|
||||
if (len > 3) {
|
||||
char output[4];
|
||||
output[0] = symbol->outfile[len - 3];
|
||||
output[1] = symbol->outfile[len - 2];
|
||||
output[2] = symbol->outfile[len - 1];
|
||||
output[3] = '\0';
|
||||
to_upper((unsigned char *) output, 3);
|
||||
|
||||
if (!(strcmp(output, "PNG"))) {
|
||||
error_number = plot_raster(symbol, rotate_angle, OUT_PNG_FILE);
|
||||
|
||||
} else if (!(strcmp(output, "BMP"))) {
|
||||
error_number = plot_raster(symbol, rotate_angle, OUT_BMP_FILE);
|
||||
|
||||
} else if (!(strcmp(output, "PCX"))) {
|
||||
error_number = plot_raster(symbol, rotate_angle, OUT_PCX_FILE);
|
||||
|
||||
} else if (!(strcmp(output, "GIF"))) {
|
||||
error_number = plot_raster(symbol, rotate_angle, OUT_GIF_FILE);
|
||||
|
||||
} else if (!(strcmp(output, "TIF"))) {
|
||||
error_number = plot_raster(symbol, rotate_angle, OUT_TIF_FILE);
|
||||
|
||||
} else if (!(strcmp(output, "TXT"))) {
|
||||
error_number = dump_plot(symbol);
|
||||
|
||||
} else if (!(strcmp(output, "EPS"))) {
|
||||
error_number = plot_vector(symbol, rotate_angle, OUT_EPS_FILE);
|
||||
|
||||
} else if (!(strcmp(output, "SVG"))) {
|
||||
error_number = plot_vector(symbol, rotate_angle, OUT_SVG_FILE);
|
||||
|
||||
} else if (!(strcmp(output, "EMF"))) {
|
||||
error_number = plot_vector(symbol, rotate_angle, OUT_EMF_FILE);
|
||||
|
||||
int i = filetype_idx(symbol->outfile + len - 3);
|
||||
if (i >= 0) {
|
||||
if (filetypes[i].filetype) {
|
||||
if (filetypes[i].is_raster) {
|
||||
error_number = plot_raster(symbol, rotate_angle, filetypes[i].filetype);
|
||||
} else {
|
||||
error_number = plot_vector(symbol, rotate_angle, filetypes[i].filetype);
|
||||
}
|
||||
} else {
|
||||
error_number = dump_plot(symbol);
|
||||
}
|
||||
} else {
|
||||
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "225: Unknown output format");
|
||||
}
|
||||
@ -1597,7 +1604,7 @@ int ZBarcode_BarcodeName(int symbol_id, char name[32]) {
|
||||
{ "BARCODE_MAXICODE", BARCODE_MAXICODE, 57 },
|
||||
{ "BARCODE_QRCODE", BARCODE_QRCODE, 58 },
|
||||
{ "", -1, 59 },
|
||||
{ "BARCODE_CODE128B", BARCODE_CODE128B, 60 },
|
||||
{ "BARCODE_CODE128AB", BARCODE_CODE128AB, 60 },
|
||||
{ "", -1, 61 },
|
||||
{ "", -1, 62 },
|
||||
{ "BARCODE_AUSPOST", BARCODE_AUSPOST, 63 },
|
||||
@ -1761,7 +1768,7 @@ unsigned int ZBarcode_Cap(int symbol_id, unsigned int cap_flag) {
|
||||
/* Note does not include HIBC versions */
|
||||
switch (symbol_id) {
|
||||
case BARCODE_CODE128: /* Note does not include GS1_128 or NVE18 */
|
||||
case BARCODE_CODE128B:
|
||||
case BARCODE_CODE128AB:
|
||||
case BARCODE_CODE16K:
|
||||
case BARCODE_CODABLOCKF:
|
||||
case BARCODE_PDF417:
|
||||
@ -1831,7 +1838,7 @@ unsigned int ZBarcode_Cap(int symbol_id, unsigned int cap_flag) {
|
||||
case BARCODE_C25LOGIC:
|
||||
case BARCODE_C25IND:
|
||||
case BARCODE_CODE128: /* Left to application */
|
||||
case BARCODE_CODE128B:
|
||||
case BARCODE_CODE128AB:
|
||||
case BARCODE_DPLEIT: /* TODO: Find doc */
|
||||
case BARCODE_DPIDENT: /* TODO: Find doc */
|
||||
case BARCODE_FLAT: /* TODO: Find doc */
|
||||
@ -1856,6 +1863,243 @@ unsigned int ZBarcode_Cap(int symbol_id, unsigned int cap_flag) {
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Return default X-dimension in mm for symbology `symbol_id`. Returns 0 on error (invalid `symbol_id`) */
|
||||
float ZBarcode_Default_Xdim(int symbol_id) {
|
||||
float x_dim_mm;
|
||||
|
||||
if (!ZBarcode_ValidID(symbol_id)) {
|
||||
return 0.0f;
|
||||
}
|
||||
switch (symbol_id) {
|
||||
/* Postal 2/4-track */
|
||||
case BARCODE_AUSPOST:
|
||||
case BARCODE_AUSREPLY:
|
||||
case BARCODE_AUSROUTE:
|
||||
case BARCODE_AUSREDIRECT:
|
||||
/* Australia Post Customer Barcoding Technical Specifications, average of 0.4 to 0.6 mm */
|
||||
x_dim_mm = 0.5f;
|
||||
break;
|
||||
case BARCODE_CEPNET:
|
||||
case BARCODE_POSTNET:
|
||||
case BARCODE_PLANET:
|
||||
case BARCODE_USPS_IMAIL:
|
||||
/* USPS-B-3200 Section 2.3.1, height 0.145" (average of 0.125, 0.165) / 6.235 (Zint height), same as
|
||||
USPS DMM 300 Section 708.4.2.5 using bar pitch (1" / 43) ~ 0.023" */
|
||||
x_dim_mm = 0.591f;
|
||||
break;
|
||||
case BARCODE_RM4SCC:
|
||||
case BARCODE_KIX:
|
||||
case BARCODE_MAILMARK:
|
||||
/* Royal Mail Mailmark Barcode Definition Document, height 5.1mm / 8 (Zint height) == 0.6375 */
|
||||
x_dim_mm = 0.638f; /* Seems better fit to round up to 3 d.p. */
|
||||
break;
|
||||
case BARCODE_JAPANPOST:
|
||||
x_dim_mm = 0.6f; /* Japan Post Zip/Barcode Manual */
|
||||
break;
|
||||
|
||||
/* GS1 (excluding GS1-128, ITF-14, GS1 QRCODE & GS1 DATAMATRIX - see default) */
|
||||
case BARCODE_EANX:
|
||||
case BARCODE_EANX_CHK:
|
||||
case BARCODE_EANX_CC:
|
||||
case BARCODE_ISBNX:
|
||||
case BARCODE_UPCA:
|
||||
case BARCODE_UPCA_CHK:
|
||||
case BARCODE_UPCA_CC:
|
||||
case BARCODE_UPCE:
|
||||
case BARCODE_UPCE_CHK:
|
||||
case BARCODE_UPCE_CC:
|
||||
case BARCODE_DBAR_OMN:
|
||||
case BARCODE_DBAR_OMN_CC:
|
||||
case BARCODE_DBAR_LTD:
|
||||
case BARCODE_DBAR_LTD_CC:
|
||||
case BARCODE_DBAR_EXP:
|
||||
case BARCODE_DBAR_EXP_CC:
|
||||
case BARCODE_DBAR_STK:
|
||||
case BARCODE_DBAR_STK_CC:
|
||||
case BARCODE_DBAR_OMNSTK:
|
||||
case BARCODE_DBAR_OMNSTK_CC:
|
||||
case BARCODE_DBAR_EXPSTK:
|
||||
case BARCODE_DBAR_EXPSTK_CC:
|
||||
x_dim_mm = 0.33f; /* GS1 General Standards 22.0 Section 5.12.3 Table 1 except DBAR_LTD Table 4 */
|
||||
break;
|
||||
|
||||
/* Specific */
|
||||
case BARCODE_BC412:
|
||||
x_dim_mm = 0.12f; /* SEMI T1-95 Table 1 */
|
||||
break;
|
||||
case BARCODE_CODABAR:
|
||||
x_dim_mm = 0.38f; /* EN 798:1996 Appendix D.1 (d), average of 0.33 to 0.43 mm */
|
||||
break;
|
||||
case BARCODE_CODE32:
|
||||
x_dim_mm = 0.25f; /* Allegato A Caratteristiche tecniche del bollino farmaceutico, 0.25mm */
|
||||
break;
|
||||
case BARCODE_DPD:
|
||||
x_dim_mm = 0.375f; /* DPD Parcel Label Specification Version 2.4.1 (19.01.2021) Section 4.6.1.2 */
|
||||
break;
|
||||
case BARCODE_FIM:
|
||||
/* USPS DMM 300 Section 708.9.3, 0.03125" */
|
||||
x_dim_mm = 0.79375f;
|
||||
break;
|
||||
case BARCODE_LOGMARS:
|
||||
x_dim_mm = 0.34925f; /* MIL-STD-1189 Rev. B Section 5.2, average of 0.0075" and 0.02" */
|
||||
break;
|
||||
case BARCODE_MAXICODE:
|
||||
/* ISO/IEC 16023:2000 Table 7, based on L = 25.5mm */
|
||||
x_dim_mm = 0.88f;
|
||||
break;
|
||||
case BARCODE_PHARMA:
|
||||
x_dim_mm = 0.5f; /* Laetus Pharmacode Guide Section 1.2, standard 0.5mm */
|
||||
break;
|
||||
case BARCODE_PHARMA_TWO:
|
||||
x_dim_mm = 1.0f; /* Laetus Pharmacode Guide Section 1.4, standard 1mm */
|
||||
break;
|
||||
case BARCODE_PZN:
|
||||
x_dim_mm = 0.25f; /* Technical Information regarding PZN, "normal" X 0.25mm */
|
||||
break;
|
||||
case BARCODE_TELEPEN:
|
||||
case BARCODE_TELEPEN_NUM:
|
||||
/* Telepen Barcode Symbology information and History, average of between 0.010" and 0.0125" */
|
||||
x_dim_mm = 0.28575f;
|
||||
break;
|
||||
|
||||
/* Stacked (excluding GS1 DataBar) */
|
||||
case BARCODE_CODE16K: /* Application-defined */
|
||||
case BARCODE_CODE49: /* ANSI/AIM BC6-2000 Appendix D.2.4, C grade if > 0.25mm */
|
||||
case BARCODE_CODABLOCKF: /* Application-defined */
|
||||
case BARCODE_HIBC_BLOCKF:
|
||||
case BARCODE_PDF417: /* Maybe 0.27mm following ISO/IEC 15438:2015 Annex S.2.2 example? */
|
||||
case BARCODE_PDF417COMP:
|
||||
case BARCODE_HIBC_PDF:
|
||||
case BARCODE_MICROPDF417:
|
||||
case BARCODE_HIBC_MICPDF:
|
||||
/* Fairly arbitrarily using ISO/IEC 15416:2016 Section 5.3.1 Table 1, aperature diameters 0.125 & 0.250
|
||||
(also fits in 0.25 <= X < 0.5 range for aperature 0.2 from ISO/IEC 15415:2011 Annex D Table D.1) */
|
||||
x_dim_mm = 0.33f;
|
||||
break;
|
||||
|
||||
/* Application defined (and hence pretty arbitrary) */
|
||||
default:
|
||||
if (is_fixed_ratio(symbol_id)) {
|
||||
/* GS1 General Standards 22.0 Section 5.12.3 Table 1 (general retail) */
|
||||
x_dim_mm = 0.625f;
|
||||
} else {
|
||||
/* GS1 General Standards 22.0 Section 5.12.3.4 GS1-128 Tables 2, 4, 5, 6, 8 */
|
||||
x_dim_mm = 0.495f;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return x_dim_mm;
|
||||
}
|
||||
|
||||
/* Return the scale to use for `symbol_id` for non-zero X-dimension `x_dim_mm` at `dpmm` dots per mm for
|
||||
`filetype`. If `dpmm` zero defaults to 12. If `filetype` NULL/empty, defaults to "GIF". Returns 0 on error */
|
||||
float ZBarcode_Scale_From_XdimDp(int symbol_id, float x_dim_mm, float dpmm, const char *filetype) {
|
||||
int i;
|
||||
float scale;
|
||||
|
||||
if (!ZBarcode_ValidID(symbol_id)) {
|
||||
return 0.0f;
|
||||
}
|
||||
if (x_dim_mm <= 0.0f || x_dim_mm > 10.0f) { /* 10mm == 0.39" */
|
||||
return 0.0f;
|
||||
}
|
||||
if (dpmm == 0.0f) {
|
||||
dpmm = 12.0f; /* ~300 dpi */
|
||||
} else if (dpmm < 0.0f || dpmm > 1000.0f) { /* 1000 dpmm == 25400 dpi */
|
||||
return 0.0f;
|
||||
}
|
||||
if (filetype && *filetype) {
|
||||
if ((i = filetype_idx(filetype)) < 0 || filetypes[i].filetype == 0) { /* Not found or TXT */
|
||||
return 0.0f;
|
||||
}
|
||||
} else {
|
||||
i = filetype_idx("GIF"); /* Default to raster */
|
||||
}
|
||||
|
||||
scale = stripf(stripf(x_dim_mm) * stripf(dpmm));
|
||||
|
||||
if (symbol_id == BARCODE_MAXICODE) {
|
||||
if (filetypes[i].is_raster) {
|
||||
scale /= 10.0f;
|
||||
} else if (filetypes[i].filetype == OUT_EMF_FILE) {
|
||||
scale /= 40.0f;
|
||||
} else {
|
||||
scale /= 2.0f;
|
||||
}
|
||||
} else {
|
||||
if (filetypes[i].is_raster) {
|
||||
scale = roundf(scale) / 2.0f; /* Half-integer increments */
|
||||
} else {
|
||||
scale /= 2.0f;
|
||||
}
|
||||
}
|
||||
scale = stripf(scale);
|
||||
|
||||
if (scale > 200.0f) {
|
||||
scale = 200.0f;
|
||||
} else {
|
||||
if (filetypes[i].is_raster) {
|
||||
if (symbol_id == BARCODE_MAXICODE) {
|
||||
if (scale < 0.2f) {
|
||||
scale = 0.2f;
|
||||
}
|
||||
} else if (scale < 0.5f) {
|
||||
scale = 0.5f; /* Note if dotty mode needs further bounding to 1.0 */
|
||||
}
|
||||
} else {
|
||||
if (scale < 0.1f) {
|
||||
scale = 0.1f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return scale;
|
||||
}
|
||||
|
||||
/* Reverse of `ZBarcode_Scale_From_XdimDp()` above to estimate the X-dimension or dpmm given non-zero `scale` and
|
||||
non-zero `x_dim_mm_or_dpmm`. Return value bound to dpmm max not X-dimension max. Returns 0 on error */
|
||||
float ZBarcode_XdimDp_From_Scale(int symbol_id, float scale, float xdim_mm_or_dpmm, const char *filetype) {
|
||||
int i;
|
||||
|
||||
if (!ZBarcode_ValidID(symbol_id)) {
|
||||
return 0.0f;
|
||||
}
|
||||
if (scale <= 0.0f || scale > 200.0f) {
|
||||
return 0.0f;
|
||||
}
|
||||
if (xdim_mm_or_dpmm <= 0.0f || xdim_mm_or_dpmm > 1000.0f) { /* 1000 dpmm == 25400 dpi */
|
||||
return 0.0f;
|
||||
}
|
||||
if (filetype && *filetype) {
|
||||
if ((i = filetype_idx(filetype)) < 0 || filetypes[i].filetype == 0) { /* Not found or TXT */
|
||||
return 0.0f;
|
||||
}
|
||||
} else {
|
||||
i = filetype_idx("GIF"); /* Default to raster */
|
||||
}
|
||||
|
||||
if (symbol_id == BARCODE_MAXICODE) {
|
||||
if (filetypes[i].is_raster) {
|
||||
scale *= 10.0f;
|
||||
} else if (filetypes[i].filetype == OUT_EMF_FILE) {
|
||||
scale *= 40.0f;
|
||||
} else {
|
||||
scale *= 2.0f;
|
||||
}
|
||||
} else {
|
||||
scale *= 2.0f;
|
||||
}
|
||||
|
||||
xdim_mm_or_dpmm = stripf(stripf(scale) / stripf(xdim_mm_or_dpmm));
|
||||
|
||||
if (xdim_mm_or_dpmm > 1000.0f) { /* Note if X-dimension sought needs to be further bound to <= 10 on return */
|
||||
xdim_mm_or_dpmm = 1000.0f;
|
||||
}
|
||||
|
||||
return xdim_mm_or_dpmm;
|
||||
}
|
||||
|
||||
/* Whether Zint built without PNG support */
|
||||
int ZBarcode_NoPng(void) {
|
||||
#ifdef ZINT_NO_PNG
|
||||
|
@ -154,13 +154,15 @@ INTERNAL int mailmark(struct zint_symbol *symbol, unsigned char source[], int le
|
||||
ustrcpy(local_source, source);
|
||||
|
||||
if (length < 22) {
|
||||
if (length < 14) {
|
||||
strcpy(symbol->errtxt, "588: Input too short (14 character minimum)");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
for (i = length; i <= 22; i++) {
|
||||
strcat(local_source, " ");
|
||||
}
|
||||
length = 22;
|
||||
}
|
||||
|
||||
if ((length > 22) && (length < 26)) {
|
||||
} else if ((length > 22) && (length < 26)) {
|
||||
for (i = length; i <= 26; i++) {
|
||||
strcat(local_source, " ");
|
||||
}
|
||||
|
@ -188,7 +188,8 @@ INTERNAL int pharma_two(struct zint_symbol *symbol, unsigned char source[], int
|
||||
|
||||
if (symbol->output_options & COMPLIANT_HEIGHT) {
|
||||
/* Laetus Pharmacode Guide 1.4
|
||||
Two-track height min 8mm / 2mm (X max) = 4, standard 8mm / 1mm = 8, max 12mm / 0.8mm (X min) = 15 */
|
||||
Two-track height min 8mm / 2mm (X max) = 4X (2X per row), standard 8mm / 1mm = 8X,
|
||||
max 12mm / 0.8mm (X min) = 15X */
|
||||
error_number = set_height(symbol, 2.0f, 8.0f, 15.0f, 0 /*no_errtxt*/);
|
||||
} else {
|
||||
(void) set_height(symbol, 0.0f, 10.0f, 0.0f, 1 /*no_errtxt*/);
|
||||
@ -270,11 +271,11 @@ INTERNAL int codabar(struct zint_symbol *symbol, unsigned char source[], int len
|
||||
expand(symbol, dest, d - dest);
|
||||
|
||||
if (symbol->output_options & COMPLIANT_HEIGHT) {
|
||||
/* BS EN 798:1995 4.4.1 (d) max of 5mm / 0.191mm (X) ~ 26.178 or 15% of width where (taking N = narrow/wide
|
||||
ratio as 2 and I = X) width = ((2 * N + 5) * C + (N – 1) * (D + 2)) * X + I * (C – 1) + 2Q
|
||||
/* BS EN 798:1995 4.4.1 (d) max of 5mm / 0.43mm (X max) ~ 11.628 or 15% of width where (taking N =
|
||||
narrow/wide ratio as 2 and I = X) width = ((2 * N + 5) * C + (N – 1) * (D + 2)) * X + I * (C – 1) + 2Q
|
||||
= ((4 + 5) * C + (D + 2) + C - 1 + 2 * 10) * X = (10 * C + D + 21) * X
|
||||
Length (C) includes start/stop chars */
|
||||
const float min_height_min = stripf(5.0f / 0.191f);
|
||||
const float min_height_min = stripf(5.0f / 0.43f);
|
||||
float min_height = stripf((10.0f * ((add_checksum ? length + 1 : length) + 2.0f) + d_chars + 21.0f) * 0.15f);
|
||||
if (min_height < min_height_min) {
|
||||
min_height = min_height_min;
|
||||
|
100
backend/output.c
100
backend/output.c
@ -31,8 +31,14 @@
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <direct.h>
|
||||
#else
|
||||
#include <sys/stat.h> /* mkdir(2) */
|
||||
#endif
|
||||
#include "common.h"
|
||||
#include "output.h"
|
||||
#include "font.h"
|
||||
@ -241,7 +247,7 @@ static int out_quiet_zones(const struct zint_symbol *symbol, const int hide_text
|
||||
done = 1;
|
||||
break;
|
||||
case BARCODE_CODE128:
|
||||
case BARCODE_CODE128B:
|
||||
case BARCODE_CODE128AB:
|
||||
case BARCODE_HIBC_128:
|
||||
case BARCODE_NVE18:
|
||||
/* ISO/IEC 15417:2007 4.4.2 */
|
||||
@ -250,7 +256,7 @@ static int out_quiet_zones(const struct zint_symbol *symbol, const int hide_text
|
||||
break;
|
||||
case BARCODE_DPLEIT:
|
||||
case BARCODE_DPIDENT:
|
||||
/* Using CODE39 values TODO: Find doc */
|
||||
/* Using C25INTER values TODO: Find doc */
|
||||
*left = *right = 10.0f;
|
||||
done = 1;
|
||||
break;
|
||||
@ -486,7 +492,7 @@ static int out_quiet_zones(const struct zint_symbol *symbol, const int hide_text
|
||||
#ifdef ZINT_TEST /* Wrapper for direct testing */
|
||||
INTERNAL int out_quiet_zones_test(const struct zint_symbol *symbol, const int hide_text,
|
||||
float *left, float *right, float *top, float *bottom) {
|
||||
return out_quiet_zones(symbol, hide_text, left, right, top, bottom);
|
||||
return out_quiet_zones(symbol, hide_text, left, right, top, bottom);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -742,4 +748,90 @@ INTERNAL void out_upcean_split_text(int upceanflag, unsigned char text[],
|
||||
}
|
||||
}
|
||||
|
||||
/* Make a directory; already existing dir okay */
|
||||
/* Adapted from https://gist.github.com/JonathonReinhart/8c0d90191c38af2dcadb102c4e202950 and
|
||||
https://nachtimwald.com/2019/07/10/recursive-create-directory-in-c-revisited/ */
|
||||
static int out_maybe_mkdir(const char* path)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
DWORD dwAttrib;
|
||||
|
||||
/* Try to make the directory */
|
||||
if (CreateDirectory(path, NULL) != 0) { /* Non-zero on success */
|
||||
return 0;
|
||||
}
|
||||
/* If it fails for any reason but already exists, fail */
|
||||
if (GetLastError() != ERROR_ALREADY_EXISTS) {
|
||||
return -1;
|
||||
}
|
||||
/* Check if the existing path is a directory */
|
||||
if ((dwAttrib = GetFileAttributes(path)) == (DWORD) -1 || !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) {
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
struct stat st;
|
||||
|
||||
/* Try to make the directory */
|
||||
if (mkdir(path, 0777) == 0) {
|
||||
return 0;
|
||||
}
|
||||
/* If it fails for any reason but already exists, fail */
|
||||
if (errno != EEXIST) {
|
||||
return -1;
|
||||
}
|
||||
/* Check if the existing path is a directory */
|
||||
if (stat(path, &st) != 0 || !S_ISDIR(st.st_mode)) {
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Create output file, creating sub-directories if necessary. Returns `fopen()` FILE pointer */
|
||||
INTERNAL FILE *out_fopen(const char filename[256], const char *mode) {
|
||||
FILE *outfile;
|
||||
|
||||
if (!(outfile = fopen(filename, mode))) {
|
||||
char dirname[256];
|
||||
char *d;
|
||||
#ifdef _WIN32
|
||||
char *dirend = strrchr(filename, '\\');
|
||||
if (!dirend) {
|
||||
dirend = strrchr(filename, '/');
|
||||
}
|
||||
#else
|
||||
char *dirend = strrchr(filename, '/');
|
||||
#endif
|
||||
if (!dirend) {
|
||||
return outfile;
|
||||
}
|
||||
|
||||
/* Adapted from https://gist.github.com/JonathonReinhart/8c0d90191c38af2dcadb102c4e202950 */
|
||||
/* Remove filename, leaving directories */
|
||||
memcpy(dirname, filename, dirend - filename);
|
||||
dirname[dirend - filename] = '/';
|
||||
dirname[dirend - filename + 1] = '\0';
|
||||
#if _WIN32
|
||||
for (d = dirname; *d; d++) { /* Convert to Unix separators */
|
||||
if (*d == '\\') {
|
||||
*d = '/';
|
||||
}
|
||||
}
|
||||
#endif
|
||||
for (d = dirname + 1; *d; d++) { /* Ignore slash at start if any */
|
||||
if (*d == '/' && *(d - 1) != '/') { /* Ignore double-slashes */
|
||||
*d = '\0'; /* Temporarily truncate */
|
||||
if (out_maybe_mkdir(dirname) != 0) {
|
||||
return NULL;
|
||||
}
|
||||
*d = '/'; /* Restore */
|
||||
}
|
||||
}
|
||||
outfile = fopen(filename, mode);
|
||||
}
|
||||
|
||||
return outfile;
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
@ -37,6 +37,8 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include <stdio.h> /* For FILE */
|
||||
|
||||
INTERNAL int out_check_colour_options(struct zint_symbol *symbol);
|
||||
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,
|
||||
@ -47,6 +49,7 @@ INTERNAL float out_large_bar_height(struct zint_symbol *symbol, int si, int *row
|
||||
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]);
|
||||
INTERNAL FILE *out_fopen(const char filename[256], const char *mode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -31,12 +31,14 @@
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#include "common.h"
|
||||
#include "output.h"
|
||||
#include "pcx.h" /* PCX header structure */
|
||||
|
||||
/* ZSoft PCX File Format Technical Reference Manual http://bespin.org/~qz/pc-gpe/pcx.txt */
|
||||
@ -68,8 +70,8 @@ INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
|
||||
header.window_ymin = 0;
|
||||
header.window_xmax = symbol->bitmap_width - 1;
|
||||
header.window_ymax = symbol->bitmap_height - 1;
|
||||
header.horiz_dpi = 300;
|
||||
header.vert_dpi = 300;
|
||||
header.horiz_dpi = symbol->dpmm ? (uint16_t) roundf(stripf(symbol->dpmm * 25.4f)) : 300;
|
||||
header.vert_dpi = header.horiz_dpi;
|
||||
|
||||
for (i = 0; i < 48; i++) {
|
||||
header.colourmap[i] = 0x00;
|
||||
@ -98,7 +100,7 @@ INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
|
||||
#endif
|
||||
pcx_file = stdout;
|
||||
} else {
|
||||
if (!(pcx_file = fopen(symbol->outfile, "wb"))) {
|
||||
if (!(pcx_file = out_fopen(symbol->outfile, "wb"))) {
|
||||
sprintf(symbol->errtxt, "621: Could not open output file (%d: %.30s)", errno, strerror(errno));
|
||||
return ZINT_ERROR_FILE_ACCESS;
|
||||
}
|
||||
|
@ -1132,7 +1132,7 @@ static int pdf_initial_segs(struct zint_symbol *symbol, struct zint_seg segs[],
|
||||
if (symbol->structapp.id[0]) {
|
||||
int id_len;
|
||||
|
||||
for (id_len = 0; id_len < 32 && symbol->structapp.id[id_len]; id_len++);
|
||||
for (id_len = 1; id_len < 31 && symbol->structapp.id[id_len]; id_len++);
|
||||
|
||||
if (id_len > 30) { /* 10 triplets */
|
||||
strcpy(symbol->errtxt, "742: Structured Append ID too long (30 digit maximum)");
|
||||
|
@ -33,6 +33,7 @@
|
||||
#ifndef ZINT_NO_PNG
|
||||
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <fcntl.h>
|
||||
@ -42,6 +43,7 @@
|
||||
#include <zlib.h>
|
||||
#include <setjmp.h>
|
||||
#include "common.h"
|
||||
#include "output.h"
|
||||
|
||||
/* Note if change this need to change "backend/tests/test_png.c" definition also */
|
||||
struct wpng_error_type {
|
||||
@ -232,7 +234,7 @@ INTERNAL int png_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
|
||||
#endif
|
||||
outfile = stdout;
|
||||
} else {
|
||||
if (!(outfile = fopen(symbol->outfile, "wb"))) {
|
||||
if (!(outfile = out_fopen(symbol->outfile, "wb"))) {
|
||||
sprintf(symbol->errtxt, "632: Could not open output file (%d: %.30s)", errno, strerror(errno));
|
||||
return ZINT_ERROR_FILE_ACCESS;
|
||||
}
|
||||
@ -279,6 +281,11 @@ INTERNAL int png_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
|
||||
png_set_compression_strategy(png_ptr, compression_strategy);
|
||||
}
|
||||
|
||||
if (symbol->dpmm) {
|
||||
int resolution = (int) roundf(stripf(symbol->dpmm * 1000.0f)); /* pixels per metre */
|
||||
png_set_pHYs(png_ptr, info_ptr, resolution, resolution, PNG_RESOLUTION_METER);
|
||||
}
|
||||
|
||||
/* set Header block */
|
||||
png_set_IHDR(png_ptr, info_ptr, symbol->bitmap_width, symbol->bitmap_height,
|
||||
bit_depth, PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE,
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include "common.h"
|
||||
#include "output.h"
|
||||
|
||||
static void colour_to_pscolor(int option, int colour, char *output) {
|
||||
*output = '\0';
|
||||
@ -174,7 +175,7 @@ INTERNAL int ps_plot(struct zint_symbol *symbol) {
|
||||
if (output_to_stdout) {
|
||||
feps = stdout;
|
||||
} else {
|
||||
if (!(feps = fopen(symbol->outfile, "w"))) {
|
||||
if (!(feps = out_fopen(symbol->outfile, "w"))) {
|
||||
sprintf(symbol->errtxt, "645: Could not open output file (%d: %.30s)", errno, strerror(errno));
|
||||
return ZINT_ERROR_FILE_ACCESS;
|
||||
}
|
||||
|
@ -1620,9 +1620,9 @@ INTERNAL int qrcode(struct zint_symbol *symbol, struct zint_seg segs[], const in
|
||||
if (symbol->structapp.id[0]) {
|
||||
int id, id_len;
|
||||
|
||||
for (id_len = 0; id_len < 32 && symbol->structapp.id[id_len]; id_len++);
|
||||
for (id_len = 1; id_len < 4 && symbol->structapp.id[id_len]; id_len++);
|
||||
|
||||
if (id_len > 3) { /* 255 */
|
||||
if (id_len > 3) { /* Max value 255 */
|
||||
strcpy(symbol->errtxt, "752: Structured Append ID too long (3 digit maximum)");
|
||||
return ZINT_ERROR_INVALID_OPTION;
|
||||
}
|
||||
|
@ -688,7 +688,8 @@ static void draw_bind_box(const struct zint_symbol *symbol, unsigned char *pixel
|
||||
const int width_si = symbol->width * si;
|
||||
draw_bar(pixelbuf, xoffset_si, width_si, ybind_top, bwidth_si, image_width, image_height, DEFAULT_INK);
|
||||
if (!(symbol->output_options & BARCODE_BIND_TOP)) { /* Trumps BARCODE_BOX & BARCODE_BIND */
|
||||
draw_bar(pixelbuf, xoffset_si, width_si, ybind_bot, bwidth_si, image_width, image_height, DEFAULT_INK);
|
||||
draw_bar(pixelbuf, xoffset_si, width_si, ybind_bot, bwidth_si, image_width, image_height,
|
||||
DEFAULT_INK);
|
||||
}
|
||||
}
|
||||
if (symbol->output_options & BARCODE_BOX) {
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "output.h"
|
||||
|
||||
static void pick_colour(int colour, char colour_code[]) {
|
||||
switch (colour) {
|
||||
@ -183,7 +184,7 @@ INTERNAL int svg_plot(struct zint_symbol *symbol) {
|
||||
if (symbol->output_options & BARCODE_STDOUT) {
|
||||
fsvg = stdout;
|
||||
} else {
|
||||
if (!(fsvg = fopen(symbol->outfile, "w"))) {
|
||||
if (!(fsvg = out_fopen(symbol->outfile, "w"))) {
|
||||
sprintf(symbol->errtxt, "680: Could not open output file (%d: %.30s)", errno, strerror(errno));
|
||||
return ZINT_ERROR_FILE_ACCESS;
|
||||
}
|
||||
|
@ -62,21 +62,25 @@ To run a single dataset item in a single test function, use '-i <index>':
|
||||
|
||||
backend/tests/test_dotcode -f input -i 2
|
||||
|
||||
To run a range of dataset items in a single test function, use '-i <start>,<end>':
|
||||
To run a range of dataset items in a single test function, use '-i <start>-<end>':
|
||||
|
||||
backend/tests/test_dotcode -f input -i 2,5
|
||||
backend/tests/test_dotcode -f input -i 2-5
|
||||
|
||||
To exclude a single dataset item in a single test function, use '-x <index>':
|
||||
|
||||
backend/tests/test_dotcode -f input -x 4
|
||||
|
||||
This can also take a range, '-x <start>,<end>':
|
||||
This can also take a range, '-x <start>-<end>':
|
||||
|
||||
backend/tests/test_dotcode -f input -x 4,6
|
||||
|
||||
Exclude can be used multiple times (unlike '-i'):
|
||||
|
||||
backend/tests/test_dotcode -f input -x 4 -x 6-8
|
||||
|
||||
The include and exclude options can be used together:
|
||||
|
||||
backend/tests/test_dotcode -f input -i 2,7 -x 4
|
||||
backend/tests/test_dotcode -f input -i 2-7 -x 4 -x 6
|
||||
|
||||
To show debug info (if any), use '-d <flag>':
|
||||
|
||||
|
Binary file not shown.
BIN
backend/tests/data/emf/code128_egrave_bold_100dpi.emf
Normal file
BIN
backend/tests/data/emf/code128_egrave_bold_100dpi.emf
Normal file
Binary file not shown.
BIN
backend/tests/data/emf/code128_egrave_bold_1200dpi.emf
Normal file
BIN
backend/tests/data/emf/code128_egrave_bold_1200dpi.emf
Normal file
Binary file not shown.
BIN
backend/tests/data/emf/code128_egrave_bold_150dpi.emf
Normal file
BIN
backend/tests/data/emf/code128_egrave_bold_150dpi.emf
Normal file
Binary file not shown.
BIN
backend/tests/data/emf/code128_egrave_bold_300dpi.emf
Normal file
BIN
backend/tests/data/emf/code128_egrave_bold_300dpi.emf
Normal file
Binary file not shown.
BIN
backend/tests/data/emf/code128_egrave_bold_400dpi.emf
Normal file
BIN
backend/tests/data/emf/code128_egrave_bold_400dpi.emf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
backend/tests/data/emf/code39_rotate_90_300dpi.emf
Normal file
BIN
backend/tests/data/emf/code39_rotate_90_300dpi.emf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
backend/tests/data/emf/itf14_bold_600dpi.emf
Normal file
BIN
backend/tests/data/emf/itf14_bold_600dpi.emf
Normal file
Binary file not shown.
Binary file not shown.
BIN
backend/tests/data/emf/maxicode_#185_150dpi.emf
Normal file
BIN
backend/tests/data/emf/maxicode_#185_150dpi.emf
Normal file
Binary file not shown.
BIN
backend/tests/data/emf/maxicode_#185_600dpi.emf
Normal file
BIN
backend/tests/data/emf/maxicode_#185_600dpi.emf
Normal file
Binary file not shown.
Binary file not shown.
BIN
backend/tests/data/emf/maxicode_rotate_90_nobg_300dpi.emf
Normal file
BIN
backend/tests/data/emf/maxicode_rotate_90_nobg_300dpi.emf
Normal file
Binary file not shown.
Binary file not shown.
BIN
backend/tests/data/emf/telenum_fg_bg_150dpi.emf
Normal file
BIN
backend/tests/data/emf/telenum_fg_bg_150dpi.emf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
backend/tests/data/emf/ultracode_fg_bg_box2_600dpi.emf
Normal file
BIN
backend/tests/data/emf/ultracode_fg_bg_box2_600dpi.emf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
backend/tests/data/emf/upce_2addon_150dpi.emf
Normal file
BIN
backend/tests/data/emf/upce_2addon_150dpi.emf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -135,10 +135,10 @@ static void test_hrt(const testCtx *const p_ctx) {
|
||||
/* 15*/ { BARCODE_C25IND, -1, "123456789", "123456789" },
|
||||
/* 16*/ { BARCODE_C25IND, 1, "123456789", "1234567895" },
|
||||
/* 17*/ { BARCODE_C25IND, 2, "123456789", "123456789" },
|
||||
/* 18*/ { BARCODE_DPLEIT, -1, "123456789", "00001234567890" }, /* Leading zeroes added to make 13 + appended checksum */
|
||||
/* 19*/ { BARCODE_DPLEIT, -1, "1234567890123", "12345678901236" },
|
||||
/* 20*/ { BARCODE_DPIDENT, -1, "123456789", "001234567890" }, /* Leading zeroes added to make 11 + appended checksum */
|
||||
/* 21*/ { BARCODE_DPIDENT, -1, "12345678901", "123456789016" },
|
||||
/* 18*/ { BARCODE_DPLEIT, -1, "123456789", "00001.234.567.890" }, /* Leading zeroes added to make 13 + appended checksum */
|
||||
/* 19*/ { BARCODE_DPLEIT, -1, "1234567890123", "12345.678.901.236" },
|
||||
/* 20*/ { BARCODE_DPIDENT, -1, "123456789", "00.12 3.456.789 0" }, /* Leading zeroes added to make 11 + appended checksum */
|
||||
/* 21*/ { BARCODE_DPIDENT, -1, "12345678901", "12.34 5.678.901 6" },
|
||||
/* 22*/ { BARCODE_ITF14, -1, "123456789", "00001234567895" }, /* Leading zeroes added to make 13 + appended checksum */
|
||||
/* 23*/ { BARCODE_ITF14, -1, "1234567890123", "12345678901231" },
|
||||
};
|
||||
@ -282,25 +282,31 @@ static void test_encode(const testCtx *const p_ctx) {
|
||||
/* 15*/ { BARCODE_DPLEIT, -1, "0000087654321", 0, 1, 135, "Deutsche Post Leitcode; verified manually against tec-it",
|
||||
"101010101110001110001010101110001110001010001011101110001010100010001110111011101011100010100011101110001010100011101000100010111011101"
|
||||
},
|
||||
/* 16*/ { BARCODE_DPLEIT, -1, "5082300702800", 0, 1, 135, "Deutsche Post Leitcode https://de.wikipedia.org/wiki/Leitcode example",
|
||||
/* 16*/ { BARCODE_DPLEIT, -1, "2045703000360", 0, 1, 135, "Deutsche Post DIALOGPOST SCHWER brochure 3.1 example",
|
||||
"101010111010001000111010001011100010111010101000111000111011101110100010001010101110001110001011101110001000101010001011100011101011101"
|
||||
},
|
||||
/* 17*/ { BARCODE_DPLEIT, -1, "5082300702800", 0, 1, 135, "Deutsche Post Leitcode https://de.wikipedia.org/wiki/Leitcode example",
|
||||
"101011101011100010001011101000101110100011101110100010001010101110111000100010100011101110100011101010001110001010001011100011101011101"
|
||||
},
|
||||
/* 17*/ { BARCODE_DPIDENT, -1, "00087654321", 0, 1, 117, "Deutsche Post Identcode; verified manually against tec-it",
|
||||
/* 18*/ { BARCODE_DPIDENT, -1, "00087654321", 0, 1, 117, "Deutsche Post Identcode; verified manually against tec-it (HRT differently formatted)",
|
||||
"101010101110001110001010001011101110001010100010001110111011101011100010100011101110001010100011101000100010111011101"
|
||||
},
|
||||
/* 18*/ { BARCODE_DPIDENT, -1, "39601313414", 0, 1, 117, "Deutsche Post Identcode https://de.wikipedia.org/wiki/Leitcode example",
|
||||
/* 19*/ { BARCODE_DPIDENT, -1, "80420000001", 0, 1, 117, "Deutsche Post DIALOGPOST SCHWER brochure 3.1 example",
|
||||
"101011101010001110001010100011101011100010101110001110001010101110001110001010101110001110001011101010001000111011101"
|
||||
},
|
||||
/* 20*/ { BARCODE_DPIDENT, -1, "39601313414", 0, 1, 117, "Deutsche Post Identcode https://de.wikipedia.org/wiki/Leitcode example",
|
||||
"101011101110001010001010111011100010001011100010001010111011100010001010111010001011101011100010101110001000111011101"
|
||||
},
|
||||
/* 19*/ { BARCODE_ITF14, -1, "0000087654321", 0, 1, 135, "ITF-14; verified manually against tec-it",
|
||||
/* 21*/ { BARCODE_ITF14, -1, "0000087654321", 0, 1, 135, "ITF-14; verified manually against tec-it",
|
||||
"101010101110001110001010101110001110001010001011101110001010100010001110111011101011100010100011101110001010100011101000101011100011101"
|
||||
},
|
||||
/* 20*/ { BARCODE_ITF14, -1, "0950110153000", 0, 1, 135, "GS1 General Specifications Figure 5.1-2",
|
||||
/* 22*/ { BARCODE_ITF14, -1, "0950110153000", 0, 1, 135, "GS1 General Specifications Figure 5.1-2",
|
||||
"101010100011101110001011101011100010001011100010101011100010001011101110100011100010001110101010101110001110001010001000111011101011101"
|
||||
},
|
||||
/* 21*/ { BARCODE_ITF14, -1, "1540014128876", 0, 1, 135, "GS1 General Specifications Figure 5.3.2.4-1",
|
||||
/* 23*/ { BARCODE_ITF14, -1, "1540014128876", 0, 1, 135, "GS1 General Specifications Figure 5.3.2.4-1",
|
||||
"101011100010100010111010101110001000111010001011101110100010001011101011100010001110101000111011101010111000100010001110001110101011101"
|
||||
},
|
||||
/* 22*/ { BARCODE_ITF14, -1, "0950110153001", 0, 1, 135, "GS1 General Specifications Figure 5.3.6-1",
|
||||
/* 24*/ { BARCODE_ITF14, -1, "0950110153001", 0, 1, 135, "GS1 General Specifications Figure 5.3.6-1",
|
||||
"101010100011101110001011101011100010001011100010101011100010001011101110100011100010001110101010101110001110001011101010001000111011101"
|
||||
},
|
||||
};
|
||||
|
@ -65,7 +65,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
|
||||
|
||||
char data_buf[8 * 2 + 1];
|
||||
|
||||
int have_identify = testUtilHaveIdentify();
|
||||
const char *const have_identify = testUtilHaveIdentify();
|
||||
|
||||
testStart("test_pixel_plot");
|
||||
|
||||
@ -104,7 +104,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
|
||||
|
||||
if (ret < ZINT_ERROR) {
|
||||
if (have_identify) {
|
||||
ret = testUtilVerifyIdentify(symbol->outfile, debug);
|
||||
ret = testUtilVerifyIdentify(have_identify, symbol->outfile, debug);
|
||||
assert_zero(ret, "i:%d identify %s ret %d != 0\n", i, symbol->outfile, ret);
|
||||
}
|
||||
if (!(debug & ZINT_DEBUG_TEST_KEEP_OUTFILE)) {
|
||||
@ -156,7 +156,7 @@ static void test_print(const testCtx *const p_ctx) {
|
||||
char escaped[1024];
|
||||
int escaped_size = 1024;
|
||||
|
||||
int have_identify = testUtilHaveIdentify();
|
||||
const char *const have_identify = testUtilHaveIdentify();
|
||||
|
||||
testStart("test_print");
|
||||
|
||||
@ -211,7 +211,7 @@ static void test_print(const testCtx *const p_ctx) {
|
||||
ret = testUtilRename(symbol->outfile, expected_file);
|
||||
assert_zero(ret, "i:%d testUtilRename(%s, %s) ret %d != 0 (%d: %s)\n", i, symbol->outfile, expected_file, ret, errno, strerror(errno));
|
||||
if (have_identify) {
|
||||
ret = testUtilVerifyIdentify(expected_file, debug);
|
||||
ret = testUtilVerifyIdentify(have_identify, expected_file, debug);
|
||||
assert_zero(ret, "i:%d %s identify %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), expected_file, ret);
|
||||
}
|
||||
} else {
|
||||
@ -242,10 +242,13 @@ static void test_outfile(const testCtx *const p_ctx) {
|
||||
symbol.bitmap = data;
|
||||
symbol.bitmap_width = symbol.bitmap_height = 1;
|
||||
|
||||
strcpy(symbol.outfile, "nosuch_dir/out.bmp");
|
||||
strcpy(symbol.outfile, "test_bmp_out.bmp");
|
||||
(void) testUtilRmROFile(symbol.outfile); /* In case lying around from previous fail */
|
||||
assert_nonzero(testUtilCreateROFile(symbol.outfile), "bmp_pixel_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
ret = bmp_pixel_plot(&symbol, data);
|
||||
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "bmp_pixel_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
|
||||
assert_zero(testUtilRmROFile(symbol.outfile), "bmp_pixel_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
symbol.output_options |= BARCODE_STDOUT;
|
||||
|
||||
|
@ -55,10 +55,10 @@ static void test_large(const testCtx *const p_ctx) {
|
||||
/* 4*/ { BARCODE_CODE128, "\351A", 41, ZINT_ERROR_TOO_LONG, -1 }, /* 41 chars (+ 20 shifts) */
|
||||
/* 5*/ { BARCODE_CODE128, "0", 120, 0, 695 },
|
||||
/* 6*/ { BARCODE_CODE128, "0", 121, ZINT_ERROR_TOO_LONG, -1 },
|
||||
/* 7*/ { BARCODE_CODE128B, "A", 60, 0, 695 },
|
||||
/* 8*/ { BARCODE_CODE128B, "A", 61, ZINT_ERROR_TOO_LONG, -1 },
|
||||
/* 9*/ { BARCODE_CODE128B, "0", 60, 0, 695 },
|
||||
/* 10*/ { BARCODE_CODE128B, "0", 61, ZINT_ERROR_TOO_LONG, -1 },
|
||||
/* 7*/ { BARCODE_CODE128AB, "A", 60, 0, 695 },
|
||||
/* 8*/ { BARCODE_CODE128AB, "A", 61, ZINT_ERROR_TOO_LONG, -1 },
|
||||
/* 9*/ { BARCODE_CODE128AB, "0", 60, 0, 695 },
|
||||
/* 10*/ { BARCODE_CODE128AB, "0", 61, ZINT_ERROR_TOO_LONG, -1 },
|
||||
/* 11*/ { BARCODE_GS1_128, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]1234567890", -1, 0, 706 }, /* 116 nos + 3 FNC1s */
|
||||
/* 12*/ { BARCODE_GS1_128, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]1234[93]1234", -1, ZINT_ERROR_TOO_LONG, -1 }, /* 116 nos + 4 FNC1s */
|
||||
/* 13*/ { BARCODE_GS1_128, "A", 161, ZINT_ERROR_TOO_LONG, -1 },
|
||||
@ -198,13 +198,13 @@ static void test_hrt(const testCtx *const p_ctx) {
|
||||
struct item data[] = {
|
||||
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, -1, "1234567890", -1, "1234567890" },
|
||||
/* 1*/ { BARCODE_CODE128, UNICODE_MODE, -1, "\000ABC\000DEF\000", 9, " ABC DEF " },
|
||||
/* 2*/ { BARCODE_CODE128B, UNICODE_MODE, -1, "12345\00067890", 11, "12345 67890" },
|
||||
/* 2*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, "12345\00067890", 11, "12345 67890" },
|
||||
/* 3*/ { BARCODE_CODE128, UNICODE_MODE, -1, "12345\01167890\037\177", -1, "12345 67890 " },
|
||||
/* 4*/ { BARCODE_CODE128, UNICODE_MODE, -1, "abcdé", -1, "abcdé" },
|
||||
/* 5*/ { BARCODE_CODE128, DATA_MODE, -1, "abcd\351", -1, "abcdé" },
|
||||
/* 6*/ { BARCODE_CODE128, DATA_MODE, -1, "ab\240cd\351", -1, "ab\302\240cdé" }, /* NBSP */
|
||||
/* 7*/ { BARCODE_CODE128B, UNICODE_MODE, -1, "abcdé", -1, "abcdé" },
|
||||
/* 8*/ { BARCODE_CODE128B, DATA_MODE, -1, "abcd\351", -1, "abcdé" },
|
||||
/* 7*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, "abcdé", -1, "abcdé" },
|
||||
/* 8*/ { BARCODE_CODE128AB, DATA_MODE, -1, "abcd\351", -1, "abcdé" },
|
||||
/* 9*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, "1234567890", -1, "*+12345678900*" },
|
||||
/* 10*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, "a99912345", -1, "*+A999123457*" }, /* Converts to upper */
|
||||
/* 11*/ { BARCODE_DPD, UNICODE_MODE, -1, "000393206219912345678101040", -1, "0003 932 0621 9912 3456 78 101 040 9" }, /* DPDAPPD 4.0.2 - Illustration 7 */
|
||||
@ -281,7 +281,7 @@ static void test_reader_init(const testCtx *const p_ctx) {
|
||||
struct item data[] = {
|
||||
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, READER_INIT, "A", 0, 1, 57, "(5) 104 96 33 60 106", "StartA FNC3 A" },
|
||||
/* 1*/ { BARCODE_CODE128, UNICODE_MODE, READER_INIT, "12", 0, 1, 68, "(6) 104 96 99 12 22 106", "StartB FNC3 CodeC 12" },
|
||||
/* 2*/ { BARCODE_CODE128B, UNICODE_MODE, READER_INIT, "\0371234", 0, 1, 101, "(9) 103 96 95 17 18 19 20 6 106", "StartA FNC3 US 1 2 3 4" },
|
||||
/* 2*/ { BARCODE_CODE128AB, UNICODE_MODE, READER_INIT, "\0371234", 0, 1, 101, "(9) 103 96 95 17 18 19 20 6 106", "StartA FNC3 US 1 2 3 4" },
|
||||
/* 3*/ { BARCODE_GS1_128, GS1_MODE, READER_INIT, "[90]12", 0, 1, 68, "(6) 105 102 90 12 11 106", "StartC FNC1 90 12 (Reader Initialise not supported by GS1 barcodes (use CODE128))" },
|
||||
/* 4*/ { BARCODE_EAN14, GS1_MODE, READER_INIT, "12", 0, 1, 134, "(12) 105 102 1 0 0 0 0 0 1 23 12 106", "StartC FNC1 01 00 (5) 01 23 (Reader Initialise not supported by GS1 barcodes (use CODE128))" },
|
||||
/* 5*/ { BARCODE_NVE18, GS1_MODE, READER_INIT, "12", 0, 1, 156, "(14) 105 102 0 0 0 0 0 0 0 0 1 23 58 106", "StartC FNC1 00 (8) 01 23 (Reader Initialise not supported by GS1 barcodes (use CODE128))" },
|
||||
@ -766,13 +766,13 @@ static void test_encode(const testCtx *const p_ctx) {
|
||||
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, -1, "AIM", 0, 1, 68, 1, "ISO/IEC 15417:2007 Figure 1",
|
||||
"11010010000101000110001100010001010111011000101110110001100011101011"
|
||||
},
|
||||
/* 1*/ { BARCODE_CODE128B, UNICODE_MODE, -1, "AIM", 0, 1, 68, 1, "128B same",
|
||||
/* 1*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, "AIM", 0, 1, 68, 1, "128B same",
|
||||
"11010010000101000110001100010001010111011000101110110001100011101011"
|
||||
},
|
||||
/* 2*/ { BARCODE_CODE128, UNICODE_MODE, -1, "1234567890", 0, 1, 90, 1, "",
|
||||
"110100111001011001110010001011000111000101101100001010011011110110100111100101100011101011"
|
||||
},
|
||||
/* 3*/ { BARCODE_CODE128B, UNICODE_MODE, -1, "1234567890", 0, 1, 145, 1, "",
|
||||
/* 3*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, "1234567890", 0, 1, 145, 1, "",
|
||||
"1101001000010011100110110011100101100101110011001001110110111001001100111010011101101110111010011001110010110010011101100101000110001100011101011"
|
||||
},
|
||||
/* 4*/ { BARCODE_CODE128, DATA_MODE, -1, "\101\102\103\104\105\106\200\200\200\200\200", 0, 1, 178, 1, "",
|
||||
|
@ -266,9 +266,9 @@ static void test_reduced_charset_input(const testCtx *const p_ctx) {
|
||||
/*121*/ { BARCODE_MAXICODE, UNICODE_MODE, 29, "齄齄", 0, 29, "U+9F44 in GB2312 but not in Big5" },
|
||||
/*122*/ { BARCODE_MAXICODE, UNICODE_MODE, 30, "가", 0, 30, "U+AC00 in EUC-KR" },
|
||||
/*123*/ { BARCODE_MAXICODE, UNICODE_MODE, 30, "가가", 0, 30, "U+AC00 in EUC-KR" },
|
||||
/*124*/ { BARCODE_CODE128B, UNICODE_MODE, 0, "é", 0, 0, "" },
|
||||
/*125*/ { BARCODE_CODE128B, UNICODE_MODE, 3, "é", ZINT_ERROR_INVALID_OPTION, -1, "Does not support ECI" },
|
||||
/*126*/ { BARCODE_CODE128B, UNICODE_MODE, 0, "β", ZINT_ERROR_INVALID_DATA, -1, "β not in ISO 8859-1" },
|
||||
/*124*/ { BARCODE_CODE128AB, UNICODE_MODE, 0, "é", 0, 0, "" },
|
||||
/*125*/ { BARCODE_CODE128AB, UNICODE_MODE, 3, "é", ZINT_ERROR_INVALID_OPTION, -1, "Does not support ECI" },
|
||||
/*126*/ { BARCODE_CODE128AB, UNICODE_MODE, 0, "β", ZINT_ERROR_INVALID_DATA, -1, "β not in ISO 8859-1" },
|
||||
/*127*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 0, "é", 0, 0, "" },
|
||||
/*128*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 3, "é", 0, 3, "Supports ECI" },
|
||||
/*129*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 0, "β", ZINT_WARN_USES_ECI, 9, "" },
|
||||
|
@ -44,6 +44,7 @@ static void test_print(const testCtx *const p_ctx) {
|
||||
int whitespace_height;
|
||||
int option_1;
|
||||
int option_2;
|
||||
float dpmm;
|
||||
char *fgcolour;
|
||||
char *bgcolour;
|
||||
int rotate_angle;
|
||||
@ -52,21 +53,34 @@ static void test_print(const testCtx *const p_ctx) {
|
||||
char *comment;
|
||||
};
|
||||
struct item data[] = {
|
||||
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, "", "", 0, "Égjpqy", "code128_egrave_bold.emf", "" },
|
||||
/* 1*/ { BARCODE_TELEPEN, -1, -1, -1, -1, -1, -1, -1, "147AD0", "FC9630", 0, "123", "telenum_fg_bg.emf", "" },
|
||||
/* 2*/ { BARCODE_ULTRA, -1, -1, -1, 5, -1, -1, -1, "147AD0", "FC9630", 0, "123", "ultracode_fg_bg.emf", "" },
|
||||
/* 3*/ { BARCODE_ULTRA, -1, 2, BARCODE_BOX, 2, 2, -1, -1, "FF0000", "0000FF", 0, "123", "ultracode_fg_bg_box2.emf", "" },
|
||||
/* 4*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, "", "", 0, "9780877799306+54321", "ean13_5addon_ggs_5.2.2.5.2-2.emf", "" },
|
||||
/* 5*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, "", "", 0, "210987654321+54321", "ean13_5addon_#185.emf", "#185 Byte count, font data, HeaderExtension1/2" },
|
||||
/* 6*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, -1, -1, "", "", 0, "012345678905+24", "upca_2addon_ggs_5.2.6.6-5.emf", "" },
|
||||
/* 7*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, -1, "", "", 0, "0123456+12", "upce_2addon.emf", "" },
|
||||
/* 8*/ { BARCODE_UPCE, -1, -1, SMALL_TEXT | BOLD_TEXT, -1, -1, -1, -1, "", "", 0, "0123456+12", "upce_2addon_small_bold.emf", "" },
|
||||
/* 9*/ { BARCODE_ITF14, -1, -1, BOLD_TEXT, -1, -1, -1, -1, "", "", 0, "123", "itf14_bold.emf", "" },
|
||||
/* 10*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, -1, -1, "", "", 90, "123", "code39_rotate_90.emf", "" },
|
||||
/* 11*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, -1, -1, "", "", 180, "123", "code39_rotate_180.emf", "" },
|
||||
/* 12*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, -1, -1, "", "", 270, "123", "code39_rotate_270.emf", "" },
|
||||
/* 13*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, "E0E0E0", "700070", 0, "THIS IS A 93 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, UNAPPENDED, MAXICODE SYMBOL...", "maxicode_#185.emf", "#185 Maxicode scaling" },
|
||||
/* 14*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, "", "FFFFFF00", 90, "THIS IS A 93 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, UNAPPENDED, MAXICODE SYMBOL...", "maxicode_rotate_90_nobg.emf", "" },
|
||||
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, 0, "", "", 0, "Égjpqy", "code128_egrave_bold.emf", "" },
|
||||
/* 1*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, 100.0f / 25.4f, "", "", 0, "Égjpqy", "code128_egrave_bold_100dpi.emf", "" },
|
||||
/* 2*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, 150.0f / 25.4f, "", "", 0, "Égjpqy", "code128_egrave_bold_150dpi.emf", "" },
|
||||
/* 3*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, 300.0f / 25.4f, "", "", 0, "Égjpqy", "code128_egrave_bold_300dpi.emf", "" },
|
||||
/* 4*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, 400.0f / 25.4f, "", "", 0, "Égjpqy", "code128_egrave_bold_400dpi.emf", "" },
|
||||
/* 5*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, 1200.0f / 25.4f, "", "", 0, "Égjpqy", "code128_egrave_bold_1200dpi.emf", "" },
|
||||
/* 6*/ { BARCODE_TELEPEN, -1, -1, -1, -1, -1, -1, -1, 0, "147AD0", "FC9630", 0, "123", "telenum_fg_bg.emf", "" },
|
||||
/* 7*/ { BARCODE_TELEPEN, -1, -1, -1, -1, -1, -1, -1, 150.0f / 25.4f, "147AD0", "FC9630", 0, "123", "telenum_fg_bg_150dpi.emf", "" },
|
||||
/* 8*/ { BARCODE_ULTRA, -1, -1, -1, 5, -1, -1, -1, 0, "147AD0", "FC9630", 0, "123", "ultracode_fg_bg.emf", "" },
|
||||
/* 9*/ { BARCODE_ULTRA, -1, 2, BARCODE_BOX, 2, 2, -1, -1, 0, "FF0000", "0000FF", 0, "123", "ultracode_fg_bg_box2.emf", "" },
|
||||
/* 10*/ { BARCODE_ULTRA, -1, 2, BARCODE_BOX, 2, 2, -1, -1, 600.0f / 25.4f, "FF0000", "0000FF", 0, "123", "ultracode_fg_bg_box2_600dpi.emf", "" },
|
||||
/* 11*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, 0, "", "", 0, "9780877799306+54321", "ean13_5addon_ggs_5.2.2.5.2-2.emf", "" },
|
||||
/* 12*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, 0, "", "", 0, "210987654321+54321", "ean13_5addon_#185.emf", "#185 Byte count, font data, HeaderExtension1/2" },
|
||||
/* 13*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, -1, -1, 0, "", "", 0, "012345678905+24", "upca_2addon_ggs_5.2.6.6-5.emf", "" },
|
||||
/* 14*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, -1, 0, "", "", 0, "0123456+12", "upce_2addon.emf", "" },
|
||||
/* 15*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, -1, 150.f / 25.4f, "", "", 0, "0123456+12", "upce_2addon_150dpi.emf", "" },
|
||||
/* 16*/ { BARCODE_UPCE, -1, -1, SMALL_TEXT | BOLD_TEXT, -1, -1, -1, -1, 0, "", "", 0, "0123456+12", "upce_2addon_small_bold.emf", "" },
|
||||
/* 17*/ { BARCODE_ITF14, -1, -1, BOLD_TEXT, -1, -1, -1, -1, 0, "", "", 0, "123", "itf14_bold.emf", "" },
|
||||
/* 18*/ { BARCODE_ITF14, -1, -1, BOLD_TEXT, -1, -1, -1, -1, 600.f / 25.4f, "", "", 0, "123", "itf14_bold_600dpi.emf", "" },
|
||||
/* 19*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, -1, -1, 0, "", "", 90, "123", "code39_rotate_90.emf", "" },
|
||||
/* 20*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, -1, -1, 300.f / 25.4f, "", "", 90, "123", "code39_rotate_90_300dpi.emf", "" },
|
||||
/* 21*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, -1, -1, 0, "", "", 180, "123", "code39_rotate_180.emf", "" },
|
||||
/* 22*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, -1, -1, 0, "", "", 270, "123", "code39_rotate_270.emf", "" },
|
||||
/* 23*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, 0, "E0E0E0", "700070", 0, "THIS IS A 93 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, UNAPPENDED, MAXICODE SYMBOL...", "maxicode_#185.emf", "#185 Maxicode scaling" },
|
||||
/* 24*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, 150.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_150dpi.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", "" },
|
||||
/* 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", "" },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
@ -111,6 +125,10 @@ static void test_print(const testCtx *const p_ctx) {
|
||||
if (data[i].whitespace_height != -1) {
|
||||
symbol->whitespace_height = data[i].whitespace_height;
|
||||
}
|
||||
if (data[i].dpmm) {
|
||||
symbol->dpmm = data[i].dpmm;
|
||||
symbol->scale = ZBarcode_Scale_From_XdimDp(symbol->symbology, ZBarcode_Default_Xdim(symbol->symbology), symbol->dpmm, "EMF");
|
||||
}
|
||||
if (*data[i].fgcolour) {
|
||||
strcpy(symbol->fgcolour, data[i].fgcolour);
|
||||
}
|
||||
@ -128,10 +146,10 @@ static void test_print(const testCtx *const p_ctx) {
|
||||
assert_nonzero(testUtilDataPath(expected_file, sizeof(expected_file), data_dir, data[i].expected_file), "i:%d testUtilDataPath == 0\n", i);
|
||||
|
||||
if (p_ctx->generate) {
|
||||
printf(" /*%3d*/ { %s, %s, %d, %s, %d, %d, %d, %d, \"%s\", \"%s\", %d, \"%s\", \"%s\", \"%s\" },\n",
|
||||
printf(" /*%3d*/ { %s, %s, %d, %s, %d, %d, %d, %d, %g, \"%s\", \"%s\", %d, \"%s\", \"%s\", \"%s\" },\n",
|
||||
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].border_width,
|
||||
testUtilOutputOptionsName(data[i].output_options), data[i].whitespace_width, data[i].whitespace_height,
|
||||
data[i].option_1, data[i].option_2, data[i].fgcolour, data[i].bgcolour, data[i].rotate_angle,
|
||||
data[i].option_1, data[i].option_2, data[i].dpmm, data[i].fgcolour, data[i].bgcolour, data[i].rotate_angle,
|
||||
testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].expected_file, data[i].comment);
|
||||
ret = testUtilRename(symbol->outfile, expected_file);
|
||||
assert_zero(ret, "i:%d testUtilRename(%s, %s) ret %d != 0\n", i, symbol->outfile, expected_file, ret);
|
||||
@ -170,10 +188,13 @@ static void test_outfile(const testCtx *const p_ctx) {
|
||||
symbol.symbology = BARCODE_CODE128;
|
||||
symbol.vector = &vector;
|
||||
|
||||
strcpy(symbol.outfile, "nosuch_dir/out.emf");
|
||||
strcpy(symbol.outfile, "test_emf_out.emf");
|
||||
(void) testUtilRmROFile(symbol.outfile); /* In case lying around from previous fail */
|
||||
assert_nonzero(testUtilCreateROFile(symbol.outfile), "emf_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
ret = emf_plot(&symbol, 0);
|
||||
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "emf_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
|
||||
assert_zero(testUtilRmROFile(symbol.outfile), "emf_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
symbol.output_options |= BARCODE_STDOUT;
|
||||
|
||||
|
@ -65,7 +65,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
|
||||
|
||||
char data_buf[19 * 32 + 1]; /* 19 * 32 == 608 */
|
||||
|
||||
int have_identify = testUtilHaveIdentify();
|
||||
const char *const have_identify = testUtilHaveIdentify();
|
||||
|
||||
testStart("test_pixel_plot");
|
||||
|
||||
@ -100,7 +100,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
|
||||
|
||||
if (ret < ZINT_ERROR) {
|
||||
if (have_identify) {
|
||||
ret = testUtilVerifyIdentify(symbol->outfile, debug);
|
||||
ret = testUtilVerifyIdentify(have_identify, symbol->outfile, debug);
|
||||
assert_zero(ret, "i:%d identify %s ret %d != 0\n", i, symbol->outfile, ret);
|
||||
}
|
||||
if (!(debug & ZINT_DEBUG_TEST_KEEP_OUTFILE)) {
|
||||
@ -184,7 +184,7 @@ static void test_print(const testCtx *const p_ctx) {
|
||||
char escaped[1024];
|
||||
int escaped_size = 1024;
|
||||
|
||||
int have_identify = testUtilHaveIdentify();
|
||||
const char *const have_identify = testUtilHaveIdentify();
|
||||
|
||||
testStart("test_print");
|
||||
|
||||
@ -251,7 +251,7 @@ static void test_print(const testCtx *const p_ctx) {
|
||||
ret = testUtilRename(symbol->outfile, expected_file);
|
||||
assert_zero(ret, "i:%d testUtilRename(%s, %s) ret %d != 0\n", i, symbol->outfile, expected_file, ret);
|
||||
if (have_identify) {
|
||||
ret = testUtilVerifyIdentify(expected_file, debug);
|
||||
ret = testUtilVerifyIdentify(have_identify, expected_file, debug);
|
||||
assert_zero(ret, "i:%d %s identify %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), expected_file, ret);
|
||||
}
|
||||
} else {
|
||||
@ -282,10 +282,13 @@ static void test_outfile(const testCtx *const p_ctx) {
|
||||
symbol.bitmap = data;
|
||||
symbol.bitmap_width = symbol.bitmap_height = 1;
|
||||
|
||||
strcpy(symbol.outfile, "nosuch_dir/out.gif");
|
||||
strcpy(symbol.outfile, "test_gif_out.gif");
|
||||
(void) testUtilRmROFile(symbol.outfile); /* In case lying around from previous fail */
|
||||
assert_nonzero(testUtilCreateROFile(symbol.outfile), "gif_pixel_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
ret = gif_pixel_plot(&symbol, data);
|
||||
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "gif_pixel_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
|
||||
assert_zero(testUtilRmROFile(symbol.outfile), "gif_pixel_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
symbol.output_options |= BARCODE_STDOUT;
|
||||
|
||||
|
@ -29,10 +29,12 @@
|
||||
*/
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
|
||||
#include "testcommon.h"
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <math.h>
|
||||
#include <sys/stat.h>
|
||||
#include "testcommon.h"
|
||||
#include "../common.h"
|
||||
|
||||
static void test_checks(const testCtx *const p_ctx) {
|
||||
int debug = p_ctx->debug;
|
||||
@ -63,8 +65,8 @@ static void test_checks(const testCtx *const p_ctx) {
|
||||
/* 1*/ { BARCODE_CODE128, -1, "1234", -1, -1, 0, 0, 0, 0, 0, -1, -1, -1, -1, 0, "", -1 },
|
||||
/* 2*/ { BARCODE_QRCODE, -1, "1234", -1, -1, 3, 0, 0, 0, 0, -1, -1, -1, -1, 0, "", -1 },
|
||||
/* 3*/ { BARCODE_QRCODE, -1, "1234", -1, -1, 999999 + 1, 0, 0, 0, 0, -1, -1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 218: Invalid ECI code 1000000", -1 },
|
||||
/* 4*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 0, 0, 0, 0.009, -1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 227: Scale out of range (0.01 to 100)", -1 },
|
||||
/* 5*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 0, 0, 0, 100.01, -1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 227: Scale out of range (0.01 to 100)", -1 },
|
||||
/* 4*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 0, 0, 0, 0.009, -1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 227: Scale out of range (0.01 to 200)", -1 },
|
||||
/* 5*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 0, 0, 0, 200.01, -1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 227: Scale out of range (0.01 to 200)", -1 },
|
||||
/* 6*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 0, 0, 0, -1, 20.1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 221: Dot size out of range (0.01 to 20)", -1 },
|
||||
/* 7*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 0, 0, 0, 0.01, 0.009, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 221: Dot size out of range (0.01 to 20)", -1 },
|
||||
/* 8*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, -0.1, 0, 0, 0, -1, -1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 765: Height out of range (0 to 2000)", -1 },
|
||||
@ -1381,6 +1383,204 @@ static void test_clear(const testCtx *const p_ctx) {
|
||||
testFinish();
|
||||
}
|
||||
|
||||
static void test_scale_from_xdimdp(const testCtx *const p_ctx) {
|
||||
|
||||
struct item {
|
||||
int symbology;
|
||||
float x_dim;
|
||||
float dpmm;
|
||||
int dpi;
|
||||
char *filetype;
|
||||
float expected;
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
struct item data[] = {
|
||||
/* 0*/ { BARCODE_EANX, 0.33f, 2, 50, "gif", 0.5f },
|
||||
/* 1*/ { BARCODE_EANX, 0.33f, 2, 50, "emf", 0.33000001f },
|
||||
/* 2*/ { BARCODE_EANX, 0.33f, 2, 50, "svg", 0.33000001f },
|
||||
/* 3*/ { BARCODE_EANX, 0.33f, 3, 76, "gif", 0.5f },
|
||||
/* 4*/ { BARCODE_EANX, 0.33f, 3, 76, "svg", 0.495f },
|
||||
/* 5*/ { BARCODE_EANX, 0.33f, 4, 100, "gif", 0.5f },
|
||||
/* 6*/ { BARCODE_EANX, 0.33f, 4, 100, "svg", 0.66000003f },
|
||||
/* 7*/ { BARCODE_EANX, 0.33f, 6, 150, "gif", 1 },
|
||||
/* 8*/ { BARCODE_EANX, 0.33f, 6, 150, "svg", 0.99f },
|
||||
/* 9*/ { BARCODE_EANX, 0.33f, 8, 200, "gif", 1.5f },
|
||||
/* 10*/ { BARCODE_EANX, 0.33f, 8, 200, "svg", 1.32f },
|
||||
/* 11*/ { BARCODE_EANX, 0.33f, 12, 300, "gif", 2 },
|
||||
/* 12*/ { BARCODE_EANX, 0.33f, 12, 300, "svg", 1.98f },
|
||||
/* 13*/ { BARCODE_EANX, 0.33f, 16, 400, "gif", 2.5f }, /* NOTE: scale previously documented as 3.0f */
|
||||
/* 14*/ { BARCODE_EANX, 0.33f, 16, 400, "svg", 2.64f },
|
||||
/* 15*/ { BARCODE_EANX, 0.33f, 24, 600, "gif", 4 },
|
||||
/* 16*/ { BARCODE_EANX, 0.33f, 24, 600, "svg", 3.96f },
|
||||
/* 17*/ { BARCODE_EANX, 0.33f, 47, 1200, "gif", 8 },
|
||||
/* 18*/ { BARCODE_EANX, 0.33f, 47, 1200, "emf", 7.755f },
|
||||
/* 19*/ { BARCODE_EANX, 0.33f, 47, 1200, "svg", 7.755f },
|
||||
/* 20*/ { BARCODE_EANX, 0.33f, 94, 2400, "gif", 15.5f }, /* NOTE dpmm previously documented as 95 */
|
||||
/* 21*/ { BARCODE_EANX, 0.33f, 94, 2400, "svg", 15.51f },
|
||||
/* 22*/ { BARCODE_EANX, 0.33f, 189, 4800, "gif", 31 },
|
||||
/* 23*/ { BARCODE_EANX, 0.33f, 189, 4800, "svg", 31.185001f },
|
||||
/* 24*/ { BARCODE_EANX, 0.33f, 378, 9600, "gif", 62.5f },
|
||||
/* 25*/ { BARCODE_EANX, 0.33f, 378, 9600, "svg", 62.370003f },
|
||||
/* 26*/ { BARCODE_MAXICODE, 0.88f, 4, 100, "gif", 0.352f },
|
||||
/* 27*/ { BARCODE_MAXICODE, 0.88f, 4, 100, "emf", 0.1f }, /* NOTE scale rounded up to min 0.1 so doesn't round trip */
|
||||
/* 28*/ { BARCODE_MAXICODE, 0.88f, 4, 100, "svg", 1.76f },
|
||||
/* 29*/ { BARCODE_MAXICODE, 0.88f, 6, 150, "gif", 0.528f }, /* NOTE scale previously documented as 0.5f */
|
||||
/* 30*/ { BARCODE_MAXICODE, 0.88f, 6, 150, "emf", 0.132f },
|
||||
/* 31*/ { BARCODE_MAXICODE, 0.88f, 6, 150, "svg", 2.6399999 },
|
||||
/* 32*/ { BARCODE_MAXICODE, 0.88f, 8, 200, "gif", 0.704f }, /* NOTE scale previously documented as 0.7f */
|
||||
/* 33*/ { BARCODE_MAXICODE, 0.88f, 8, 200, "emf", 0.176f },
|
||||
/* 34*/ { BARCODE_MAXICODE, 0.88f, 8, 200, "svg", 3.52f },
|
||||
/* 35*/ { BARCODE_MAXICODE, 0.88f, 12, 300, "gif", 1.056f }, /* NOTE scale previously documented as 1.0f */
|
||||
/* 36*/ { BARCODE_MAXICODE, 0.88f, 12, 300, "emf", 0.264f },
|
||||
/* 37*/ { BARCODE_MAXICODE, 0.88f, 12, 300, "svg", 5.2799997f },
|
||||
/* 38*/ { BARCODE_MAXICODE, 0.88f, 16, 400, "gif", 1.408f }, /* NOTE scale previously documented as 1.4f */
|
||||
/* 39*/ { BARCODE_MAXICODE, 0.88f, 16, 400, "emf", 0.352f },
|
||||
/* 40*/ { BARCODE_MAXICODE, 0.88f, 16, 400, "gif", 1.408f },
|
||||
/* 41*/ { BARCODE_MAXICODE, 0.88f, 24, 600, "gif", 2.112f }, /* NOTE scale previously documented as 2.1f */
|
||||
/* 42*/ { BARCODE_MAXICODE, 0.88f, 24, 600, "emf", 0.528f },
|
||||
/* 43*/ { BARCODE_MAXICODE, 0.88f, 24, 600, "svg", 10.559999f },
|
||||
/* 44*/ { BARCODE_MAXICODE, 0.88f, 47, 1200, "gif", 4.136f }, /* NOTE scale previously documented as 4.1f */
|
||||
/* 45*/ { BARCODE_MAXICODE, 0.88f, 47, 1200, "emf", 1.034f },
|
||||
/* 46*/ { BARCODE_MAXICODE, 0.88f, 47, 1200, "svg", 20.68f },
|
||||
/* 47*/ { BARCODE_MAXICODE, 0.88f, 94, 2400, "gif", 8.272f }, /* NOTE dpmm previously documented as 95, scale as 8.2f */
|
||||
/* 48*/ { BARCODE_MAXICODE, 0.88f, 94, 2400, "emf", 2.0680001f },
|
||||
/* 49*/ { BARCODE_MAXICODE, 0.88f, 94, 2400, "svg", 41.360001f },
|
||||
/* 50*/ { BARCODE_MAXICODE, 0.88f, 189, 4800, "gif", 16.632f }, /* NOTE scale previously documented as 16.4f */
|
||||
/* 51*/ { BARCODE_MAXICODE, 0.88f, 189, 4800, "emf", 4.158f },
|
||||
/* 52*/ { BARCODE_MAXICODE, 0.88f, 189, 4800, "svg", 83.159996f },
|
||||
/* 53*/ { BARCODE_MAXICODE, 0.88f, 378, 9600, "gif", 33.264f },
|
||||
/* 54*/ { BARCODE_MAXICODE, 0.88f, 378, 9600, "emf", 8.316f },
|
||||
/* 55*/ { BARCODE_MAXICODE, 0.88f, 378, 9600, "svg", 166.31999f },
|
||||
/* 56*/ { BARCODE_PDF417, 0.27f, 2, 50, "gif", 0.5f },
|
||||
/* 57*/ { BARCODE_PDF417, 0.27f, 2, 50, "svg", 0.27000001f },
|
||||
/* 58*/ { BARCODE_PDF417, 0.27f, 6, 150, "gif", 1 },
|
||||
/* 59*/ { BARCODE_PDF417, 0.27f, 6, 150, "svg", 0.81000006f },
|
||||
/* 60*/ { BARCODE_PDF417, 0.27f, 12, 300, "gif", 1.5 },
|
||||
/* 61*/ { BARCODE_PDF417, 0.27f, 12, 300, "svg", 1.6200001f },
|
||||
/* 62*/ { BARCODE_PDF417, 0.27f, 24, 600, "gif", 3 },
|
||||
/* 63*/ { BARCODE_PDF417, 0.27f, 24, 600, "emf", 3.2400002f },
|
||||
/* 64*/ { BARCODE_PDF417, 0.27f, 24, 600, "svg", 3.2400002f },
|
||||
/* 65*/ { BARCODE_PHARMA_TWO, 1, 2, 50, "gif", 1 },
|
||||
/* 66*/ { BARCODE_PHARMA_TWO, 1, 2, 50, "svg", 1 },
|
||||
/* 67*/ { BARCODE_PHARMA_TWO, 1, 6, 150, "gif", 3 },
|
||||
/* 68*/ { BARCODE_PHARMA_TWO, 1, 6, 150, "svg", 3 },
|
||||
/* 69*/ { BARCODE_PHARMA_TWO, 1, 8, 200, "gif", 4 },
|
||||
/* 70*/ { BARCODE_PHARMA_TWO, 1, 8, 200, "svg", 4 },
|
||||
/* 71*/ { BARCODE_PHARMA_TWO, 1, 189, 4800, "gif", 94.5f },
|
||||
/* 72*/ { BARCODE_PHARMA_TWO, 1, 189, 4800, "svg", 94.5f },
|
||||
/* 73*/ { BARCODE_PHARMA_TWO, 1, 378, 9600, "gif", 189 },
|
||||
/* 74*/ { BARCODE_PHARMA_TWO, 1, 378, 9600, "svg", 189 },
|
||||
/* 75*/ { BARCODE_PHARMA_TWO, 1, 401, 10200, "gif", 200 }, /* NOTE scale capped to 200 so doesn't round trip */
|
||||
/* 76*/ { BARCODE_PHARMA_TWO, 1, 401, 10200, "svg", 200 },
|
||||
/* 77*/ { BARCODE_CODE128, 0.5, 12, 300, "gif", 3 },
|
||||
/* 78*/ { BARCODE_CODE128, 0, 12, -1, "gif", 0 }, /* x_dim zero */
|
||||
/* 79*/ { BARCODE_CODE128, 200.1f, 12, -1, "gif", 0 }, /* x_dim > 200 */
|
||||
/* 80*/ { BARCODE_CODE128, 0.5f, -0.1f, -1, "gif", 0 }, /* dpmm neg */
|
||||
/* 81*/ { BARCODE_CODE128, 0.5f, 1000.1, -1, "gif", 0 }, /* dpmm > 1000 */
|
||||
/* 82*/ { BARCODE_CODE128, 0.5f, 300, -1, "abcd", 0 }, /* filetype unknown */
|
||||
/* 83*/ { BARCODE_QRCODE, 10, 31, 800, "gif", 155 },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i;
|
||||
float ret;
|
||||
float x_dim_from_scale;
|
||||
float dpmm_from_dpi;
|
||||
|
||||
testStart("test_scale_from_xdimdp");
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
|
||||
if (testContinue(p_ctx, i)) continue;
|
||||
|
||||
ret = ZBarcode_Scale_From_XdimDp(data[i].symbology, data[i].x_dim, data[i].dpmm, data[i].filetype);
|
||||
assert_equal(ret, data[i].expected, "i:%d ZBarcode_Scale_From_XdimDp(%s, %g, %g, %s) %.8g != %.8g\n",
|
||||
i, testUtilBarcodeName(data[i].symbology), data[i].dpmm, data[i].x_dim, data[i].filetype, ret, data[i].expected);
|
||||
|
||||
if (ret) {
|
||||
dpmm_from_dpi = roundf(data[i].dpi / 25.4f);
|
||||
ret = ZBarcode_Scale_From_XdimDp(data[i].symbology, data[i].x_dim, dpmm_from_dpi, data[i].filetype);
|
||||
assert_equal(ret, data[i].expected, "i:%d ZBarcode_Scale_From_XdimDp(%s, %g (dpi %d), %g, %s) %.8g != %.8g\n",
|
||||
i, testUtilBarcodeName(data[i].symbology), dpmm_from_dpi, data[i].dpi, data[i].x_dim, data[i].filetype, ret, data[i].expected);
|
||||
|
||||
if (data[i].expected > 0.1f && data[i].expected < 200.0f /* Can't round trip scales <= 0.1 or >= 200.0f */
|
||||
&& (data[i].symbology == BARCODE_MAXICODE || strcmp(data[i].filetype, "gif") != 0)) { /* Non-MAXICODE raster rounds to half-increments */
|
||||
x_dim_from_scale = ZBarcode_XdimDp_From_Scale(data[i].symbology, ret, data[i].dpmm, data[i].filetype);
|
||||
x_dim_from_scale = roundf(x_dim_from_scale * 100.0f) / 100.0f;
|
||||
assert_equal(x_dim_from_scale, data[i].x_dim, "i:%d ZBarcode_XdimDp_From_Scale(%s, %g, %g, %s) %.8g != x_dim %.8g\n",
|
||||
i, testUtilBarcodeName(data[i].symbology), ret, data[i].x_dim, data[i].filetype, x_dim_from_scale, data[i].x_dim);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
testFinish();
|
||||
}
|
||||
|
||||
static void test_xdimdp_from_scale(const testCtx *const p_ctx) {
|
||||
|
||||
struct item {
|
||||
int symbology;
|
||||
float scale;
|
||||
float dpmm; /* Note testing "normal" case that want X-dim, not dpmm */
|
||||
int dpi;
|
||||
char *filetype;
|
||||
float expected;
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
struct item data[] = {
|
||||
/* 0*/ { BARCODE_EANX, 1, 6, 150, "gif", 0.33333334f },
|
||||
/* 1*/ { BARCODE_EANX, 1.32f, 8, 200, "gif", 0.33000001f },
|
||||
/* 2*/ { BARCODE_EANX, 1.5f, 8, 200, "gif", 0.375f },
|
||||
/* 3*/ { BARCODE_EANX, 1.98f, 12, 300, "gif", 0.33f },
|
||||
/* 4*/ { BARCODE_EANX, 2, 12, 300, "gif", 0.33333334f },
|
||||
/* 5*/ { BARCODE_EANX, 2, 12, 300, "svg", 0.33333334f },
|
||||
/* 6*/ { BARCODE_EANX, 2.64f, 16, 400, "gif", 0.33f },
|
||||
/* 7*/ { BARCODE_EANX, 2.5f, 16, 400, "gif", 0.3125f },
|
||||
/* 8*/ { BARCODE_EANX, 3.96f, 24, 600, "gif", 0.33f },
|
||||
/* 9*/ { BARCODE_EANX, 3.96f, 24, 600, "svg", 0.33f },
|
||||
/* 10*/ { BARCODE_EANX, 4, 24, 600, "gif", 0.33333334f },
|
||||
/* 11*/ { BARCODE_EANX, 7.755f, 47, 1200, "gif", 0.33f },
|
||||
/* 12*/ { BARCODE_EANX, 8, 47, 1200, "gif", 0.34042552f },
|
||||
/* 13*/ { BARCODE_EANX, 15.51f, 94, 2400, "gif", 0.33f },
|
||||
/* 14*/ { BARCODE_EANX, 15.5f, 94, 2400, "gif", 0.32978722f },
|
||||
/* 15*/ { BARCODE_EANX, 31.185001f, 189, 4800, "gif", 0.33f },
|
||||
/* 16*/ { BARCODE_EANX, 31, 189, 4800, "gif", 0.32804233f },
|
||||
/* 17*/ { BARCODE_MAXICODE, 1, 12, 300, "gif", 0.83333331f },
|
||||
/* 18*/ { BARCODE_MAXICODE, 0.264f, 12, 300, "emf", 0.87999994f },
|
||||
/* 19*/ { BARCODE_MAXICODE, 5.2799997f, 12, 300, "svg", 0.87999994f },
|
||||
/* 20*/ { BARCODE_MAXICODE, 2, 24, 600, "gif", 0.83333331f },
|
||||
/* 21*/ { BARCODE_MAXICODE, 0.528f, 24, 600, "emf", 0.87999994f },
|
||||
/* 22*/ { BARCODE_MAXICODE, 10.559999f, 24, 600, "svg", 0.87999994f },
|
||||
/* 23*/ { BARCODE_CODE128, 0, 12, -1, "gif", 0 }, /* scale zero */
|
||||
/* 24*/ { BARCODE_CODE128, 200.01f, 12, -1, "gif", 0 }, /* scale > 200 */
|
||||
/* 25*/ { BARCODE_CODE128, 0.5f, 0, -1, "gif", 0 }, /* xdim_mm_or_dpmm zero */
|
||||
/* 26*/ { BARCODE_CODE128, 0.5f, 1000.1f, -1, "gif", 0 }, /* xdim_mm_or_dpmm > 1000 */
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i;
|
||||
float ret;
|
||||
float dpmm_from_dpi;
|
||||
|
||||
testStart("test_xdimdp_from_scale");
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
|
||||
if (testContinue(p_ctx, i)) continue;
|
||||
|
||||
ret = ZBarcode_XdimDp_From_Scale(data[i].symbology, data[i].scale, data[i].dpmm, data[i].filetype);
|
||||
assert_equal(ret, data[i].expected, "i:%d ZBarcode_XdimDp_From_Scale(%s, %g, %g, %s) %.8g != %.8g\n",
|
||||
i, testUtilBarcodeName(data[i].symbology), data[i].dpmm, data[i].scale, data[i].filetype, ret, data[i].expected);
|
||||
|
||||
if (ret) {
|
||||
dpmm_from_dpi = roundf(data[i].dpi / 25.4f);
|
||||
ret = ZBarcode_XdimDp_From_Scale(data[i].symbology, data[i].scale, dpmm_from_dpi, data[i].filetype);
|
||||
assert_equal(ret, data[i].expected, "i:%d ZBarcode_XdimDp_From_Scale(%s, %g (dpi %d), %g, %s) %.8g != %.8g\n",
|
||||
i, testUtilBarcodeName(data[i].symbology), dpmm_from_dpi, data[i].dpi, data[i].scale, data[i].filetype, ret, data[i].expected);
|
||||
}
|
||||
}
|
||||
|
||||
testFinish();
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
testFunction funcs[] = { /* name, func */
|
||||
@ -1404,6 +1604,8 @@ int main(int argc, char *argv[]) {
|
||||
{ "test_strip_bom", test_strip_bom },
|
||||
{ "test_zero_outfile", test_zero_outfile },
|
||||
{ "test_clear", test_clear },
|
||||
{ "test_scale_from_xdimdp", test_scale_from_xdimdp },
|
||||
{ "test_xdimdp_from_scale", test_xdimdp_from_scale },
|
||||
};
|
||||
|
||||
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
|
||||
|
@ -44,59 +44,61 @@ static void test_input(const testCtx *const p_ctx) {
|
||||
struct item data[] = {
|
||||
/* 0*/ { "41038422416563762XY11 ", 0, 3, 155 },
|
||||
/* 1*/ { "41038422416563762XY11 ", ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 2*/ { "41038422416563762xy11 ", 0, 3, 155 }, /* Case insensitive */
|
||||
/* 3*/ { "41038422416563762xy11 .", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 4*/ { "0100000000000AA000AA0A", 0, 3, 131, }, /* Length 22, Mailmark C (2 digit chain id) */
|
||||
/* 5*/ { "5100000000000AA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* 1st char format 0-4 only */
|
||||
/* 6*/ { "0000000000000AA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* 2nd char version id 1-4 only */
|
||||
/* 7*/ { "01F0000000000AA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* 3rd char class 0-9A-E only */
|
||||
/* 8*/ { "0100A00000000AA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* 4-5th chars chain id 2 digits */
|
||||
/* 9*/ { "010000000000AAA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* 6-13th chars item id 8 digits */
|
||||
/* 10*/ { "0100000000000 A000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* Remaining chars post code */
|
||||
/* 11*/ { "0100000000000C1I2JQ3N ", 0, 3, 131, }, /* F N F N L L N L S */
|
||||
/* 12*/ { "010000000000091I2JQ3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N F N L L N L S bad 1st F */
|
||||
/* 13*/ { "0100000000000CAI2JQ3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N F N L L N L S bad 1st N */
|
||||
/* 14*/ { "0100000000000C1I2IQ3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N F N L L N L S bad 1st L */
|
||||
/* 15*/ { "0100000000000C1I2IQ3NA", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N F N L L N L S bad S */
|
||||
/* 16*/ { "0100000000000KM12JQ3N ", 0, 3, 131, }, /* F F N N L L N L S */
|
||||
/* 17*/ { "0100000000000K 12JQ3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N L L N L S bad 2nd F (non-numeric otherwise matches last pattern) */
|
||||
/* 18*/ { "0100000000000KM1AJQ3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N L L N L S bad 2nd N */
|
||||
/* 19*/ { "0100000000000KM12JO3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N L L N L S bad 2nd L */
|
||||
/* 20*/ { "0100000000000KM12JQ3NA", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N L L N L S bad S */
|
||||
/* 21*/ { "0100000000000OV123JQ4U", 0, 3, 131, }, /* F F N N N L L N L */
|
||||
/* 22*/ { "01000000000009V123JQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N N L L N L bad 1st F */
|
||||
/* 23*/ { "0100000000000OV12AJQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N N L L N L bad 3rd N */
|
||||
/* 24*/ { "0100000000000OV123JQ4V", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N N L L N L bad 3rd L */
|
||||
/* 25*/ { "0100000000000CI1K3JQ4U", 0, 3, 131, }, /* F F N F N L L N L */
|
||||
/* 26*/ { "0100000000000CI1 3JQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N F N L L N L bad 3rd F (non-numeric otherwise matches pattern above) */
|
||||
/* 27*/ { "0100000000000CIAK3JQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N F N L L N L bad 1st N */
|
||||
/* 28*/ { "0100000000000CI1K3CQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N F N L L N L bad 1st L */
|
||||
/* 29*/ { "0100000000000C12JQ3U ", 0, 3, 131, }, /* F N N L L N L S S */
|
||||
/* 30*/ { "0100000000000912JQ3U ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N L L N L S S bad F */
|
||||
/* 31*/ { "0100000000000C1AJQ3U ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N L L N L S S bad 2nd N */
|
||||
/* 32*/ { "0100000000000C12JO3U ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N L L N L S S bad 2nd L */
|
||||
/* 33*/ { "0100000000000C12JQ3UA ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N L L N L S S bad 1st S */
|
||||
/* 34*/ { "0100000000000C123JQ4U ", 0, 3, 131, }, /* F N N N L L N L S */
|
||||
/* 35*/ { "01000000000009123JQ4U ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N N L L N L S bad F */
|
||||
/* 36*/ { "0100000000000C12AJQ4U ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N N L L N L S bad 3rd N */
|
||||
/* 37*/ { "0100000000000C123JQ4V ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N N L L N L S bad 3rd L */
|
||||
/* 38*/ { "0100000000000C123JQ4U1", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N N L L N L S bad S */
|
||||
/* 39*/ { "01000000000000000AA000AA0A", 0, 3, 155, }, /* Length 26, Mailmark L (6 digit chain id) */
|
||||
/* 40*/ { "010A0000000000000AA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* 4-9th chars chain id 6 digits */
|
||||
/* 41*/ { "010A0000000000000 A000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* Post code */
|
||||
/* 42*/ { "01000000000000000C1I2JQ3N ", 0, 3, 155, }, /* F N F N L L N L S */
|
||||
/* 43*/ { "01000000000000000C1 2JQ3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N F N L L N L S bad 2nd F */
|
||||
/* 44*/ { "01000000000000000KM12JQ3N ", 0, 3, 155, }, /* F F N N L L N L S */
|
||||
/* 45*/ { "01000000000000000KM12JQAN ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N L L N L S bad 3rd N */
|
||||
/* 46*/ { "01000000000000000OV123JQ4U", 0, 3, 155, }, /* F F N N N L L N L */
|
||||
/* 47*/ { "01000000000000000OV123IQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N N L L N L bad 1st L */
|
||||
/* 48*/ { "01000000000000000CI1K3JQ4U", 0, 3, 155, }, /* F F N F N L L N L */
|
||||
/* 49*/ { "010000000000000009I1K3JQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N F N L L N L bad 1st F */
|
||||
/* 50*/ { "01000000000000000C12JQ3U ", 0, 3, 155, }, /* F N N L L N L S S */
|
||||
/* 51*/ { "01000000000000000C12JQ3U A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N L L N L S S bad 2nd S */
|
||||
/* 52*/ { "01000000000000000C123JQ4U ", 0, 3, 155, }, /* F N N N L L N L S */
|
||||
/* 53*/ { "01000000000000000C 23JQ4U ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N N L L N L S bad 1st N (non-alpha otherwise matches 2nd pattern) */
|
||||
/* 54*/ { "41038422416563762XY1", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 2*/ { "4103842241656", ZINT_ERROR_TOO_LONG, -1, -1 }, /* Too short (< 14) */
|
||||
/* 3*/ { "41038422416563", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 4*/ { "41038422416563762xy11 ", 0, 3, 155 }, /* Case insensitive */
|
||||
/* 5*/ { "41038422416563762xy11 .", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
/* 6*/ { "0100000000000AA000AA0A", 0, 3, 131, }, /* Length 22, Mailmark C (2 digit chain id) */
|
||||
/* 7*/ { "5100000000000AA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* 1st char format 0-4 only */
|
||||
/* 8*/ { "0000000000000AA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* 2nd char version id 1-4 only */
|
||||
/* 9*/ { "01F0000000000AA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* 3rd char class 0-9A-E only */
|
||||
/* 10*/ { "0100A00000000AA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* 4-5th chars chain id 2 digits */
|
||||
/* 11*/ { "010000000000AAA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* 6-13th chars item id 8 digits */
|
||||
/* 12*/ { "0100000000000 A000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* Remaining chars post code */
|
||||
/* 13*/ { "0100000000000C1I2JQ3N ", 0, 3, 131, }, /* F N F N L L N L S */
|
||||
/* 14*/ { "010000000000091I2JQ3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N F N L L N L S bad 1st F */
|
||||
/* 15*/ { "0100000000000CAI2JQ3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N F N L L N L S bad 1st N */
|
||||
/* 16*/ { "0100000000000C1I2IQ3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N F N L L N L S bad 1st L */
|
||||
/* 17*/ { "0100000000000C1I2IQ3NA", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N F N L L N L S bad S */
|
||||
/* 18*/ { "0100000000000KM12JQ3N ", 0, 3, 131, }, /* F F N N L L N L S */
|
||||
/* 19*/ { "0100000000000K 12JQ3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N L L N L S bad 2nd F (non-numeric otherwise matches last pattern) */
|
||||
/* 20*/ { "0100000000000KM1AJQ3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N L L N L S bad 2nd N */
|
||||
/* 21*/ { "0100000000000KM12JO3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N L L N L S bad 2nd L */
|
||||
/* 22*/ { "0100000000000KM12JQ3NA", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N L L N L S bad S */
|
||||
/* 23*/ { "0100000000000OV123JQ4U", 0, 3, 131, }, /* F F N N N L L N L */
|
||||
/* 24*/ { "01000000000009V123JQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N N L L N L bad 1st F */
|
||||
/* 25*/ { "0100000000000OV12AJQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N N L L N L bad 3rd N */
|
||||
/* 26*/ { "0100000000000OV123JQ4V", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N N L L N L bad 3rd L */
|
||||
/* 27*/ { "0100000000000CI1K3JQ4U", 0, 3, 131, }, /* F F N F N L L N L */
|
||||
/* 28*/ { "0100000000000CI1 3JQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N F N L L N L bad 3rd F (non-numeric otherwise matches pattern above) */
|
||||
/* 29*/ { "0100000000000CIAK3JQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N F N L L N L bad 1st N */
|
||||
/* 30*/ { "0100000000000CI1K3CQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N F N L L N L bad 1st L */
|
||||
/* 31*/ { "0100000000000C12JQ3U ", 0, 3, 131, }, /* F N N L L N L S S */
|
||||
/* 32*/ { "0100000000000912JQ3U ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N L L N L S S bad F */
|
||||
/* 33*/ { "0100000000000C1AJQ3U ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N L L N L S S bad 2nd N */
|
||||
/* 34*/ { "0100000000000C12JO3U ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N L L N L S S bad 2nd L */
|
||||
/* 35*/ { "0100000000000C12JQ3UA ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N L L N L S S bad 1st S */
|
||||
/* 36*/ { "0100000000000C123JQ4U ", 0, 3, 131, }, /* F N N N L L N L S */
|
||||
/* 37*/ { "01000000000009123JQ4U ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N N L L N L S bad F */
|
||||
/* 38*/ { "0100000000000C12AJQ4U ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N N L L N L S bad 3rd N */
|
||||
/* 39*/ { "0100000000000C123JQ4V ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N N L L N L S bad 3rd L */
|
||||
/* 40*/ { "0100000000000C123JQ4U1", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N N L L N L S bad S */
|
||||
/* 41*/ { "01000000000000000AA000AA0A", 0, 3, 155, }, /* Length 26, Mailmark L (6 digit chain id) */
|
||||
/* 42*/ { "010A0000000000000AA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* 4-9th chars chain id 6 digits */
|
||||
/* 43*/ { "010A0000000000000 A000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* Post code */
|
||||
/* 44*/ { "01000000000000000C1I2JQ3N ", 0, 3, 155, }, /* F N F N L L N L S */
|
||||
/* 45*/ { "01000000000000000C1 2JQ3N ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N F N L L N L S bad 2nd F */
|
||||
/* 46*/ { "01000000000000000KM12JQ3N ", 0, 3, 155, }, /* F F N N L L N L S */
|
||||
/* 47*/ { "01000000000000000KM12JQAN ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N L L N L S bad 3rd N */
|
||||
/* 48*/ { "01000000000000000OV123JQ4U", 0, 3, 155, }, /* F F N N N L L N L */
|
||||
/* 49*/ { "01000000000000000OV123IQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N N N L L N L bad 1st L */
|
||||
/* 50*/ { "01000000000000000CI1K3JQ4U", 0, 3, 155, }, /* F F N F N L L N L */
|
||||
/* 51*/ { "010000000000000009I1K3JQ4U", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F F N F N L L N L bad 1st F */
|
||||
/* 52*/ { "01000000000000000C12JQ3U ", 0, 3, 155, }, /* F N N L L N L S S */
|
||||
/* 53*/ { "01000000000000000C12JQ3U A", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N L L N L S S bad 2nd S */
|
||||
/* 54*/ { "01000000000000000C123JQ4U ", 0, 3, 155, }, /* F N N N L L N L S */
|
||||
/* 55*/ { "01000000000000000C 23JQ4U ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N N L L N L S bad 1st N (non-alpha otherwise matches 2nd pattern) */
|
||||
/* 56*/ { "41038422416563762XY1", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
|
@ -30,6 +30,11 @@
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
|
||||
#include "testcommon.h"
|
||||
#include "../output.h"
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <direct.h>
|
||||
#endif
|
||||
|
||||
INTERNAL int out_quiet_zones_test(const struct zint_symbol *symbol, const int hide_text,
|
||||
float *left, float *right, float *top, float *bottom);
|
||||
@ -57,10 +62,107 @@ static void test_quiet_zones(const testCtx *const p_ctx) {
|
||||
testFinish();
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#define TEST_OUT_SEP '\\'
|
||||
#define TEST_OUT_SEP_STR "\\"
|
||||
#else
|
||||
#define TEST_OUT_SEP '/'
|
||||
#define TEST_OUT_SEP_STR "/"
|
||||
#endif
|
||||
|
||||
static void test_fopen(const testCtx *const p_ctx) {
|
||||
struct item {
|
||||
char dir[32];
|
||||
char subdir[32];
|
||||
char *filename;
|
||||
int succeed;
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
struct item data[] = {
|
||||
/* 0*/ { "", "", "out.png", 1 },
|
||||
/* 1*/ { "out_test", "", "out.png", 1 },
|
||||
/* 2*/ { "out_test_with_subdir", "out_test_subdir", "out.png", 1 },
|
||||
/* 3*/ { "out_test_with_subdir", "out_test_subdir", "out.bmp", 1 },
|
||||
/* 4*/ { "out_test_with_subdir", "out_test_subdir", "out.emf", 1 },
|
||||
/* 5*/ { "out_test_with_subdir", "out_test_subdir", "out.eps", 1 },
|
||||
/* 6*/ { "out_test_with_subdir", "out_test_subdir", "out.gif", 1 },
|
||||
/* 7*/ { "out_test_with_subdir", "out_test_subdir", "out.pcx", 1 },
|
||||
/* 8*/ { "out_test_with_subdir", "out_test_subdir", "out.svg", 1 },
|
||||
/* 9*/ { "out_test_with_subdir", "out_test_subdir", "out.tif", 1 },
|
||||
/* 10*/ { "out_test/", "", "out.png", 1 },
|
||||
/* 11*/ { "out_test//", "", "out.png", 1 },
|
||||
/* 12*/ { "out_test/", "/out_test_subdir/", "out.png", 1 },
|
||||
/* 13*/ { "out_test\\", "\\out_test_subdir\\", "out.png", 1 },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, len;
|
||||
|
||||
FILE *ret;
|
||||
char cwdbuf[1024];
|
||||
char outfile[1024 + 256];
|
||||
char dirname[1024 + 256];
|
||||
char subdirname[1024 + 256];
|
||||
int dir_exists, subdir_exists;
|
||||
|
||||
testStart("test_fopen");
|
||||
|
||||
assert_nonnull(getcwd(cwdbuf, sizeof(cwdbuf)), "getcwd NULL (%d, %s)\n", errno, strerror(errno));
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
|
||||
if (testContinue(p_ctx, i)) continue;
|
||||
|
||||
strcpy(outfile, cwdbuf);
|
||||
len = strlen(outfile);
|
||||
if (len && outfile[len - 1] != TEST_OUT_SEP) { outfile[len++] = TEST_OUT_SEP; outfile[len] = '\0'; }
|
||||
dir_exists = subdir_exists = 0;
|
||||
|
||||
if (data[i].dir[0]) {
|
||||
strcat(outfile, data[i].dir);
|
||||
strcat(outfile, TEST_OUT_SEP_STR);
|
||||
strcpy(dirname, outfile);
|
||||
dir_exists = testUtilDirExists(dirname);
|
||||
if (data[i].subdir[0]) {
|
||||
strcat(outfile, data[i].subdir);
|
||||
strcat(outfile, TEST_OUT_SEP_STR);
|
||||
strcpy(subdirname, outfile);
|
||||
subdir_exists = testUtilDirExists(subdirname);
|
||||
}
|
||||
}
|
||||
strcat(outfile, data[i].filename);
|
||||
|
||||
ret = out_fopen(outfile, "w");
|
||||
if (data[i].succeed) {
|
||||
assert_nonnull(ret, "i:%d out_fopen(%s) == NULL (%d: %s)\n", i, outfile, errno, strerror(errno));
|
||||
assert_zero(fclose(ret), "i:%d fclose(%s) != 0 (%d: %s)\n", i, outfile, errno, strerror(errno));
|
||||
assert_nonzero(testUtilExists(outfile), "i:%d testUtilExists(%s) != 0 (%d: %s)\n", i, outfile, errno, strerror(errno));
|
||||
if (data[i].dir[0]) {
|
||||
assert_nonzero(testUtilDirExists(dirname), "i:%d testUtilDirExists(%s) != 0 (%d: %s)\n", i, dirname, errno, strerror(errno));
|
||||
}
|
||||
assert_zero(remove(outfile), "i:%d remove(%s) != 0 (%d: %s)\n", i, outfile, errno, strerror(errno));
|
||||
if (data[i].dir[0]) {
|
||||
if (data[i].subdir[0] && !subdir_exists) {
|
||||
assert_zero(testUtilRmDir(subdirname), "i:%d rmdir(%s) != 0 (%d: %s)\n", i, subdirname, errno, strerror(errno));
|
||||
}
|
||||
if (!dir_exists && strcmp(dirname, "/") != 0 && strcmp(dirname, "\\") != 0) {
|
||||
assert_zero(testUtilRmDir(dirname), "i:%d rmdir(%s) != 0 (%d: %s)\n", i, dirname, errno, strerror(errno));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
assert_null(ret, "i:%d out_fopen(%s) == NULL (%d: %s)\n", i, outfile, errno, strerror(errno));
|
||||
/* TODO: may have left junk around */
|
||||
}
|
||||
}
|
||||
|
||||
testFinish();
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
testFunction funcs[] = { /* name, func */
|
||||
{ "test_quiet_zones", test_quiet_zones },
|
||||
{ "test_fopen", test_fopen },
|
||||
};
|
||||
|
||||
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
|
||||
|
@ -65,7 +65,7 @@ static void test_print(const testCtx *const p_ctx) {
|
||||
char escaped[1024];
|
||||
int escaped_size = 1024;
|
||||
|
||||
int have_identify = testUtilHaveIdentify();
|
||||
const char *const have_identify = testUtilHaveIdentify();
|
||||
|
||||
testStart("test_pcx");
|
||||
|
||||
@ -124,7 +124,7 @@ static void test_print(const testCtx *const p_ctx) {
|
||||
ret = testUtilRename(symbol->outfile, expected_file);
|
||||
assert_zero(ret, "i:%d testUtilRename(%s, %s) ret %d != 0 (%d: %s)\n", i, symbol->outfile, expected_file, ret, errno, strerror(errno));
|
||||
if (have_identify) {
|
||||
ret = testUtilVerifyIdentify(expected_file, debug);
|
||||
ret = testUtilVerifyIdentify(have_identify, expected_file, debug);
|
||||
assert_zero(ret, "i:%d %s identify %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), expected_file, ret);
|
||||
}
|
||||
} else {
|
||||
@ -157,10 +157,13 @@ static void test_outfile(const testCtx *const p_ctx) {
|
||||
symbol.bitmap = data;
|
||||
symbol.bitmap_width = symbol.bitmap_height = 1;
|
||||
|
||||
strcpy(symbol.outfile, "nosuch_dir/out.pcx");
|
||||
strcpy(symbol.outfile, "test_pcx_out.pcx");
|
||||
(void) testUtilRmROFile(symbol.outfile); /* In case lying around from previous fail */
|
||||
assert_nonzero(testUtilCreateROFile(symbol.outfile), "pcx_pixel_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
ret = pcx_pixel_plot(&symbol, data);
|
||||
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "pcx_pixel_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
|
||||
assert_zero(testUtilRmROFile(symbol.outfile), "pcx_pixel_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
symbol.output_options |= BARCODE_STDOUT;
|
||||
|
||||
|
@ -63,7 +63,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
|
||||
|
||||
char data_buf[8 * 2 + 1];
|
||||
|
||||
int have_identify = testUtilHaveIdentify();
|
||||
const char *const have_identify = testUtilHaveIdentify();
|
||||
|
||||
testStart("test_pixel_plot");
|
||||
|
||||
@ -98,7 +98,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
|
||||
|
||||
if (ret < ZINT_ERROR) {
|
||||
if (have_identify) {
|
||||
ret = testUtilVerifyIdentify(symbol->outfile, debug);
|
||||
ret = testUtilVerifyIdentify(have_identify, symbol->outfile, debug);
|
||||
assert_zero(ret, "i:%d identify %s ret %d != 0\n", i, symbol->outfile, ret);
|
||||
}
|
||||
if (!(debug & ZINT_DEBUG_TEST_KEEP_OUTFILE)) {
|
||||
@ -214,7 +214,7 @@ static void test_print(const testCtx *const p_ctx) {
|
||||
int escaped_size = 1024;
|
||||
char *text;
|
||||
|
||||
int have_identify = testUtilHaveIdentify();
|
||||
const char *const have_identify = testUtilHaveIdentify();
|
||||
|
||||
testStart("test_print");
|
||||
|
||||
@ -288,7 +288,7 @@ static void test_print(const testCtx *const p_ctx) {
|
||||
ret = testUtilRename(symbol->outfile, expected_file);
|
||||
assert_zero(ret, "i:%d testUtilRename(%s, %s) ret %d != 0\n", i, symbol->outfile, expected_file, ret);
|
||||
if (have_identify) {
|
||||
ret = testUtilVerifyIdentify(expected_file, debug);
|
||||
ret = testUtilVerifyIdentify(have_identify, expected_file, debug);
|
||||
assert_zero(ret, "i:%d %s identify %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), expected_file, ret);
|
||||
}
|
||||
} else {
|
||||
@ -321,10 +321,13 @@ static void test_outfile(const testCtx *const p_ctx) {
|
||||
symbol.bitmap = data;
|
||||
symbol.bitmap_width = symbol.bitmap_height = 1;
|
||||
|
||||
strcpy(symbol.outfile, "nosuch_dir/out.png");
|
||||
strcpy(symbol.outfile, "test_png_out.png");
|
||||
(void) testUtilRmROFile(symbol.outfile); /* In case lying around from previous fail */
|
||||
assert_nonzero(testUtilCreateROFile(symbol.outfile), "png_pixel_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
ret = png_pixel_plot(&symbol, data);
|
||||
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "png_pixel_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
|
||||
assert_zero(testUtilRmROFile(symbol.outfile), "png_pixel_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
symbol.output_options |= BARCODE_STDOUT;
|
||||
|
||||
|
@ -67,7 +67,7 @@ static void test_print(const testCtx *const p_ctx) {
|
||||
char escaped[1024];
|
||||
int escaped_size = 1024;
|
||||
|
||||
int have_identify = 0;
|
||||
const char *have_identify = NULL;
|
||||
int have_libreoffice = 0;
|
||||
int have_ghostscript = 0;
|
||||
int have_vnu = 0;
|
||||
@ -177,7 +177,7 @@ static void test_print(const testCtx *const p_ctx) {
|
||||
assert_zero(ret, "i:%d %s tiffinfo %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), expected_file, ret);
|
||||
} else if (strcmp(exts[j], "txt") != 0) { /* I.e. rasters */
|
||||
if (have_identify) {
|
||||
ret = testUtilVerifyIdentify(expected_file, debug);
|
||||
ret = testUtilVerifyIdentify(have_identify, expected_file, debug);
|
||||
assert_zero(ret, "i:%d %s identify %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), expected_file, ret);
|
||||
}
|
||||
}
|
||||
|
@ -224,10 +224,13 @@ static void test_outfile(const testCtx *const p_ctx) {
|
||||
symbol.symbology = BARCODE_CODE128;
|
||||
symbol.vector = &vector;
|
||||
|
||||
strcpy(symbol.outfile, "nosuch_dir/out.eps");
|
||||
strcpy(symbol.outfile, "test_ps_out.eps");
|
||||
(void) testUtilRmROFile(symbol.outfile); /* In case lying around from previous fail */
|
||||
assert_nonzero(testUtilCreateROFile(symbol.outfile), "ps_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
ret = ps_plot(&symbol, 0);
|
||||
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "ps_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
|
||||
assert_zero(testUtilRmROFile(symbol.outfile), "ps_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
symbol.output_options |= BARCODE_STDOUT;
|
||||
|
||||
|
@ -91,10 +91,12 @@ static void test_qr_options(const testCtx *const p_ctx) {
|
||||
/* 38*/ { -1, -1, 4, 1, { 3, 16, "123" }, "12345678901", 0, 0, 21, -1, "" },
|
||||
/* 39*/ { -1, -1, 4, 1, { 3, 17, "123" }, "12345678901", ZINT_ERROR_INVALID_OPTION, -1, 0, -1, "Error 750: Structured Append count out of range (2-16)" },
|
||||
/* 40*/ { -1, -1, 4, 1, { 3, 2, "123" }, "12345678901", ZINT_ERROR_INVALID_OPTION, -1, 0, -1, "Error 751: Structured Append index out of range (1-2)" },
|
||||
/* 41*/ { -1, -1, 4, 1, { 1, 2, "256" }, "12345678901", ZINT_ERROR_INVALID_OPTION, -1, 0, -1, "Error 754: Structured Append ID '256' out of range (0-255)" },
|
||||
/* 42*/ { GS1_MODE, 3, -1, -1, { 0, 0, "" }, "[20]12", ZINT_WARN_NONCOMPLIANT, 0, 21, -1, "Warning 755: Using ECI in GS1 mode not supported by GS1 standards" },
|
||||
/* 43*/ { GS1_MODE, -1, -1, -1, { 1, 2, "" }, "[20]12", ZINT_WARN_NONCOMPLIANT, 0, 21, -1, "Warning 756: Using Structured Append in GS1 mode not supported by GS1 standards" },
|
||||
/* 44*/ { GS1_MODE, 3, -1, -1, { 1, 2, "" }, "[20]12", ZINT_WARN_NONCOMPLIANT, 0, 21, -1, "Warning 755: Using ECI in GS1 mode not supported by GS1 standards" }, /* ECI trumps Structured Append */
|
||||
/* 41*/ { -1, -1, 4, 1, { 1, 2, "1234" }, "12345678901", ZINT_ERROR_INVALID_OPTION, -1, 0, -1, "Error 752: Structured Append ID too long (3 digit maximum)" },
|
||||
/* 42*/ { -1, -1, 4, 1, { 1, 2, "12A" }, "12345678901", ZINT_ERROR_INVALID_OPTION, -1, 0, -1, "Error 753: Invalid Structured Append ID (digits only)" },
|
||||
/* 43*/ { -1, -1, 4, 1, { 1, 2, "256" }, "12345678901", ZINT_ERROR_INVALID_OPTION, -1, 0, -1, "Error 754: Structured Append ID '256' out of range (0-255)" },
|
||||
/* 44*/ { GS1_MODE, 3, -1, -1, { 0, 0, "" }, "[20]12", ZINT_WARN_NONCOMPLIANT, 0, 21, -1, "Warning 755: Using ECI in GS1 mode not supported by GS1 standards" },
|
||||
/* 45*/ { GS1_MODE, -1, -1, -1, { 1, 2, "" }, "[20]12", ZINT_WARN_NONCOMPLIANT, 0, 21, -1, "Warning 756: Using Structured Append in GS1 mode not supported by GS1 standards" },
|
||||
/* 46*/ { GS1_MODE, 3, -1, -1, { 1, 2, "" }, "[20]12", ZINT_WARN_NONCOMPLIANT, 0, 21, -1, "Warning 755: Using ECI in GS1 mode not supported by GS1 standards" }, /* ECI trumps Structured Append */
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
|
@ -176,10 +176,10 @@ static void test_buffer(const testCtx *const p_ctx) {
|
||||
/* 51*/ { BARCODE_CODABAR, COMPLIANT_HEIGHT, "A00000000B", "", 50, 1, 102, 204, 116 },
|
||||
/* 52*/ { BARCODE_CODE128, -1, "1234567890", "", 50, 1, 90, 180, 116 },
|
||||
/* 53*/ { BARCODE_CODE128, COMPLIANT_HEIGHT, "1234567890", "", 50, 1, 90, 180, 116 },
|
||||
/* 54*/ { BARCODE_DPLEIT, -1, "1234567890123", "", 50, 1, 135, 270, 116 },
|
||||
/* 55*/ { BARCODE_DPLEIT, COMPLIANT_HEIGHT, "1234567890123", "", 50, 1, 135, 270, 116 },
|
||||
/* 56*/ { BARCODE_DPIDENT, -1, "12345678901", "", 50, 1, 117, 234, 116 },
|
||||
/* 57*/ { BARCODE_DPIDENT, COMPLIANT_HEIGHT, "12345678901", "", 50, 1, 117, 234, 116 },
|
||||
/* 54*/ { BARCODE_DPLEIT, -1, "1234567890123", "", 72, 1, 135, 270, 160 },
|
||||
/* 55*/ { BARCODE_DPLEIT, COMPLIANT_HEIGHT, "1234567890123", "", 72, 1, 135, 270, 160 },
|
||||
/* 56*/ { BARCODE_DPIDENT, -1, "12345678901", "", 72, 1, 117, 234, 160 },
|
||||
/* 57*/ { BARCODE_DPIDENT, COMPLIANT_HEIGHT, "12345678901", "", 72, 1, 117, 234, 160 },
|
||||
/* 58*/ { BARCODE_CODE16K, -1, "1234567890", "", 20, 2, 70, 162, 44 },
|
||||
/* 59*/ { BARCODE_CODE16K, COMPLIANT_HEIGHT, "1234567890", "", 21, 2, 70, 162, 46 },
|
||||
/* 60*/ { BARCODE_CODE49, -1, "1234567890", "", 20, 2, 70, 162, 44 },
|
||||
@ -244,8 +244,8 @@ static void test_buffer(const testCtx *const p_ctx) {
|
||||
/*119*/ { BARCODE_MAXICODE, COMPLIANT_HEIGHT, "1234567890", "", 165, 33, 30, 299, 298 },
|
||||
/*120*/ { BARCODE_QRCODE, -1, "1234567890AB", "", 21, 21, 21, 42, 42 },
|
||||
/*121*/ { BARCODE_QRCODE, COMPLIANT_HEIGHT, "1234567890AB", "", 21, 21, 21, 42, 42 },
|
||||
/*122*/ { BARCODE_CODE128B, -1, "1234567890", "", 50, 1, 145, 290, 116 },
|
||||
/*123*/ { BARCODE_CODE128B, COMPLIANT_HEIGHT, "1234567890", "", 50, 1, 145, 290, 116 },
|
||||
/*122*/ { BARCODE_CODE128AB, -1, "1234567890", "", 50, 1, 145, 290, 116 },
|
||||
/*123*/ { BARCODE_CODE128AB, COMPLIANT_HEIGHT, "1234567890", "", 50, 1, 145, 290, 116 },
|
||||
/*124*/ { BARCODE_AUSPOST, -1, "12345678901234567890123", "", 8, 3, 133, 266, 16 },
|
||||
/*125*/ { BARCODE_AUSPOST, COMPLIANT_HEIGHT, "12345678901234567890123", "", 9.5, 3, 133, 266, 19 },
|
||||
/*126*/ { BARCODE_AUSREPLY, -1, "12345678", "", 8, 3, 73, 146, 16 },
|
||||
@ -1477,10 +1477,10 @@ static void test_quiet_zones(const testCtx *const p_ctx) {
|
||||
/* 44*/ { BARCODE_CODABAR, BARCODE_QUIET_ZONES, -1, -1, "A0B", 0, 50, 1, 32, 104, 116, 0 /*set*/, 0, 100, 0, 20 },
|
||||
/* 45*/ { BARCODE_CODE128, -1, -1, -1, "1234", 0, 50, 1, 57, 114, 116, 1 /*set*/, 0, 100, 0, 4 },
|
||||
/* 46*/ { BARCODE_CODE128, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 50, 1, 57, 154, 116, 0 /*set*/, 0, 100, 0, 20 },
|
||||
/* 47*/ { BARCODE_DPLEIT, -1, -1, -1, "1234", 0, 50, 1, 135, 270, 116, 1 /*set*/, 0, 100, 0, 2 },
|
||||
/* 48*/ { BARCODE_DPLEIT, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 50, 1, 135, 310, 116, 0 /*set*/, 0, 100, 0, 20 },
|
||||
/* 49*/ { BARCODE_DPIDENT, -1, -1, -1, "1234", 0, 50, 1, 117, 234, 116, 1 /*set*/, 0, 100, 0, 2 },
|
||||
/* 50*/ { BARCODE_DPIDENT, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 50, 1, 117, 274, 116, 0 /*set*/, 0, 100, 0, 20 },
|
||||
/* 47*/ { BARCODE_DPLEIT, -1, -1, -1, "1234", 0, 72, 1, 135, 270, 160, 1 /*set*/, 0, 100, 0, 2 },
|
||||
/* 48*/ { BARCODE_DPLEIT, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 72, 1, 135, 310, 160, 0 /*set*/, 0, 100, 0, 20 },
|
||||
/* 49*/ { BARCODE_DPIDENT, -1, -1, -1, "1234", 0, 72, 1, 117, 234, 160, 1 /*set*/, 0, 100, 0, 2 },
|
||||
/* 50*/ { BARCODE_DPIDENT, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 72, 1, 117, 274, 160, 0 /*set*/, 0, 100, 0, 20 },
|
||||
/* 51*/ { BARCODE_CODE16K, -1, -1, -1, "1234", 0, 20, 2, 70, 162, 44, 0 /*set*/, 2, 20, 0, 20 },
|
||||
/* 52*/ { BARCODE_CODE16K, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 20, 2, 70, 162, 44, 0 /*set*/, 2, 20, 0, 20 },
|
||||
/* 53*/ { BARCODE_CODE16K, BARCODE_NO_QUIET_ZONES, -1, -1, "1234", 0, 20, 2, 70, 140, 44, 1 /*set*/, 2, 20, 0, 6 },
|
||||
@ -1564,8 +1564,8 @@ static void test_quiet_zones(const testCtx *const p_ctx) {
|
||||
/*131*/ { BARCODE_MAXICODE, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 165, 33, 30, 319, 318, 0 /*set*/, 0, 9, 0, 319 },
|
||||
/*132*/ { BARCODE_QRCODE, -1, -1, -1, "1234", 0, 21, 21, 21, 42, 42, 1 /*set*/, 0, 2, 0, 14 },
|
||||
/*133*/ { BARCODE_QRCODE, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 21, 21, 21, 58, 58, 0 /*set*/, 0, 8, 0, 58 },
|
||||
/*134*/ { BARCODE_CODE128B, -1, -1, -1, "1234", 0, 50, 1, 79, 158, 116, 1 /*set*/, 0, 100, 0, 4 },
|
||||
/*135*/ { BARCODE_CODE128B, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 50, 1, 79, 198, 116, 0 /*set*/, 0, 100, 0, 20 },
|
||||
/*134*/ { BARCODE_CODE128AB, -1, -1, -1, "1234", 0, 50, 1, 79, 158, 116, 1 /*set*/, 0, 100, 0, 4 },
|
||||
/*135*/ { BARCODE_CODE128AB, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 50, 1, 79, 198, 116, 0 /*set*/, 0, 100, 0, 20 },
|
||||
/*136*/ { BARCODE_AUSPOST, -1, -1, -1, "12345678", 0, 8, 3, 73, 146, 16, 1 /*set*/, 0, 10, 0, 2 },
|
||||
/*137*/ { BARCODE_AUSPOST, BARCODE_QUIET_ZONES, -1, -1, "12345678", 0, 8, 3, 73, 186, 28, 0 /*set*/, 0, 28, 0, 20 },
|
||||
/*138*/ { BARCODE_AUSREPLY, -1, -1, -1, "1234", 0, 8, 3, 73, 146, 16, 1 /*set*/, 0, 10, 0, 2 },
|
||||
@ -2045,8 +2045,8 @@ static void test_height(const testCtx *const p_ctx) {
|
||||
/* 50*/ { BARCODE_CODABAR, -1, 1, "A0B", "", 0, 1, 1, 32, 64, 2, "" },
|
||||
/* 51*/ { BARCODE_CODABAR, -1, 4, "A0B", "", 0, 4, 1, 32, 64, 8, "" },
|
||||
/* 52*/ { BARCODE_CODABAR, -1, 26, "A0B", "", 0, 26, 1, 32, 64, 52, "" },
|
||||
/* 53*/ { BARCODE_CODABAR, COMPLIANT_HEIGHT, 26, "A0B", "", ZINT_WARN_NONCOMPLIANT, 26, 1, 32, 64, 52, "" },
|
||||
/* 54*/ { BARCODE_CODABAR, COMPLIANT_HEIGHT, 27, "A0B", "", 0, 27, 1, 32, 64, 54, "" },
|
||||
/* 53*/ { BARCODE_CODABAR, COMPLIANT_HEIGHT, 11, "A0B", "", ZINT_WARN_NONCOMPLIANT, 11, 1, 32, 64, 22, "" },
|
||||
/* 54*/ { BARCODE_CODABAR, COMPLIANT_HEIGHT, 12, "A0B", "", 0, 12, 1, 32, 64, 24, "" },
|
||||
/* 55*/ { BARCODE_CODE128, -1, 1, "1234567890", "", 0, 1, 1, 90, 180, 2, "" },
|
||||
/* 56*/ { BARCODE_CODE128, COMPLIANT_HEIGHT, 1, "1234567890", "", 0, 1, 1, 90, 180, 2, "" },
|
||||
/* 57*/ { BARCODE_CODE128, -1, 4, "1234567890", "", 0, 4, 1, 90, 180, 8, "" },
|
||||
@ -2188,9 +2188,9 @@ static void test_height(const testCtx *const p_ctx) {
|
||||
/*193*/ { BARCODE_PDF417COMP, -1, 24, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJ", "", ZINT_WARN_NONCOMPLIANT, 22.5, 9, 86, 172, 45, "" },
|
||||
/*194*/ { BARCODE_MAXICODE, -1, 1, "1234567890", "", 0, 16.5, 33, 30, 299, 298, "Fixed size, symbol->height ignored" },
|
||||
/*195*/ { BARCODE_QRCODE, -1, 1, "ABCD", "", 0, 21, 21, 21, 42, 42, "Fixed width-to-height ratio, symbol->height ignored" },
|
||||
/*196*/ { BARCODE_CODE128B, -1, 1, "1234567890", "", 0, 1, 1, 145, 290, 2, "" },
|
||||
/*197*/ { BARCODE_CODE128B, COMPLIANT_HEIGHT, 1, "1234567890", "", 0, 1, 1, 145, 290, 2, "" },
|
||||
/*198*/ { BARCODE_CODE128B, -1, 4, "1234567890", "", 0, 4, 1, 145, 290, 8, "" },
|
||||
/*196*/ { BARCODE_CODE128AB, -1, 1, "1234567890", "", 0, 1, 1, 145, 290, 2, "" },
|
||||
/*197*/ { BARCODE_CODE128AB, COMPLIANT_HEIGHT, 1, "1234567890", "", 0, 1, 1, 145, 290, 2, "" },
|
||||
/*198*/ { BARCODE_CODE128AB, -1, 4, "1234567890", "", 0, 4, 1, 145, 290, 8, "" },
|
||||
/*199*/ { BARCODE_AUSPOST, -1, -1, "12345678901234567890123", "", 0, 8, 3, 133, 266, 16, "" },
|
||||
/*200*/ { BARCODE_AUSPOST, -1, 1, "12345678901234567890123", "", 0, 2.5, 3, 133, 266, 5, "" },
|
||||
/*201*/ { BARCODE_AUSPOST, COMPLIANT_HEIGHT, 1, "12345678901234567890123", "", ZINT_WARN_NONCOMPLIANT, 1.5, 3, 133, 266, 3, "" },
|
||||
|
@ -232,10 +232,13 @@ static void test_outfile(const testCtx *const p_ctx) {
|
||||
symbol.symbology = BARCODE_CODE128;
|
||||
symbol.vector = &vector;
|
||||
|
||||
strcpy(symbol.outfile, "nosuch_dir/out.svg");
|
||||
strcpy(symbol.outfile, "test_svg_out.svg");
|
||||
(void) testUtilRmROFile(symbol.outfile); /* In case lying around from previous fail */
|
||||
assert_nonzero(testUtilCreateROFile(symbol.outfile), "svg_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
ret = svg_plot(&symbol, 0);
|
||||
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "svg_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
|
||||
assert_zero(testUtilRmROFile(symbol.outfile), "svg_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
symbol.output_options |= BARCODE_STDOUT;
|
||||
|
||||
|
@ -96,7 +96,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
|
||||
char data_buf[ZINT_MAX_DATA_LEN * 2 + 1];
|
||||
|
||||
int have_tiffinfo = testUtilHaveTiffInfo();
|
||||
int have_identify = testUtilHaveIdentify();
|
||||
const char *const have_identify = testUtilHaveIdentify();
|
||||
|
||||
testStart("test_pixel_plot");
|
||||
|
||||
@ -136,7 +136,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
|
||||
ret = testUtilVerifyTiffInfo(symbol->outfile, debug);
|
||||
assert_zero(ret, "i:%d tiffinfo %s ret %d != 0\n", i, symbol->outfile, ret);
|
||||
} else if (have_identify && !data[i].no_identify) {
|
||||
ret = testUtilVerifyIdentify(symbol->outfile, debug);
|
||||
ret = testUtilVerifyIdentify(have_identify, symbol->outfile, debug);
|
||||
assert_zero(ret, "i:%d identify %s ret %d != 0\n", i, symbol->outfile, ret);
|
||||
}
|
||||
|
||||
@ -214,7 +214,7 @@ static void test_print(const testCtx *const p_ctx) {
|
||||
char *text;
|
||||
|
||||
int have_tiffinfo = testUtilHaveTiffInfo();
|
||||
int have_identify = testUtilHaveIdentify();
|
||||
const char *const have_identify = testUtilHaveIdentify();
|
||||
|
||||
testStart("test_print");
|
||||
|
||||
@ -289,7 +289,7 @@ static void test_print(const testCtx *const p_ctx) {
|
||||
ret = testUtilVerifyTiffInfo(expected_file, debug);
|
||||
assert_zero(ret, "i:%d %s tiffinfo %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), expected_file, ret);
|
||||
} else if (have_identify) {
|
||||
ret = testUtilVerifyIdentify(expected_file, debug);
|
||||
ret = testUtilVerifyIdentify(have_identify, expected_file, debug);
|
||||
assert_zero(ret, "i:%d %s identify %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), expected_file, ret);
|
||||
}
|
||||
} else {
|
||||
@ -320,10 +320,13 @@ static void test_outfile(const testCtx *const p_ctx) {
|
||||
symbol.bitmap = data;
|
||||
symbol.bitmap_width = symbol.bitmap_height = 1;
|
||||
|
||||
strcpy(symbol.outfile, "nosuch_dir/out.tif");
|
||||
strcpy(symbol.outfile, "test_tif_out.tif");
|
||||
(void) testUtilRmROFile(symbol.outfile); /* In case lying around from previous fail */
|
||||
assert_nonzero(testUtilCreateROFile(symbol.outfile), "tif_pixel_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
ret = tif_pixel_plot(&symbol, data);
|
||||
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "tif_pixel_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
|
||||
assert_zero(testUtilRmROFile(symbol.outfile), "tif_pixel_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
symbol.output_options |= BARCODE_STDOUT;
|
||||
|
||||
|
@ -188,8 +188,8 @@ static void test_buffer_vector(const testCtx *const p_ctx) {
|
||||
/* 24*/ { BARCODE_GS1_128, "[01]12345678901231", "", 50, 1, 134, 268, 118.900002 },
|
||||
/* 25*/ { BARCODE_CODABAR, "A00000000B", "", 50, 1, 102, 204, 118.900002 },
|
||||
/* 26*/ { BARCODE_CODE128, "1234567890", "", 50, 1, 90, 180, 118.900002 },
|
||||
/* 27*/ { BARCODE_DPLEIT, "1234567890123", "", 50, 1, 135, 270, 118.900002 },
|
||||
/* 28*/ { BARCODE_DPIDENT, "12345678901", "", 50, 1, 117, 234, 118.900002 },
|
||||
/* 27*/ { BARCODE_DPLEIT, "1234567890123", "", 72, 1, 135, 270, 162.89999 },
|
||||
/* 28*/ { BARCODE_DPIDENT, "12345678901", "", 72, 1, 117, 234, 162.89999 },
|
||||
/* 29*/ { BARCODE_CODE16K, "1234567890", "", 20, 2, 70, 162, 44 },
|
||||
/* 30*/ { BARCODE_CODE49, "1234567890", "", 20, 2, 70, 162, 44 },
|
||||
/* 31*/ { BARCODE_CODE93, "1234567890", "", 50, 1, 127, 254, 118.900002 },
|
||||
@ -222,7 +222,7 @@ static void test_buffer_vector(const testCtx *const p_ctx) {
|
||||
/* 58*/ { BARCODE_PDF417COMP, "1234567890", "", 21, 7, 69, 138, 42 },
|
||||
/* 59*/ { BARCODE_MAXICODE, "1234567890", "", 165, 33, 30, 60, 57.7333984 },
|
||||
/* 60*/ { BARCODE_QRCODE, "1234567890AB", "", 21, 21, 21, 42, 42 },
|
||||
/* 61*/ { BARCODE_CODE128B, "1234567890", "", 50, 1, 145, 290, 118.900002 },
|
||||
/* 61*/ { BARCODE_CODE128AB, "1234567890", "", 50, 1, 145, 290, 118.900002 },
|
||||
/* 62*/ { BARCODE_AUSPOST, "12345678901234567890123", "", 8, 3, 133, 266, 16 },
|
||||
/* 63*/ { BARCODE_AUSREPLY, "12345678", "", 8, 3, 73, 146, 16 },
|
||||
/* 64*/ { BARCODE_AUSROUTE, "12345678", "", 8, 3, 73, 146, 16 },
|
||||
@ -1175,10 +1175,10 @@ static void test_quiet_zones(const testCtx *const p_ctx) {
|
||||
/* 44*/ { BARCODE_CODABAR, BARCODE_QUIET_ZONES, -1, -1, "A0B", 0, 50, 1, 32, 104, 118.9, 20, 0, 2, 100 },
|
||||
/* 45*/ { BARCODE_CODE128, -1, -1, -1, "1234", 0, 50, 1, 57, 114, 118.9, 0, 0, 4, 100 },
|
||||
/* 46*/ { BARCODE_CODE128, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 50, 1, 57, 154, 118.9, 20, 0, 4, 100 },
|
||||
/* 47*/ { BARCODE_DPLEIT, -1, -1, -1, "1234", 0, 50, 1, 135, 270, 118.9, 0, 0, 2, 100 },
|
||||
/* 48*/ { BARCODE_DPLEIT, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 50, 1, 135, 310, 118.9, 20, 0, 2, 100 },
|
||||
/* 49*/ { BARCODE_DPIDENT, -1, -1, -1, "1234", 0, 50, 1, 117, 234, 118.9, 0, 0, 2, 100 },
|
||||
/* 50*/ { BARCODE_DPIDENT, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 50, 1, 117, 274, 118.9, 20, 0, 2, 100 },
|
||||
/* 47*/ { BARCODE_DPLEIT, -1, -1, -1, "1234", 0, 72, 1, 135, 270, 162.89999, 0, 0, 2, 144 },
|
||||
/* 48*/ { BARCODE_DPLEIT, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 72, 1, 135, 310, 162.89999, 20, 0, 2, 144 },
|
||||
/* 49*/ { BARCODE_DPIDENT, -1, -1, -1, "1234", 0, 72, 1, 117, 234, 162.89999, 0, 0, 2, 144 },
|
||||
/* 50*/ { BARCODE_DPIDENT, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 72, 1, 117, 274, 162.89999, 20, 0, 2, 144 },
|
||||
/* 51*/ { BARCODE_CODE16K, -1, -1, -1, "1234", 0, 20, 2, 70, 162, 44, 20, 2, 6, 19 },
|
||||
/* 52*/ { BARCODE_CODE16K, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 20, 2, 70, 162, 44, 20, 2, 6, 19 },
|
||||
/* 53*/ { BARCODE_CODE16K, BARCODE_NO_QUIET_ZONES, -1, -1, "1234", 0, 20, 2, 70, 140, 44, 0, 2, 6, 19 },
|
||||
@ -1261,8 +1261,8 @@ static void test_quiet_zones(const testCtx *const p_ctx) {
|
||||
/*130*/ { BARCODE_MAXICODE, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 165, 33, 30, 64, 61.733398, 31, 30.866699, 16.430941, 0 },
|
||||
/*131*/ { BARCODE_QRCODE, -1, -1, -1, "1234", 0, 21, 21, 21, 42, 42, 0, 0, 14, 2 },
|
||||
/*132*/ { BARCODE_QRCODE, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 21, 21, 21, 58, 58, 8, 8, 14, 2 },
|
||||
/*133*/ { BARCODE_CODE128B, -1, -1, -1, "1234", 0, 50, 1, 79, 158, 118.9, 0, 0, 4, 100 },
|
||||
/*134*/ { BARCODE_CODE128B, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 50, 1, 79, 198, 118.9, 20, 0, 4, 100 },
|
||||
/*133*/ { BARCODE_CODE128AB, -1, -1, -1, "1234", 0, 50, 1, 79, 158, 118.9, 0, 0, 4, 100 },
|
||||
/*134*/ { BARCODE_CODE128AB, BARCODE_QUIET_ZONES, -1, -1, "1234", 0, 50, 1, 79, 198, 118.9, 20, 0, 4, 100 },
|
||||
/*135*/ { BARCODE_AUSPOST, -1, -1, -1, "12345678", 0, 8, 3, 73, 146, 16, 0, 0, 2, 10 },
|
||||
/*136*/ { BARCODE_AUSPOST, BARCODE_QUIET_ZONES, -1, -1, "12345678", 0, 8, 3, 73, 186, 29.333332, 20, 6.6666665, 2, 10 },
|
||||
/*137*/ { BARCODE_AUSREPLY, -1, -1, -1, "1234", 0, 8, 3, 73, 146, 16, 0, 0, 2, 10 },
|
||||
@ -1550,8 +1550,8 @@ static void test_height(const testCtx *const p_ctx) {
|
||||
/* 50*/ { BARCODE_CODABAR, -1, 1, "A0B", "", 0, 1, 1, 32, 64, 2, "" },
|
||||
/* 51*/ { BARCODE_CODABAR, -1, 4, "A0B", "", 0, 4, 1, 32, 64, 8, "" },
|
||||
/* 52*/ { BARCODE_CODABAR, -1, 26, "A0B", "", 0, 26, 1, 32, 64, 52, "" },
|
||||
/* 53*/ { BARCODE_CODABAR, COMPLIANT_HEIGHT, 26, "A0B", "", ZINT_WARN_NONCOMPLIANT, 26, 1, 32, 64, 52, "" },
|
||||
/* 54*/ { BARCODE_CODABAR, COMPLIANT_HEIGHT, 27, "A0B", "", 0, 27, 1, 32, 64, 54, "" },
|
||||
/* 53*/ { BARCODE_CODABAR, COMPLIANT_HEIGHT, 11, "A0B", "", ZINT_WARN_NONCOMPLIANT, 11, 1, 32, 64, 22, "" },
|
||||
/* 54*/ { BARCODE_CODABAR, COMPLIANT_HEIGHT, 12, "A0B", "", 0, 12, 1, 32, 64, 24, "" },
|
||||
/* 55*/ { BARCODE_CODE128, -1, 1, "1234567890", "", 0, 1, 1, 90, 180, 2, "" },
|
||||
/* 56*/ { BARCODE_CODE128, COMPLIANT_HEIGHT, 1, "1234567890", "", 0, 1, 1, 90, 180, 2, "" },
|
||||
/* 57*/ { BARCODE_CODE128, -1, 4, "1234567890", "", 0, 4, 1, 90, 180, 8, "" },
|
||||
@ -1693,9 +1693,9 @@ static void test_height(const testCtx *const p_ctx) {
|
||||
/*193*/ { BARCODE_PDF417COMP, -1, 24, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJ", "", ZINT_WARN_NONCOMPLIANT, 24, 9, 86, 172, 48, "" },
|
||||
/*194*/ { BARCODE_MAXICODE, -1, 1, "1234567890", "", 0, 16.5, 33, 30, 60, 57.733398, "Fixed size, symbol->height ignored" },
|
||||
/*195*/ { BARCODE_QRCODE, -1, 1, "ABCD", "", 0, 21, 21, 21, 42, 42, "Fixed width-to-height ratio, symbol->height ignored" },
|
||||
/*196*/ { BARCODE_CODE128B, -1, 1, "1234567890", "", 0, 1, 1, 145, 290, 2, "" },
|
||||
/*197*/ { BARCODE_CODE128B, COMPLIANT_HEIGHT, 1, "1234567890", "", 0, 1, 1, 145, 290, 2, "" },
|
||||
/*198*/ { BARCODE_CODE128B, -1, 4, "1234567890", "", 0, 4, 1, 145, 290, 8, "" },
|
||||
/*196*/ { BARCODE_CODE128AB, -1, 1, "1234567890", "", 0, 1, 1, 145, 290, 2, "" },
|
||||
/*197*/ { BARCODE_CODE128AB, COMPLIANT_HEIGHT, 1, "1234567890", "", 0, 1, 1, 145, 290, 2, "" },
|
||||
/*198*/ { BARCODE_CODE128AB, -1, 4, "1234567890", "", 0, 4, 1, 145, 290, 8, "" },
|
||||
/*199*/ { BARCODE_AUSPOST, -1, -1, "12345678901234567890123", "", 0, 8, 3, 133, 266, 16, "" },
|
||||
/*200*/ { BARCODE_AUSPOST, -1, 1, "12345678901234567890123", "", 0, 2, 3, 133, 266, 4, "" },
|
||||
/*201*/ { BARCODE_AUSPOST, COMPLIANT_HEIGHT, 1, "12345678901234567890123", "", ZINT_WARN_NONCOMPLIANT, 1.9230771, 3, 133, 266, 3.8461542, "" },
|
||||
|
@ -202,7 +202,7 @@ static int validate_int_range(const char src[], int *p_val, int *p_val_end) {
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
if (src[i] < '0' || src[i] > '9') {
|
||||
if (src[i] != ',') {
|
||||
if (src[i] != '-') {
|
||||
return 0;
|
||||
}
|
||||
val_end = 0;
|
||||
@ -236,9 +236,13 @@ void testRun(int argc, char *argv[], testFunction funcs[], int funcs_size) {
|
||||
char *optarg;
|
||||
char *func = NULL;
|
||||
char func_buf[256 + 5];
|
||||
int exclude_idx = 0;
|
||||
testCtx ctx;
|
||||
|
||||
ctx.index = ctx.index_end = ctx.exclude = ctx.exclude_end = -1;
|
||||
ctx.index = ctx.index_end = -1;
|
||||
for (i = 0; i < ZINT_TEST_CTX_EXC_MAX; i++) {
|
||||
ctx.exclude[i] = ctx.exclude_end[i] = -1;
|
||||
}
|
||||
ctx.generate = ctx.debug = 0;
|
||||
|
||||
if (argc) {
|
||||
@ -303,9 +307,13 @@ void testRun(int argc, char *argv[], testFunction funcs[], int funcs_size) {
|
||||
fprintf(stderr, "testRun: -x exclude value missing, ignored\n");
|
||||
} else {
|
||||
optarg = argv[++i];
|
||||
if (!validate_int_range(optarg, &ctx.exclude, &ctx.exclude_end)) {
|
||||
if (exclude_idx + 1 == ZINT_TEST_CTX_EXC_MAX) {
|
||||
fprintf(stderr, "testRun: too many -x exclude values, ignored\n");
|
||||
} else if (!validate_int_range(optarg, &ctx.exclude[exclude_idx], &ctx.exclude_end[exclude_idx])) {
|
||||
fprintf(stderr, "testRun: -x exclude value invalid, ignored\n");
|
||||
ctx.exclude = ctx.exclude_end = -1;
|
||||
ctx.exclude[exclude_idx] = ctx.exclude_end[exclude_idx] = -1;
|
||||
} else {
|
||||
exclude_idx++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -329,6 +337,7 @@ void testRun(int argc, char *argv[], testFunction funcs[], int funcs_size) {
|
||||
|
||||
/* Call in a dataset loop to determine if a datum should be tested according to -i & -x args */
|
||||
int testContinue(const testCtx *const p_ctx, const int i) {
|
||||
int j;
|
||||
if (p_ctx->index != -1) {
|
||||
if (p_ctx->index_end != -1) {
|
||||
if (i < p_ctx->index || (p_ctx->index_end && i > p_ctx->index_end)) {
|
||||
@ -338,12 +347,12 @@ int testContinue(const testCtx *const p_ctx, const int i) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (p_ctx->exclude != -1) {
|
||||
if (p_ctx->exclude_end != -1) {
|
||||
if (i >= p_ctx->exclude && (p_ctx->exclude_end == 0 || i <= p_ctx->exclude_end)) {
|
||||
for (j = 0; j < ZINT_TEST_CTX_EXC_MAX && p_ctx->exclude[j] != -1; j++) {
|
||||
if (p_ctx->exclude_end[j] != -1) {
|
||||
if (i >= p_ctx->exclude[j] && (p_ctx->exclude_end[j] == 0 || i <= p_ctx->exclude_end[j])) {
|
||||
return 1;
|
||||
}
|
||||
} else if (i == p_ctx->exclude) {
|
||||
} else if (i == p_ctx->exclude[j]) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -1351,7 +1360,7 @@ int testUtilRmDir(const char *dirname) {
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Rename a file (Windows compatibility). */
|
||||
/* Rename a file (Windows compatibility) */
|
||||
int testUtilRename(const char *oldpath, const char *newpath) {
|
||||
#ifdef _MSVC
|
||||
int ret = remove(newpath);
|
||||
@ -1360,6 +1369,37 @@ int testUtilRename(const char *oldpath, const char *newpath) {
|
||||
return rename(oldpath, newpath);
|
||||
}
|
||||
|
||||
/* Create read-only file */
|
||||
int testUtilCreateROFile(const char *filename) {
|
||||
FILE *fp = fopen(filename, "w+");
|
||||
if (fp == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if (fclose(fp) != 0) {
|
||||
return 0;
|
||||
}
|
||||
#ifdef _WIN32
|
||||
if (SetFileAttributesA(filename, GetFileAttributesA(filename) | FILE_ATTRIBUTE_READONLY) == 0) {
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
if (chmod(filename, S_IRUSR | S_IRGRP | S_IROTH) != 0) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Remove read-only file (Windows compatibility) */
|
||||
int testUtilRmROFile(const char *filename) {
|
||||
#ifdef _WIN32
|
||||
if (SetFileAttributesA(filename, GetFileAttributesA(filename) & ~FILE_ATTRIBUTE_READONLY) == 0) {
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
return remove(filename);
|
||||
}
|
||||
|
||||
/* Compare 2 PNG files */
|
||||
int testUtilCmpPngs(const char *png1, const char *png2) {
|
||||
int ret = -1;
|
||||
@ -1730,12 +1770,19 @@ int testUtilCmpEpss(const char *eps1, const char *eps2) {
|
||||
#endif
|
||||
|
||||
/* Whether ImageMagick's identify utility available on system */
|
||||
int testUtilHaveIdentify(void) {
|
||||
return system("magick -version " DEV_NULL) == 0;
|
||||
const char *testUtilHaveIdentify(void) {
|
||||
static const char *progs[2] = { "magick identify", "identify" };
|
||||
if (system("magick -version " DEV_NULL_STDERR) == 0) {
|
||||
return progs[0];
|
||||
}
|
||||
if (system("identify -version " DEV_NULL_STDERR) == 0) {
|
||||
return progs[1];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Check raster files */
|
||||
int testUtilVerifyIdentify(const char *filename, int debug) {
|
||||
int testUtilVerifyIdentify(const char *const prog, const char *filename, int debug) {
|
||||
char cmd[512 + 128];
|
||||
|
||||
if (strlen(filename) > 512) {
|
||||
@ -1745,12 +1792,12 @@ int testUtilVerifyIdentify(const char *filename, int debug) {
|
||||
if (debug & ZINT_DEBUG_TEST_PRINT) {
|
||||
/* Verbose very noisy though so for quick check just return default output */
|
||||
if (debug & ZINT_DEBUG_TEST_LESS_NOISY) {
|
||||
sprintf(cmd, "magick identify %s", filename);
|
||||
sprintf(cmd, "%s %s", prog, filename);
|
||||
} else {
|
||||
sprintf(cmd, "magick identify -verbose %s", filename);
|
||||
sprintf(cmd, "%s -verbose %s", prog, filename);
|
||||
}
|
||||
} else {
|
||||
sprintf(cmd, "magick identify -verbose %s " DEV_NULL, filename);
|
||||
sprintf(cmd, "%s -verbose %s " DEV_NULL, prog, filename);
|
||||
}
|
||||
|
||||
return system(cmd);
|
||||
@ -1981,7 +2028,7 @@ static const char *testUtilBwippName(int index, const struct zint_symbol *symbol
|
||||
{ "maxicode", BARCODE_MAXICODE, 57, 1, 1, 0, 0, 0, },
|
||||
{ "qrcode", BARCODE_QRCODE, 58, 1, 1, 1, 0, 0, },
|
||||
{ "", -1, 59, 0, 0, 0, 0, 0, },
|
||||
{ "", BARCODE_CODE128B, 60, 0, 0, 0, 0, 0, },
|
||||
{ "", BARCODE_CODE128AB, 60, 0, 0, 0, 0, 0, },
|
||||
{ "", -1, 61, 0, 0, 0, 0, 0, },
|
||||
{ "", -1, 62, 0, 0, 0, 0, 0, },
|
||||
{ "auspost", BARCODE_AUSPOST, 63, 0, 0, 0, 0, 0, },
|
||||
@ -3324,7 +3371,7 @@ static const char *testUtilZXingCPPName(int index, const struct zint_symbol *sym
|
||||
{ "MaxiCode", BARCODE_MAXICODE, 57, },
|
||||
{ "QRCode", BARCODE_QRCODE, 58, },
|
||||
{ "", -1, 59, },
|
||||
{ "Code128", BARCODE_CODE128B, 60, },
|
||||
{ "Code128", BARCODE_CODE128AB, 60, },
|
||||
{ "", -1, 61, },
|
||||
{ "", -1, 62, },
|
||||
{ "", BARCODE_AUSPOST, 63, },
|
||||
|
@ -86,11 +86,12 @@ void testFinish(void);
|
||||
void testSkip(const char *msg);
|
||||
void testReport(void);
|
||||
|
||||
#define ZINT_TEST_CTX_EXC_MAX 32
|
||||
typedef struct s_testCtx {
|
||||
int index;
|
||||
int index_end;
|
||||
int exclude;
|
||||
int exclude_end;
|
||||
int exclude[ZINT_TEST_CTX_EXC_MAX];
|
||||
int exclude_end[ZINT_TEST_CTX_EXC_MAX];
|
||||
int generate;
|
||||
int debug;
|
||||
} testCtx;
|
||||
@ -163,6 +164,8 @@ int testUtilDirExists(const char *dirname);
|
||||
int testUtilMkDir(const char *dirname);
|
||||
int testUtilRmDir(const char *dirname);
|
||||
int testUtilRename(const char *oldpath, const char *newpath);
|
||||
int testUtilCreateROFile(const char *filename);
|
||||
int testUtilRmROFile(const char *filename);
|
||||
|
||||
int testUtilCmpPngs(const char *file1, const char *file2);
|
||||
int testUtilCmpTxts(const char *txt1, const char *txt2);
|
||||
@ -170,8 +173,8 @@ int testUtilCmpBins(const char *bin1, const char *bin2);
|
||||
int testUtilCmpSvgs(const char *svg1, const char *svg2);
|
||||
int testUtilCmpEpss(const char *eps1, const char *eps2);
|
||||
|
||||
int testUtilHaveIdentify(void);
|
||||
int testUtilVerifyIdentify(const char *filename, int debug);
|
||||
const char *testUtilHaveIdentify(void);
|
||||
int testUtilVerifyIdentify(const char *const prog, const char *filename, int debug);
|
||||
int testUtilHaveLibreOffice(void);
|
||||
int testUtilVerifyLibreOffice(const char *filename, int debug);
|
||||
int testUtilHaveGhostscript(void);
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#include "common.h"
|
||||
#include "output.h"
|
||||
#include "tif.h"
|
||||
#include "tif_lzw.h"
|
||||
|
||||
@ -331,7 +332,7 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
|
||||
#endif
|
||||
tif_file = stdout;
|
||||
} else {
|
||||
if (!(tif_file = fopen(symbol->outfile, "wb+"))) { /* '+' as use fseek/ftell() */
|
||||
if (!(tif_file = out_fopen(symbol->outfile, "wb+"))) { /* '+' as use fseek/ftell() */
|
||||
sprintf(symbol->errtxt, "672: Could not open output file (%d: %.30s)", errno, strerror(errno));
|
||||
return ZINT_ERROR_FILE_ACCESS;
|
||||
}
|
||||
@ -523,7 +524,11 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
|
||||
tags[entries].tag = 0x0128; /* ResolutionUnit */
|
||||
tags[entries].type = 3; /* SHORT */
|
||||
tags[entries].count = 1;
|
||||
tags[entries++].offset = 2; /* Inches */
|
||||
if (symbol->dpmm) {
|
||||
tags[entries++].offset = 3; /* Centimetres */
|
||||
} else {
|
||||
tags[entries++].offset = 2; /* Inches */
|
||||
}
|
||||
|
||||
if (color_map_size) {
|
||||
tags[entries].tag = 0x0140; /* ColorMap */
|
||||
@ -571,17 +576,17 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
|
||||
total_bytes_put += strip_count * 8;
|
||||
}
|
||||
|
||||
/* X Resolution */
|
||||
temp32 = 72;
|
||||
/* XResolution */
|
||||
temp32 = symbol->dpmm ? symbol->dpmm : 72;
|
||||
fwrite(&temp32, 4, 1, tif_file);
|
||||
temp32 = 1;
|
||||
temp32 = symbol->dpmm ? 10 /*cm*/ : 1;
|
||||
fwrite(&temp32, 4, 1, tif_file);
|
||||
total_bytes_put += 8;
|
||||
|
||||
/* Y Resolution */
|
||||
temp32 = 72;
|
||||
/* YResolution */
|
||||
temp32 = symbol->dpmm ? symbol->dpmm : 72;
|
||||
fwrite(&temp32, 4, 1, tif_file);
|
||||
temp32 = 1;
|
||||
temp32 = symbol->dpmm ? 10 /*cm*/ : 1;
|
||||
fwrite(&temp32, 4, 1, tif_file);
|
||||
total_bytes_put += 8;
|
||||
|
||||
|
@ -957,7 +957,7 @@ INTERNAL int ultra(struct zint_symbol *symbol, struct zint_seg segs[], const int
|
||||
if (symbol->structapp.id[0]) {
|
||||
int id, id_len;
|
||||
|
||||
for (id_len = 0; id_len < 32 && symbol->structapp.id[id_len]; id_len++);
|
||||
for (id_len = 1; id_len < 6 && symbol->structapp.id[id_len]; id_len++);
|
||||
|
||||
if (id_len > 5) { /* 282 * 283 + 282 = 80088 */
|
||||
strcpy(symbol->errtxt, "593: Structured Append ID too long (5 digit maximum)");
|
||||
|
@ -111,6 +111,7 @@ extern "C" {
|
||||
int fontsize; /* Unused */
|
||||
int input_mode; /* Encoding of input data (see DATA_MODE etc below). Default DATA_MODE */
|
||||
int eci; /* Extended Channel Interpretation. Default 0 (none) */
|
||||
float dpmm; /* Resolution of output in dots per mm (BMP/EMF/PCX/PNG/TIF only). Default 0 (none) */
|
||||
float dot_size; /* Size of dots used in BARCODE_DOTTY_MODE. Default 0.8 */
|
||||
float guard_descent; /* Height in X-dimensions that EAN/UPC guard bars descend. Default 5 */
|
||||
struct zint_structapp structapp; /* Structured Append info. Default structapp.count 0 (none) */
|
||||
@ -184,7 +185,8 @@ extern "C" {
|
||||
#define BARCODE_PDF417TRUNC 56 /* Legacy */
|
||||
#define BARCODE_MAXICODE 57 /* MaxiCode */
|
||||
#define BARCODE_QRCODE 58 /* QR Code */
|
||||
#define BARCODE_CODE128B 60 /* Code 128 (Subset B) */
|
||||
#define BARCODE_CODE128AB 60 /* Code 128 (Suppress subset C) */
|
||||
#define BARCODE_CODE128B 60 /* Legacy */
|
||||
#define BARCODE_AUSPOST 63 /* Australia Post Standard Customer */
|
||||
#define BARCODE_AUSREPLY 66 /* Australia Post Reply Paid */
|
||||
#define BARCODE_AUSROUTE 67 /* Australia Post Routing */
|
||||
@ -322,7 +324,7 @@ extern "C" {
|
||||
#define ZINT_ERROR_USES_ECI 13 /* Error counterpart of warning if WARN_FAIL_ALL set (see below) */
|
||||
#define ZINT_ERROR_NONCOMPLIANT 14 /* Error counterpart of warning if WARN_FAIL_ALL set */
|
||||
|
||||
/* Warning warn (`symbol->warn_level`) */
|
||||
/* Warning level (`symbol->warn_level`) */
|
||||
#define WARN_DEFAULT 0 /* Default behaviour */
|
||||
#define WARN_FAIL_ALL 2 /* Treat warning as error */
|
||||
|
||||
@ -443,6 +445,19 @@ extern "C" {
|
||||
ZINT_EXTERN unsigned int ZBarcode_Cap(int symbol_id, unsigned int cap_flag);
|
||||
|
||||
|
||||
/* Return default X-dimension in mm for symbology `symbol_id`. Returns 0 on error (invalid `symbol_id`) */
|
||||
ZINT_EXTERN float ZBarcode_Default_Xdim(int symbol_id);
|
||||
|
||||
/* Return the scale to use for `symbol_id` for non-zero X-dimension `x_dim_mm` at `dpmm` dots per mm for
|
||||
`filetype`. If `dpmm` zero defaults to 12. If `filetype` NULL/empty, defaults to "GIF". Returns 0 on error */
|
||||
ZINT_EXTERN float ZBarcode_Scale_From_XdimDp(int symbol_id, float x_dim_mm, float dpmm, const char *filetype);
|
||||
|
||||
/* Reverse of `ZBarcode_Scale_From_XdimDp()` above to estimate the X-dimension or dpmm given non-zero `scale` and
|
||||
non-zero `x_dim_mm_or_dpmm`. Return value bound to dpmm max not X-dimension max. Returns 0 on error */
|
||||
ZINT_EXTERN float ZBarcode_XdimDp_From_Scale(int symbol_id, float scale, float x_dim_mm_or_dpmm,
|
||||
const char *filetype);
|
||||
|
||||
|
||||
/* Whether Zint built without PNG support */
|
||||
ZINT_EXTERN int ZBarcode_NoPng(void);
|
||||
|
||||
|
Reference in New Issue
Block a user