From 94fe73ebfdf164ca1d0be88781e41e02eefbcc26 Mon Sep 17 00:00:00 2001 From: Robin Stuart Date: Wed, 1 Apr 2020 20:01:02 +0100 Subject: [PATCH] Adjust size of Maxicode symbols when output as EMF Size and position of elements in EMF files is stored as an integer, therefore Maxicode does not render properly Increasing scale for these images ensures proper rendering Fixes #185 reported by Alex Roy --- backend/vector.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/backend/vector.c b/backend/vector.c index 51384fb9..228eddcb 100644 --- a/backend/vector.c +++ b/backend/vector.c @@ -1,7 +1,7 @@ /* vector.c - Creates vector image objects libzint - the open source barcode library - Copyright (C) 2018 Robin Stuart + Copyright (C) 2018 - 2020 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -193,13 +193,18 @@ INTERNAL void vector_free(struct zint_symbol *symbol) { } } -static void vector_scale(struct zint_symbol *symbol) { +static void vector_scale(struct zint_symbol *symbol, int file_type) { struct zint_vector_rect *rect; struct zint_vector_hexagon *hex; struct zint_vector_circle *circle; struct zint_vector_string *string; float scale = symbol->scale * 2.0f; + if ((file_type == OUT_EMF_FILE) && (symbol->symbology == BARCODE_MAXICODE)) { + // Increase size to overcome limitations in EMF file format + scale *= 20; + } + symbol->vector->width *= scale; symbol->vector->height *= scale; @@ -820,7 +825,7 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_ vector_reduce_rectangles(symbol); - vector_scale(symbol); + vector_scale(symbol, file_type); switch (file_type) { case OUT_EPS_FILE: