mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-31 15:18:29 -04:00
Allow output to stdout
This commit is contained in:
parent
db6757ab91
commit
ef80d11beb
4 changed files with 33 additions and 13 deletions
|
@ -110,15 +110,17 @@ int png_to_file(struct zint_symbol *symbol, int image_height, int image_width, c
|
|||
bgblu = (16 * ctoi(symbol->bgcolour[4])) + ctoi(symbol->bgcolour[5]);
|
||||
|
||||
/* Open output file in binary mode */
|
||||
if (!(graphic->outfile = fopen(symbol->outfile, "wb"))) {
|
||||
strcpy(symbol->errtxt, "Can't open output file [B5]");
|
||||
return ERROR_FILE_ACCESS;
|
||||
if((symbol->output_options & BARCODE_STDOUT) != 0) {
|
||||
graphic->outfile = stdout;
|
||||
} else {
|
||||
if (!(graphic->outfile = fopen(symbol->outfile, "wb"))) {
|
||||
strcpy(symbol->errtxt, "Can't open output file [B5]");
|
||||
return ERROR_FILE_ACCESS;
|
||||
}
|
||||
}
|
||||
/* graphic->outfile = stdout; */
|
||||
|
||||
/* Set up error handling routine as proc() above */
|
||||
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, graphic,
|
||||
writepng_error_handler, NULL);
|
||||
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, graphic, writepng_error_handler, NULL);
|
||||
if (!png_ptr) {
|
||||
strcpy(symbol->errtxt, "Out of memory [B6]");
|
||||
return ERROR_MEMORY;
|
||||
|
@ -758,7 +760,7 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle)
|
|||
xoffset -= comp_offset;
|
||||
|
||||
/* Put boundary bars or box around symbol */
|
||||
if ((symbol->output_options == BARCODE_BOX) || (symbol->output_options == BARCODE_BIND)) {
|
||||
if(((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) {
|
||||
if(symbol->symbology != BARCODE_CODABLOCKF) {
|
||||
/* boundary bars */
|
||||
draw_bar(pixelbuf, 0, (symbol->width + xoffset + xoffset) * scaler, textoffset * scaler, symbol->border_width * scaler, image_width, image_height);
|
||||
|
@ -782,7 +784,7 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle)
|
|||
}
|
||||
}
|
||||
|
||||
if (symbol->output_options == BARCODE_BOX) {
|
||||
if((symbol->output_options & BARCODE_BOX) != 0) {
|
||||
/* side bars */
|
||||
draw_bar(pixelbuf, 0, symbol->border_width * scaler, textoffset * scaler, (symbol->height + (2 * symbol->border_width)) * scaler, image_width, image_height);
|
||||
draw_bar(pixelbuf, (symbol->width + xoffset + xoffset - symbol->border_width) * scaler, symbol->border_width * scaler, textoffset * scaler, (symbol->height + (2 * symbol->border_width)) * scaler, image_width, image_height);
|
||||
|
|
10
backend/ps.c
10
backend/ps.c
|
@ -66,7 +66,11 @@ int ps_plot(struct zint_symbol *symbol)
|
|||
comp_offset = 0;
|
||||
addon_text_posn = 0.0;
|
||||
|
||||
feps = fopen(symbol->outfile, "w");
|
||||
if((symbol->output_options & BARCODE_STDOUT) != 0) {
|
||||
feps = stdout;
|
||||
} else {
|
||||
feps = fopen(symbol->outfile, "w");
|
||||
}
|
||||
if(feps == NULL) {
|
||||
strcpy(symbol->errtxt, "Could not open output file [C1]");
|
||||
return ERROR_FILE_ACCESS;
|
||||
|
@ -683,7 +687,7 @@ int ps_plot(struct zint_symbol *symbol)
|
|||
|
||||
|
||||
/* Put boundary bars or box around symbol */
|
||||
if ((symbol->output_options == BARCODE_BOX) || (symbol->output_options == BARCODE_BIND)) {
|
||||
if (((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) {
|
||||
if(symbol->symbology != BARCODE_CODABLOCKF) {
|
||||
/* boundary bars */
|
||||
fprintf(feps, "TE\n");
|
||||
|
@ -719,7 +723,7 @@ int ps_plot(struct zint_symbol *symbol)
|
|||
}
|
||||
}
|
||||
|
||||
if (symbol->output_options == BARCODE_BOX) {
|
||||
if((symbol->output_options & BARCODE_BOX) != 0) {
|
||||
/* side bars */
|
||||
fprintf(feps, "TE\n");
|
||||
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
|
||||
|
|
|
@ -129,6 +129,7 @@ struct zint_symbol {
|
|||
#define BARCODE_NO_ASCII 1
|
||||
#define BARCODE_BIND 2
|
||||
#define BARCODE_BOX 4
|
||||
#define BARCODE_STDOUT 8
|
||||
|
||||
#define WARN_INVALID_OPTION 2
|
||||
#define ERROR_TOO_LONG 5
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue