From 2f09c8f9387c2dd4b0fe4abdc72eff19170c7b2f Mon Sep 17 00:00:00 2001 From: hooper114 Date: Fri, 10 Jul 2009 08:19:22 +0000 Subject: [PATCH] Tweak Mode C blocks a bit more! --- backend/code128.c | 5 +++++ backend/code16k.c | 32 +++++++++++++++++++++++++++----- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/backend/code128.c b/backend/code128.c index 5ea5307e..1dde8880 100644 --- a/backend/code128.c +++ b/backend/code128.c @@ -704,6 +704,11 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[]) set[i - 1] = 'B'; } } + for(i = 1; i < read - 1; i++) { + if((set[i] == 'C') && ((set[i - 1] == 'B') && (set[i + 1] == 'B'))) { + set[i] = 'B'; + } + } /* for(i = 0; i < read; i++) { printf("char %c mode %c\n", reduced[i], set[i]); diff --git a/backend/code16k.c b/backend/code16k.c index 8b933da2..3cc319cf 100644 --- a/backend/code16k.c +++ b/backend/code16k.c @@ -305,19 +305,41 @@ int code16k(struct zint_symbol *symbol, unsigned char source[]) c_count = 0; for(i = 0; i < read; i++) { if(set[i] == 'C') { - if((source[i] == '[') && gs1) { - if(c_count % 2) { set[i - c_count] = 'B'; } + if(reduced[i] == '[') { + if(c_count % 2) { + if((i - c_count) != 0) { + set[i - c_count] = 'B'; + } else { + set[i - 1] = 'B'; + } + } c_count = 0; } else { c_count++; } } else { - if(c_count % 2) { set[i - c_count] = 'B'; } + if(c_count % 2) { + if((i - c_count) != 0) { + set[i - c_count] = 'B'; + } else { + set[i - 1] = 'B'; + } + } c_count = 0; } } - if(c_count % 2) { set[i - c_count] = 'B'; } - + if(c_count % 2) { + if((i - c_count) != 0) { + set[i - c_count] = 'B'; + } else { + set[i - 1] = 'B'; + } + } + for(i = 1; i < read - 1; i++) { + if((set[i] == 'C') && ((set[i - 1] == 'B') && (set[i + 1] == 'B'))) { + set[i] = 'B'; + } + } /* Make sure the data will fit in the symbol */ last_set = ' ';