Improved PDF417 plotting and bugfix.

This commit is contained in:
hooper114 2009-12-20 23:08:04 +00:00
parent d1359c10ca
commit 2afe34a138
2 changed files with 15 additions and 27 deletions

View File

@ -30,7 +30,7 @@
symbol->option_2 is used to adjust the width of the resulting symbol (i.e. the symbol->option_2 is used to adjust the width of the resulting symbol (i.e. the
number of codeword columns not including row start and end data) */ number of codeword columns not including row start and end data) */
/* @(#) $Id: pdf417.c,v 1.17 2009/12/04 23:18:48 hooper114 Exp $ */ /* @(#) $Id: pdf417.c,v 1.18 2009/12/20 23:08:04 hooper114 Exp $ */
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -671,7 +671,9 @@ int pdf417(struct zint_symbol *symbol, unsigned char chaine[], int length)
for(loop = 0; loop < strlen(pattern); loop++) { for(loop = 0; loop < strlen(pattern); loop++) {
if(pattern[loop] == '1') { set_module(symbol, i, loop); } if(pattern[loop] == '1') { set_module(symbol, i, loop); }
} }
symbol->row_height[i] = 3; if(symbol->height == 0) {
symbol->row_height[i] = 3;
}
} }
symbol->rows = (mclength / symbol->option_2); symbol->rows = (mclength / symbol->option_2);
symbol->width = strlen(pattern); symbol->width = strlen(pattern);
@ -704,19 +706,6 @@ int pdf417enc(struct zint_symbol *symbol, unsigned char source[], int length)
error_number = WARN_INVALID_OPTION; error_number = WARN_INVALID_OPTION;
} }
/* The following to be replaced by ECI handling */
switch(symbol->input_mode) {
case DATA_MODE:
case GS1_MODE:
memcpy(local_source, source, length);
local_source[length] = '\0';
break;
case UNICODE_MODE:
error_number = latin1_process(symbol, source, local_source, &length);
if(error_number != 0) { return error_number; }
break;
}
/* 349 */ /* 349 */
codeerr = pdf417(symbol, local_source, length); codeerr = pdf417(symbol, local_source, length);

View File

@ -486,6 +486,8 @@ int png_to_file(struct zint_symbol *symbol, int image_height, int image_width, c
error_number = bmp_pixel_plot(symbol, scale_height, scale_width, scaled_pixelbuf, rotate_angle); error_number = bmp_pixel_plot(symbol, scale_height, scale_width, scaled_pixelbuf, rotate_angle);
} }
free(scaled_pixelbuf);
return error_number; return error_number;
} }
@ -705,6 +707,7 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type)
float row_height, row_posn; float row_height, row_posn;
int error_number; int error_number;
int default_text_posn; int default_text_posn;
int next_yposn;
#ifndef _MSC_VER #ifndef _MSC_VER
unsigned char local_text[ustrlen(symbol->text) + 1]; unsigned char local_text[ustrlen(symbol->text) + 1];
#else #else
@ -816,26 +819,22 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type)
default_text_posn = image_height - 17 - symbol->border_width - symbol->border_width; default_text_posn = image_height - 17 - symbol->border_width - symbol->border_width;
} }
row_posn = textoffset + yoffset;
next_yposn = textoffset + yoffset;
row_height = 0;
/* Plot the body of the symbol to the pixel buffer */ /* Plot the body of the symbol to the pixel buffer */
for(r = 0; r < symbol->rows; r++) { for(r = 0; r < symbol->rows; r++) {
this_row = symbol->rows - r - 1; /* invert r otherwise plots upside down */ this_row = symbol->rows - r - 1; /* invert r otherwise plots upside down */
row_posn += row_height;
plot_yposn = next_yposn;
if(symbol->row_height[this_row] == 0) { if(symbol->row_height[this_row] == 0) {
row_height = large_bar_height; row_height = large_bar_height;
} else { } else {
row_height = symbol->row_height[this_row]; row_height = symbol->row_height[this_row];
} }
row_posn = 0; next_yposn = (int)(row_posn + row_height);
for(i = 0; i < r; i++) { plot_height = next_yposn - plot_yposn;
if(symbol->row_height[symbol->rows - i - 1] == 0) {
row_posn += large_bar_height;
} else {
row_posn += symbol->row_height[symbol->rows - i - 1];
}
}
row_posn += (textoffset + yoffset);
plot_height = (int)row_height;
plot_yposn = (int)row_posn;
i = 0; i = 0;
if(module_is_set(symbol, this_row, 0)) { if(module_is_set(symbol, this_row, 0)) {