mirror of
https://git.code.sf.net/p/zint/code
synced 2026-01-10 13:36:02 +00:00
general: prefix all INTERNAL funcs/tables with zint_, except
those in "backend/common.h", which are prefixed by `z_` - makes symbol clashes more unlikely when zint is statically linked (ticket #337, props Ulrich Becker) DOTCODE: fix padding allowance (10 -> 52 - probable max 35) to cover cases with large no. of columns requested and little data, to prevent `codeword_array` buffer overflow AZTEC/CODEONE: some code fiddling general_field: prefix defines with `GF_`, shorten static funcs prefix `general_field_` -> `gf_`
This commit is contained in:
224
backend/tif.c
224
backend/tif.c
@@ -61,7 +61,7 @@ static void to_cmyk(const char *colour, unsigned char *cmyk) {
|
||||
int cyan, magenta, yellow, black;
|
||||
unsigned char alpha;
|
||||
|
||||
(void) out_colour_get_cmyk(colour, &cyan, &magenta, &yellow, &black, &alpha);
|
||||
(void) zint_out_colour_get_cmyk(colour, &cyan, &magenta, &yellow, &black, &alpha);
|
||||
cmyk[0] = (unsigned char) roundf(cyan * 0xFF / 100.0f);
|
||||
cmyk[1] = (unsigned char) roundf(magenta * 0xFF / 100.0f);
|
||||
cmyk[2] = (unsigned char) roundf(yellow * 0xFF / 100.0f);
|
||||
@@ -70,7 +70,7 @@ static void to_cmyk(const char *colour, unsigned char *cmyk) {
|
||||
}
|
||||
|
||||
/* TIFF Revision 6.0 https://www.adobe.io/content/dam/udp/en/open/standards/tiff/TIFF6.pdf */
|
||||
INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, const unsigned char *pixelbuf) {
|
||||
INTERNAL int zint_tif_pixel_plot(struct zint_symbol *symbol, const unsigned char *pixelbuf) {
|
||||
unsigned char fg[4], bg[4];
|
||||
int i;
|
||||
int pmi; /* PhotometricInterpretation */
|
||||
@@ -111,8 +111,8 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, const unsigned char *pix
|
||||
uint32_t temp32;
|
||||
uint16_t temp16;
|
||||
|
||||
(void) out_colour_get_rgb(symbol->fgcolour, &fg[0], &fg[1], &fg[2], &fg[3]);
|
||||
(void) out_colour_get_rgb(symbol->bgcolour, &bg[0], &bg[1], &bg[2], &bg[3]);
|
||||
(void) zint_out_colour_get_rgb(symbol->fgcolour, &fg[0], &fg[1], &fg[2], &fg[3]);
|
||||
(void) zint_out_colour_get_rgb(symbol->bgcolour, &bg[0], &bg[1], &bg[2], &bg[3]);
|
||||
|
||||
if (symbol->symbology == BARCODE_ULTRA) {
|
||||
static const unsigned char ultra_chars[8] = { 'W', 'C', 'B', 'M', 'R', 'Y', 'G', 'K' };
|
||||
@@ -305,13 +305,13 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, const unsigned char *pix
|
||||
}
|
||||
|
||||
if (free_memory > 0xffff0000) {
|
||||
return errtxt(ZINT_ERROR_MEMORY, symbol, 670, "TIF output file size too big");
|
||||
return z_errtxt(ZINT_ERROR_MEMORY, symbol, 670, "TIF output file size too big");
|
||||
}
|
||||
|
||||
/* Open output file in binary mode */
|
||||
if (!fm_open(fmp, symbol, "wb")) {
|
||||
return ZEXT errtxtf(ZINT_ERROR_FILE_ACCESS, symbol, 672, "Could not open TIF output file (%1$d: %2$s)",
|
||||
fmp->err, strerror(fmp->err));
|
||||
if (!zint_fm_open(fmp, symbol, "wb")) {
|
||||
return ZEXT z_errtxtf(ZINT_ERROR_FILE_ACCESS, symbol, 672, "Could not open TIF output file (%1$d: %2$s)",
|
||||
fmp->err, strerror(fmp->err));
|
||||
}
|
||||
if (!output_to_stdout) {
|
||||
compression = TIF_LZW;
|
||||
@@ -319,11 +319,11 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, const unsigned char *pix
|
||||
}
|
||||
|
||||
/* Header */
|
||||
out_le_u16(header.byte_order, 0x4949); /* "II" little-endian */
|
||||
out_le_u16(header.identity, 42);
|
||||
out_le_u32(header.offset, free_memory);
|
||||
zint_out_le_u16(header.byte_order, 0x4949); /* "II" little-endian */
|
||||
zint_out_le_u16(header.identity, 42);
|
||||
zint_out_le_u32(header.offset, free_memory);
|
||||
|
||||
fm_write(&header, sizeof(tiff_header_t), 1, fmp);
|
||||
zint_fm_write(&header, sizeof(tiff_header_t), 1, fmp);
|
||||
total_bytes_put = sizeof(tiff_header_t);
|
||||
|
||||
/* Pixel data */
|
||||
@@ -369,13 +369,13 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, const unsigned char *pix
|
||||
if (strip_row == rows_per_strip || (strip == strip_count - 1 && strip_row == rows_last_strip)) {
|
||||
/* End of strip */
|
||||
if (compression == TIF_LZW) {
|
||||
file_pos = fm_tell(fmp);
|
||||
file_pos = zint_fm_tell(fmp);
|
||||
if (!tif_lzw_encode(&lzw_state, fmp, strip_buf, bytes_put)) { /* Only fails if can't malloc */
|
||||
tif_lzw_cleanup(&lzw_state);
|
||||
(void) fm_close(fmp, symbol);
|
||||
return errtxt(ZINT_ERROR_MEMORY, symbol, 673, "Insufficient memory for TIF LZW hash table");
|
||||
(void) zint_fm_close(fmp, symbol);
|
||||
return z_errtxt(ZINT_ERROR_MEMORY, symbol, 673, "Insufficient memory for TIF LZW hash table");
|
||||
}
|
||||
bytes_put = fm_tell(fmp) - file_pos;
|
||||
bytes_put = zint_fm_tell(fmp) - file_pos;
|
||||
if (bytes_put != strip_bytes[strip]) {
|
||||
const int diff = bytes_put - strip_bytes[strip];
|
||||
strip_bytes[strip] = bytes_put;
|
||||
@@ -384,7 +384,7 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, const unsigned char *pix
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fm_write(strip_buf, 1, bytes_put, fmp);
|
||||
zint_fm_write(strip_buf, 1, bytes_put, fmp);
|
||||
}
|
||||
strip++;
|
||||
total_bytes_put += bytes_put;
|
||||
@@ -396,46 +396,46 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, const unsigned char *pix
|
||||
}
|
||||
|
||||
if (total_bytes_put & 1) {
|
||||
fm_putc(0, fmp); /* IFD must be on word boundary */
|
||||
zint_fm_putc(0, fmp); /* IFD must be on word boundary */
|
||||
total_bytes_put++;
|
||||
}
|
||||
|
||||
if (compression == TIF_LZW) {
|
||||
tif_lzw_cleanup(&lzw_state);
|
||||
|
||||
file_pos = fm_tell(fmp);
|
||||
fm_seek(fmp, 4, SEEK_SET);
|
||||
file_pos = zint_fm_tell(fmp);
|
||||
zint_fm_seek(fmp, 4, SEEK_SET);
|
||||
free_memory = file_pos;
|
||||
temp32 = (uint32_t) free_memory;
|
||||
/* Shouldn't happen as `free_memory` checked above to be <= 0xffff0000 & should only decrease */
|
||||
if (free_memory != temp32 || (long) free_memory != file_pos) {
|
||||
(void) fm_close(fmp, symbol);
|
||||
return errtxt(ZINT_ERROR_MEMORY, symbol, 982, "TIF output file size too big");
|
||||
(void) zint_fm_close(fmp, symbol);
|
||||
return z_errtxt(ZINT_ERROR_MEMORY, symbol, 982, "TIF output file size too big");
|
||||
}
|
||||
out_le_u32(temp32, temp32);
|
||||
fm_write(&temp32, 4, 1, fmp);
|
||||
fm_seek(fmp, file_pos, SEEK_SET);
|
||||
zint_out_le_u32(temp32, temp32);
|
||||
zint_fm_write(&temp32, 4, 1, fmp);
|
||||
zint_fm_seek(fmp, file_pos, SEEK_SET);
|
||||
}
|
||||
|
||||
/* Image File Directory */
|
||||
out_le_u16(tags[entries].tag, 0x0100); /* ImageWidth */
|
||||
out_le_u16(tags[entries].type, 3); /* SHORT */
|
||||
out_le_u32(tags[entries].count, 1);
|
||||
out_le_u32(tags[entries++].offset, symbol->bitmap_width);
|
||||
zint_out_le_u16(tags[entries].tag, 0x0100); /* ImageWidth */
|
||||
zint_out_le_u16(tags[entries].type, 3); /* SHORT */
|
||||
zint_out_le_u32(tags[entries].count, 1);
|
||||
zint_out_le_u32(tags[entries++].offset, symbol->bitmap_width);
|
||||
|
||||
out_le_u16(tags[entries].tag, 0x0101); /* ImageLength - number of rows */
|
||||
out_le_u16(tags[entries].type, 3); /* SHORT */
|
||||
out_le_u32(tags[entries].count, 1);
|
||||
out_le_u32(tags[entries++].offset, symbol->bitmap_height);
|
||||
zint_out_le_u16(tags[entries].tag, 0x0101); /* ImageLength - number of rows */
|
||||
zint_out_le_u16(tags[entries].type, 3); /* SHORT */
|
||||
zint_out_le_u32(tags[entries].count, 1);
|
||||
zint_out_le_u32(tags[entries++].offset, symbol->bitmap_height);
|
||||
|
||||
if (samples_per_pixel != 1 || bits_per_sample != 1) {
|
||||
out_le_u16(tags[entries].tag, 0x0102); /* BitsPerSample */
|
||||
out_le_u16(tags[entries].type, 3); /* SHORT */
|
||||
out_le_u32(tags[entries].count, samples_per_pixel);
|
||||
zint_out_le_u16(tags[entries].tag, 0x0102); /* BitsPerSample */
|
||||
zint_out_le_u16(tags[entries].type, 3); /* SHORT */
|
||||
zint_out_le_u32(tags[entries].count, samples_per_pixel);
|
||||
if (samples_per_pixel == 1) {
|
||||
out_le_u32(tags[entries++].offset, bits_per_sample);
|
||||
zint_out_le_u32(tags[entries++].offset, bits_per_sample);
|
||||
} else if (samples_per_pixel == 2) { /* 2 SHORTS fit into LONG offset so packed into offset */
|
||||
out_le_u32(tags[entries++].offset, (bits_per_sample << 16) | bits_per_sample);
|
||||
zint_out_le_u32(tags[entries++].offset, (bits_per_sample << 16) | bits_per_sample);
|
||||
} else {
|
||||
update_offsets[offsets++] = entries;
|
||||
tags[entries++].offset = (uint32_t) free_memory;
|
||||
@@ -443,21 +443,21 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, const unsigned char *pix
|
||||
}
|
||||
}
|
||||
|
||||
out_le_u16(tags[entries].tag, 0x0103); /* Compression */
|
||||
out_le_u16(tags[entries].type, 3); /* SHORT */
|
||||
out_le_u32(tags[entries].count, 1);
|
||||
out_le_u32(tags[entries++].offset, compression);
|
||||
zint_out_le_u16(tags[entries].tag, 0x0103); /* Compression */
|
||||
zint_out_le_u16(tags[entries].type, 3); /* SHORT */
|
||||
zint_out_le_u32(tags[entries].count, 1);
|
||||
zint_out_le_u32(tags[entries++].offset, compression);
|
||||
|
||||
out_le_u16(tags[entries].tag, 0x0106); /* PhotometricInterpretation */
|
||||
out_le_u16(tags[entries].type, 3); /* SHORT */
|
||||
out_le_u32(tags[entries].count, 1);
|
||||
out_le_u32(tags[entries++].offset, pmi);
|
||||
zint_out_le_u16(tags[entries].tag, 0x0106); /* PhotometricInterpretation */
|
||||
zint_out_le_u16(tags[entries].type, 3); /* SHORT */
|
||||
zint_out_le_u32(tags[entries].count, 1);
|
||||
zint_out_le_u32(tags[entries++].offset, pmi);
|
||||
|
||||
out_le_u16(tags[entries].tag, 0x0111); /* StripOffsets */
|
||||
out_le_u16(tags[entries].type, 4); /* LONG */
|
||||
out_le_u32(tags[entries].count, strip_count);
|
||||
zint_out_le_u16(tags[entries].tag, 0x0111); /* StripOffsets */
|
||||
zint_out_le_u16(tags[entries].type, 4); /* LONG */
|
||||
zint_out_le_u32(tags[entries].count, strip_count);
|
||||
if (strip_count == 1) {
|
||||
out_le_u32(tags[entries++].offset, strip_offset[0]);
|
||||
zint_out_le_u32(tags[entries++].offset, strip_offset[0]);
|
||||
} else {
|
||||
update_offsets[offsets++] = entries;
|
||||
tags[entries++].offset = (uint32_t) free_memory;
|
||||
@@ -465,83 +465,83 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, const unsigned char *pix
|
||||
}
|
||||
|
||||
if (samples_per_pixel > 1) {
|
||||
out_le_u16(tags[entries].tag, 0x0115); /* SamplesPerPixel */
|
||||
out_le_u16(tags[entries].type, 3); /* SHORT */
|
||||
out_le_u32(tags[entries].count, 1);
|
||||
out_le_u32(tags[entries++].offset, samples_per_pixel);
|
||||
zint_out_le_u16(tags[entries].tag, 0x0115); /* SamplesPerPixel */
|
||||
zint_out_le_u16(tags[entries].type, 3); /* SHORT */
|
||||
zint_out_le_u32(tags[entries].count, 1);
|
||||
zint_out_le_u32(tags[entries++].offset, samples_per_pixel);
|
||||
}
|
||||
|
||||
out_le_u16(tags[entries].tag, 0x0116); /* RowsPerStrip */
|
||||
out_le_u16(tags[entries].type, 4); /* LONG */
|
||||
out_le_u32(tags[entries].count, 1);
|
||||
out_le_u32(tags[entries++].offset, rows_per_strip);
|
||||
zint_out_le_u16(tags[entries].tag, 0x0116); /* RowsPerStrip */
|
||||
zint_out_le_u16(tags[entries].type, 4); /* LONG */
|
||||
zint_out_le_u32(tags[entries].count, 1);
|
||||
zint_out_le_u32(tags[entries++].offset, rows_per_strip);
|
||||
|
||||
out_le_u16(tags[entries].tag, 0x0117); /* StripByteCounts */
|
||||
out_le_u16(tags[entries].type, 4); /* LONG */
|
||||
out_le_u32(tags[entries].count, strip_count);
|
||||
zint_out_le_u16(tags[entries].tag, 0x0117); /* StripByteCounts */
|
||||
zint_out_le_u16(tags[entries].type, 4); /* LONG */
|
||||
zint_out_le_u32(tags[entries].count, strip_count);
|
||||
if (strip_count == 1) {
|
||||
out_le_u32(tags[entries++].offset, strip_bytes[0]);
|
||||
zint_out_le_u32(tags[entries++].offset, strip_bytes[0]);
|
||||
} else {
|
||||
update_offsets[offsets++] = entries;
|
||||
tags[entries++].offset = (uint32_t) free_memory;
|
||||
free_memory += strip_count * 4;
|
||||
}
|
||||
|
||||
out_le_u16(tags[entries].tag, 0x011a); /* XResolution */
|
||||
out_le_u16(tags[entries].type, 5); /* RATIONAL */
|
||||
out_le_u32(tags[entries].count, 1);
|
||||
zint_out_le_u16(tags[entries].tag, 0x011a); /* XResolution */
|
||||
zint_out_le_u16(tags[entries].type, 5); /* RATIONAL */
|
||||
zint_out_le_u32(tags[entries].count, 1);
|
||||
update_offsets[offsets++] = entries;
|
||||
tags[entries++].offset = (uint32_t) free_memory;
|
||||
free_memory += 8;
|
||||
|
||||
out_le_u16(tags[entries].tag, 0x011b); /* YResolution */
|
||||
out_le_u16(tags[entries].type, 5); /* RATIONAL */
|
||||
out_le_u32(tags[entries].count, 1);
|
||||
zint_out_le_u16(tags[entries].tag, 0x011b); /* YResolution */
|
||||
zint_out_le_u16(tags[entries].type, 5); /* RATIONAL */
|
||||
zint_out_le_u32(tags[entries].count, 1);
|
||||
update_offsets[offsets++] = entries;
|
||||
tags[entries++].offset = (uint32_t) free_memory;
|
||||
free_memory += 8;
|
||||
|
||||
out_le_u16(tags[entries].tag, 0x0128); /* ResolutionUnit */
|
||||
out_le_u16(tags[entries].type, 3); /* SHORT */
|
||||
out_le_u32(tags[entries].count, 1);
|
||||
zint_out_le_u16(tags[entries].tag, 0x0128); /* ResolutionUnit */
|
||||
zint_out_le_u16(tags[entries].type, 3); /* SHORT */
|
||||
zint_out_le_u32(tags[entries].count, 1);
|
||||
if (symbol->dpmm) {
|
||||
out_le_u32(tags[entries++].offset, 3); /* Centimetres */
|
||||
zint_out_le_u32(tags[entries++].offset, 3); /* Centimetres */
|
||||
} else {
|
||||
out_le_u32(tags[entries++].offset, 2); /* Inches */
|
||||
zint_out_le_u32(tags[entries++].offset, 2); /* Inches */
|
||||
}
|
||||
|
||||
if (color_map_size) {
|
||||
out_le_u16(tags[entries].tag, 0x0140); /* ColorMap */
|
||||
out_le_u16(tags[entries].type, 3); /* SHORT */
|
||||
out_le_u32(tags[entries].count, color_map_size * 3);
|
||||
zint_out_le_u16(tags[entries].tag, 0x0140); /* ColorMap */
|
||||
zint_out_le_u16(tags[entries].type, 3); /* SHORT */
|
||||
zint_out_le_u32(tags[entries].count, color_map_size * 3);
|
||||
update_offsets[offsets++] = entries;
|
||||
tags[entries++].offset = (uint32_t) free_memory;
|
||||
/* free_memory += color_map_size * 3 * 2; Unnecessary as long as last use */
|
||||
}
|
||||
|
||||
if (extra_samples) {
|
||||
out_le_u16(tags[entries].tag, 0x0152); /* ExtraSamples */
|
||||
out_le_u16(tags[entries].type, 3); /* SHORT */
|
||||
out_le_u32(tags[entries].count, 1);
|
||||
out_le_u32(tags[entries++].offset, extra_samples);
|
||||
zint_out_le_u16(tags[entries].tag, 0x0152); /* ExtraSamples */
|
||||
zint_out_le_u16(tags[entries].type, 3); /* SHORT */
|
||||
zint_out_le_u32(tags[entries].count, 1);
|
||||
zint_out_le_u32(tags[entries++].offset, extra_samples);
|
||||
}
|
||||
|
||||
ifd_size = sizeof(entries) + sizeof(tiff_tag_t) * entries + sizeof(offset);
|
||||
for (i = 0; i < offsets; i++) {
|
||||
out_le_u32(tags[update_offsets[i]].offset, tags[update_offsets[i]].offset + ifd_size);
|
||||
zint_out_le_u32(tags[update_offsets[i]].offset, tags[update_offsets[i]].offset + ifd_size);
|
||||
}
|
||||
|
||||
out_le_u16(temp16, entries);
|
||||
fm_write(&temp16, sizeof(entries), 1, fmp);
|
||||
fm_write(&tags, sizeof(tiff_tag_t), entries, fmp);
|
||||
out_le_u32(offset, offset);
|
||||
fm_write(&offset, sizeof(offset), 1, fmp);
|
||||
zint_out_le_u16(temp16, entries);
|
||||
zint_fm_write(&temp16, sizeof(entries), 1, fmp);
|
||||
zint_fm_write(&tags, sizeof(tiff_tag_t), entries, fmp);
|
||||
zint_out_le_u32(offset, offset);
|
||||
zint_fm_write(&offset, sizeof(offset), 1, fmp);
|
||||
total_bytes_put += ifd_size;
|
||||
|
||||
if (samples_per_pixel > 2) {
|
||||
out_le_u16(bits_per_sample, bits_per_sample);
|
||||
zint_out_le_u16(bits_per_sample, bits_per_sample);
|
||||
for (i = 0; i < samples_per_pixel; i++) {
|
||||
fm_write(&bits_per_sample, sizeof(bits_per_sample), 1, fmp);
|
||||
zint_fm_write(&bits_per_sample, sizeof(bits_per_sample), 1, fmp);
|
||||
}
|
||||
total_bytes_put += sizeof(bits_per_sample) * samples_per_pixel;
|
||||
}
|
||||
@@ -549,60 +549,60 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, const unsigned char *pix
|
||||
if (strip_count != 1) {
|
||||
/* Strip offsets */
|
||||
for (i = 0; i < strip_count; i++) {
|
||||
out_le_u32(temp32, strip_offset[i]);
|
||||
fm_write(&temp32, 4, 1, fmp);
|
||||
zint_out_le_u32(temp32, strip_offset[i]);
|
||||
zint_fm_write(&temp32, 4, 1, fmp);
|
||||
}
|
||||
|
||||
/* Strip byte lengths */
|
||||
for (i = 0; i < strip_count; i++) {
|
||||
out_le_u32(temp32, strip_bytes[i]);
|
||||
fm_write(&temp32, 4, 1, fmp);
|
||||
zint_out_le_u32(temp32, strip_bytes[i]);
|
||||
zint_fm_write(&temp32, 4, 1, fmp);
|
||||
}
|
||||
total_bytes_put += strip_count * 8;
|
||||
}
|
||||
|
||||
/* XResolution */
|
||||
out_le_u32(temp32, symbol->dpmm ? symbol->dpmm : 72);
|
||||
fm_write(&temp32, 4, 1, fmp);
|
||||
out_le_u32(temp32, symbol->dpmm ? 10 /*cm*/ : 1);
|
||||
fm_write(&temp32, 4, 1, fmp);
|
||||
zint_out_le_u32(temp32, symbol->dpmm ? symbol->dpmm : 72);
|
||||
zint_fm_write(&temp32, 4, 1, fmp);
|
||||
zint_out_le_u32(temp32, symbol->dpmm ? 10 /*cm*/ : 1);
|
||||
zint_fm_write(&temp32, 4, 1, fmp);
|
||||
total_bytes_put += 8;
|
||||
|
||||
/* YResolution */
|
||||
out_le_u32(temp32, symbol->dpmm ? symbol->dpmm : 72);
|
||||
fm_write(&temp32, 4, 1, fmp);
|
||||
out_le_u32(temp32, symbol->dpmm ? 10 /*cm*/ : 1);
|
||||
fm_write(&temp32, 4, 1, fmp);
|
||||
zint_out_le_u32(temp32, symbol->dpmm ? symbol->dpmm : 72);
|
||||
zint_fm_write(&temp32, 4, 1, fmp);
|
||||
zint_out_le_u32(temp32, symbol->dpmm ? 10 /*cm*/ : 1);
|
||||
zint_fm_write(&temp32, 4, 1, fmp);
|
||||
total_bytes_put += 8;
|
||||
|
||||
if (color_map_size) {
|
||||
for (i = 0; i < color_map_size; i++) {
|
||||
fm_write(&color_map[i].red, 2, 1, fmp);
|
||||
zint_fm_write(&color_map[i].red, 2, 1, fmp);
|
||||
}
|
||||
for (i = 0; i < color_map_size; i++) {
|
||||
fm_write(&color_map[i].green, 2, 1, fmp);
|
||||
zint_fm_write(&color_map[i].green, 2, 1, fmp);
|
||||
}
|
||||
for (i = 0; i < color_map_size; i++) {
|
||||
fm_write(&color_map[i].blue, 2, 1, fmp);
|
||||
zint_fm_write(&color_map[i].blue, 2, 1, fmp);
|
||||
}
|
||||
total_bytes_put += 6 * color_map_size;
|
||||
}
|
||||
|
||||
if (fm_error(fmp)) {
|
||||
ZEXT errtxtf(0, symbol, 679, "Incomplete write of TIF output (%1$d: %2$s)", fmp->err, strerror(fmp->err));
|
||||
(void) fm_close(fmp, symbol);
|
||||
if (zint_fm_error(fmp)) {
|
||||
ZEXT z_errtxtf(0, symbol, 679, "Incomplete write of TIF output (%1$d: %2$s)", fmp->err, strerror(fmp->err));
|
||||
(void) zint_fm_close(fmp, symbol);
|
||||
return ZINT_ERROR_FILE_WRITE;
|
||||
}
|
||||
|
||||
if (!output_to_stdout) {
|
||||
if (fm_tell(fmp) != total_bytes_put) {
|
||||
(void) fm_close(fmp, symbol);
|
||||
return errtxt(ZINT_ERROR_FILE_WRITE, symbol, 674, "Failed to write all TIF output");
|
||||
if (zint_fm_tell(fmp) != total_bytes_put) {
|
||||
(void) zint_fm_close(fmp, symbol);
|
||||
return z_errtxt(ZINT_ERROR_FILE_WRITE, symbol, 674, "Failed to write all TIF output");
|
||||
}
|
||||
}
|
||||
if (!fm_close(fmp, symbol)) {
|
||||
return ZEXT errtxtf(ZINT_ERROR_FILE_WRITE, symbol, 981, "Failure on closing TIF output file (%1$d: %2$s)",
|
||||
fmp->err, strerror(fmp->err));
|
||||
if (!zint_fm_close(fmp, symbol)) {
|
||||
return ZEXT z_errtxtf(ZINT_ERROR_FILE_WRITE, symbol, 981, "Failure on closing TIF output file (%1$d: %2$s)",
|
||||
fmp->err, strerror(fmp->err));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user