From 6902ad1e803cc8b0e0ed108443f225a2be03fde8 Mon Sep 17 00:00:00 2001 From: Robin Stuart Date: Mon, 19 Jul 2010 09:31:52 +0100 Subject: [PATCH] Add binding and boxes to rendering Added capabilities for row binding and bind/box options to render.c --- backend/render.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/backend/render.c b/backend/render.c index d6f72f07..8f57e907 100644 --- a/backend/render.c +++ b/backend/render.c @@ -449,9 +449,39 @@ int render_plot(struct zint_symbol *symbol, float width, float height) /* Put normal human readable text at the bottom (and centered) */ if (textdone == 0) { // caculate start xoffset to center text - render_plot_add_string(symbol, symbol->text, (symbol->width / 2.0) * scaler, default_text_posn, 9.0 * scaler, 0.0, &last_string); + render_plot_add_string(symbol, symbol->text, ((symbol->width / 2.0) + xoffset) * scaler, default_text_posn, 9.0 * scaler, 0.0, &last_string); } } + + switch(symbol->symbology) { + case BARCODE_MAXICODE: + /* Do nothing! */ + break; + default: + if((symbol->output_options & BARCODE_BIND) != 0) { + if((symbol->rows > 1) && (is_stackable(symbol->symbology) == 1)) { + /* row binding */ + for(r = 1; r < symbol->rows; r++) { + line = render_plot_create_line((xoffset + x_spacer) * scaler, ((r * row_height) + yoffset - 1 + y_spacer) * scaler, symbol->width * scaler, 2.0 * scaler); + render_plot_add_line(symbol, line, &last_line); + } + } + } + if (((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) { + line = render_plot_create_line((x_spacer * scaler), (y_spacer * scaler), (symbol->width + xoffset + xoffset) * scaler, symbol->border_width * scaler); + render_plot_add_line(symbol, line, &last_line); + line = render_plot_create_line((x_spacer * scaler), (symbol->height + symbol->border_width + y_spacer) * scaler, (symbol->width + xoffset + xoffset) * scaler, symbol->border_width * scaler); + render_plot_add_line(symbol, line, &last_line); + } + if((symbol->output_options & BARCODE_BOX) != 0) { + /* side bars */ + line = render_plot_create_line((x_spacer * scaler), (y_spacer * scaler), symbol->border_width * scaler, (symbol->height + (2 * symbol->border_width)) * scaler); + render_plot_add_line(symbol, line, &last_line); + line = render_plot_create_line((symbol->width + xoffset + xoffset - symbol->border_width + x_spacer) * scaler, (y_spacer * scaler), symbol->border_width * scaler, (symbol->height + (2 * symbol->border_width)) * scaler); + render_plot_add_line(symbol, line, &last_line); + } + break; + } if (locale) setlocale(LC_ALL, locale);