From f2262f26165b3a4539972e3117bd08604b7b2b79 Mon Sep 17 00:00:00 2001 From: Robin Stuart Date: Tue, 3 Sep 2019 19:53:01 +0100 Subject: [PATCH] Reinstate height adjustment for PDF Allows height adjustment of PDF417 and MicroPDF417 symbols. Fixes #161 reported by 'DigitalResident' --- backend/pdf417.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/backend/pdf417.c b/backend/pdf417.c index 7170503d..c6c66f2a 100644 --- a/backend/pdf417.c +++ b/backend/pdf417.c @@ -551,7 +551,7 @@ void numbprocess(int *chainemc, int *mclength, char chaine[], int start, int len /* 366 */ static int pdf417(struct zint_symbol *symbol, unsigned char chaine[], const size_t length) { int i, k, j, indexchaine, indexliste, mode, longueur, loop, mccorrection[520], offset; - int total, chainemc[2700], mclength, c1, c2, c3, dummy[35]; + int total, chainemc[2700], mclength, c1, c2, c3, dummy[35], calcheight; char pattern[580]; int debug = symbol->debug; @@ -808,10 +808,18 @@ static int pdf417(struct zint_symbol *symbol, unsigned char chaine[], const size set_module(symbol, i, loop); } } - - symbol->row_height[i] = 3; - } + + /* Allow user to adjust height of symbol, but enforce minimum row height of 3X */ + calcheight = (int)(symbol->height / i); + if (calcheight < 3) { + calcheight = 3; + } + + for (j = 0; j < i; j++) { + symbol->row_height[j] = calcheight; + } + symbol->rows = (mclength / symbol->option_2); symbol->width =(int)strlen(pattern); @@ -878,7 +886,7 @@ int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[], const size_ int total, chainemc[2700], mclength, dummy[5], codeerr; char pattern[580]; int variant, LeftRAPStart, CentreRAPStart, RightRAPStart, StartCluster; - int LeftRAP, CentreRAP, RightRAP, Cluster, loop; + int LeftRAP, CentreRAP, RightRAP, Cluster, loop, calcheight; int debug = 0; /* Encoding starts out the same as PDF417, so use the same code */ @@ -1283,6 +1291,16 @@ int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[], const size_ Cluster = 0; } } + + /* Allow user to adjust height of symbol, but enforce minimum row height of 2X */ + calcheight = (int)(symbol->height / i); + if (calcheight < 2) { + calcheight = 2; + } + + for (j = 0; j < i; j++) { + symbol->row_height[j] = calcheight; + } return codeerr; }