mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-24 12:07:00 -04:00
Ultra: Extend colour support to PNG PCX BMP and TIF
Implementation needs improvement, but colour output is now achieved in most formats
This commit is contained in:
parent
6181885e2e
commit
5861ad3c3b
6 changed files with 310 additions and 101 deletions
|
@ -83,16 +83,16 @@ int tif_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) {
|
|||
if ((symbol->bitmap_height % rows_per_strip) != 0) {
|
||||
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];
|
||||
|
@ -151,24 +151,67 @@ int tif_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) {
|
|||
|
||||
fwrite(&header, sizeof(tiff_header_t), 1, tif_file);
|
||||
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') {
|
||||
putc(fgred, tif_file);
|
||||
putc(fggrn, tif_file);
|
||||
putc(fgblu, tif_file);
|
||||
} else {
|
||||
putc(bgred, tif_file);
|
||||
putc(bggrn, tif_file);
|
||||
putc(bgblu, tif_file);
|
||||
switch(pixelbuf[(row * symbol->bitmap_width) + column]) {
|
||||
case 'W': // White
|
||||
putc(255, tif_file);
|
||||
putc(255, tif_file);
|
||||
putc(255, tif_file);
|
||||
break;
|
||||
case 'C': // Cyan
|
||||
putc(0, tif_file);
|
||||
putc(255, tif_file);
|
||||
putc(255, tif_file);
|
||||
break;
|
||||
case 'B': // Blue
|
||||
putc(0, tif_file);
|
||||
putc(0, tif_file);
|
||||
putc(255, tif_file);
|
||||
break;
|
||||
case 'M': // Magenta
|
||||
putc(255, tif_file);
|
||||
putc(0, tif_file);
|
||||
putc(255, tif_file);
|
||||
break;
|
||||
case 'R': // Red
|
||||
putc(255, tif_file);
|
||||
putc(0, tif_file);
|
||||
putc(0, tif_file);
|
||||
break;
|
||||
case 'Y': // Yellow
|
||||
putc(255, tif_file);
|
||||
putc(255, tif_file);
|
||||
putc(0, tif_file);
|
||||
break;
|
||||
case 'G': // Green
|
||||
putc(0, tif_file);
|
||||
putc(255, tif_file);
|
||||
putc(0, tif_file);
|
||||
break;
|
||||
case 'K': // Black
|
||||
putc(0, tif_file);
|
||||
putc(0, tif_file);
|
||||
putc(0, tif_file);
|
||||
break;
|
||||
case '1':
|
||||
putc(fgred, tif_file);
|
||||
putc(fggrn, tif_file);
|
||||
putc(fgblu, tif_file);
|
||||
break;
|
||||
default:
|
||||
putc(bgred, tif_file);
|
||||
putc(bggrn, tif_file);
|
||||
putc(bgblu, tif_file);
|
||||
break;
|
||||
}
|
||||
bytes_put += 3;
|
||||
}
|
||||
|
||||
|
||||
if ((bytes_put + 3) >= strip_bytes[strip]) {
|
||||
// End of strip, pad if strip length is odd
|
||||
if (strip_bytes[strip] % 2 == 1) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue