Force TIFF to always use more than one strip

This commit is contained in:
Robin Stuart 2018-02-11 13:01:43 +00:00
parent 78d85bd72e
commit fa3c150610

View File

@ -55,7 +55,7 @@ int tif_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) {
int i;
int rows_per_strip, strip_count;
int free_memory;
int row, column;
int row, column, strip, bytes_put;
FILE *tif_file;
#ifdef _MSC_VER
uint32_t* strip_offset;
@ -84,6 +84,15 @@ int tif_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) {
strip_count++;
}
if (rows_per_strip > symbol->bitmap_height) {
rows_per_strip = symbol->bitmap_height;
}
if (strip_count == 1) {
rows_per_strip = (rows_per_strip / 2) + 1;
strip_count++;
}
#ifndef _MSC_VER
uint32_t strip_offset[strip_count];
uint32_t strip_bytes[strip_count];
@ -144,6 +153,8 @@ int tif_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) {
free_memory += sizeof(tiff_ifd_t);
/* Pixel data */
strip = 0;
bytes_put = 0;
for (row = 0; row < symbol->bitmap_height; row++) {
for (column = 0; column < symbol->bitmap_width; column++) {
if (pixelbuf[(row * symbol->bitmap_width) + column] == '1') {
@ -155,13 +166,16 @@ int tif_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) {
putc(bggrn, tif_file);
putc(bgblu, tif_file);
}
bytes_put += 3;
}
if (((row + 1) % rows_per_strip) == 0) {
/* End of a strip */
if ((strip_bytes[0] % 2) == 1) {
/* Add end-of strip pad */
if ((bytes_put + 3) >= strip_bytes[strip]) {
// End of strip, pad if strip length is odd
if (strip_bytes[strip] % 2 == 1) {
putc(0, tif_file);
}
strip++;
bytes_put = 0;
}
}