From 382a051cb5569e230f2e8ccce4fb705ed9a7bf08 Mon Sep 17 00:00:00 2001 From: Robin Stuart Date: Mon, 3 Aug 2020 07:37:27 +0100 Subject: [PATCH] Extend no background option to EPS --- backend/ps.c | 24 ++++++++++++++++++------ docs/manual.txt | 6 +++--- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/backend/ps.c b/backend/ps.c index 31a2f39d..943ad0e1 100644 --- a/backend/ps.c +++ b/backend/ps.c @@ -112,6 +112,13 @@ INTERNAL int ps_plot(struct zint_symbol *symbol) { float radius; int colour_index, colour_rect_counter; char ps_color[30]; + int draw_background = 1; + + if (strlen(symbol->bgcolour) > 6) { + if ((ctoi(symbol->bgcolour[6]) == 0) && (ctoi(symbol->bgcolour[7]) == 0)) { + draw_background = 0; + } + } struct zint_vector_rect *rect; struct zint_vector_hexagon *hex; @@ -210,14 +217,19 @@ INTERNAL int ps_plot(struct zint_symbol *symbol) { fprintf(feps, "newpath\n"); /* Now the actual representation */ - if ((symbol->output_options & CMYK_COLOUR) == 0) { - fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_paper, green_paper, blue_paper); - } else { - fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_paper, magenta_paper, yellow_paper, black_paper); + + //Background + if (draw_background) { + if ((symbol->output_options & CMYK_COLOUR) == 0) { + fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_paper, green_paper, blue_paper); + } else { + fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_paper, magenta_paper, yellow_paper, black_paper); + } + + fprintf(feps, "%.2f 0.00 TB 0.00 %.2f TR\n", symbol->vector->height, symbol->vector->width); + fprintf(feps, "TE\n"); } - fprintf(feps, "%.2f 0.00 TB 0.00 %.2f TR\n", symbol->vector->height, symbol->vector->width); - fprintf(feps, "TE\n"); if (symbol->symbology != BARCODE_ULTRA) { if ((symbol->output_options & CMYK_COLOUR) == 0) { fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); diff --git a/docs/manual.txt b/docs/manual.txt index b56451dd..14c8f448 100644 --- a/docs/manual.txt +++ b/docs/manual.txt @@ -419,7 +419,7 @@ will give different results for PNG and SVG. Experimentation is advised! Also note that these options don't work properly with Maxicode yet. In addition the --nobackground option will simply remove the background from -PNG, SVG and EMF files. +PNG, SVG, EMF and EPS files. 4.8 Rotating the Symbol ----------------------- @@ -926,8 +926,8 @@ int main(int argc, char **argv) return 0; } -Background removal for PNG, SVG and EMF files can be achieved by setting the -background alpha to "00" where the values for R, G and B will be ignored: +Background removal for PNG, SVG, EMF and EPS files can be achieved by setting +the background alpha to "00" where the values for R, G and B will be ignored: strcpy(my_symbol->bgcolour, "55555500");