diff --git a/backend/library.c b/backend/library.c index 8b46ca1f..9d94a5cd 100755 --- a/backend/library.c +++ b/backend/library.c @@ -215,8 +215,13 @@ void error_tag(char error_string[], int error_number) int dump_plot(struct zint_symbol *symbol) { + /* Output a hexadecimal representation of the rendered symbol */ FILE *f; int i, r; + int byt; + char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', + '9', 'A', 'B', 'C', 'D', 'E', 'F'}; + int space = 0; if(symbol->output_options & BARCODE_STDOUT) { f = stdout; @@ -228,15 +233,31 @@ int dump_plot(struct zint_symbol *symbol) } } - fputs("[\n", f); for (r = 0; r < symbol->rows; r++) { - fputs(" [ ", f); + byt = 0; for (i = 0; i < symbol->width; i++) { - fputs(module_is_set(symbol, r, i) ? "1 " : "0 ", f); + byt = byt << 1; + if (module_is_set(symbol, r, i)) { + byt += 1; + } + if (((i + 1) % 4) == 0) { + fputc(hex[byt], f); + space++; + byt = 0; + } + if (space == 2) { + fputc(' ', f); + space = 0; + } } - fputs("]\n", f); + + if ((symbol->width % 4) != 0) { + byt = byt << (4 - (symbol->width % 4)); + fputc(hex[byt], f); + } + fputs("\n", f); + space = 0; } - fputs("]\n", f); if(symbol->output_options & BARCODE_STDOUT) { fflush(f); diff --git a/frontend/main.c b/frontend/main.c index a247a6e1..9ff94905 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -91,7 +91,7 @@ void usage(void) " --directpng Send PNG output to stdout\n" " --directeps Send EPS output to stdout\n" " --directsvg Send SVG output to stdout\n" - " --dump Dump binary data to stdout\n" + " --dump Dump hexadecimal representation to stdout\n" " --rotate=NUMBER Rotate symbol (PNG output only).\n" " --cols=NUMBER (PDF417) Number of columns.\n" " --vers=NUMBER (QR Code) Version\n"