mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-16 16:14:36 -04:00
- zint_symbol->fgcolour
& bgcolour
buffer lengths extended 10
-> 16 to allow for "C,M,Y,K" comma-separated decimal percentage strings - API/CLI/GUI: allow foreground/background colours to be specified as comma-separated decimal "C,M,Y,K" strings where "C", "M" etc. are percentages (0-100) (ticket #281, 3rd point) - output.c: new funcs `out_colour_get_rgb()` & `out_colour_get_cmyk()` and use in bmp/emf/gif etc. - PCX: add alpha support - GUI: fix fg/gbcolor icon background not being reset on zap - GUI: Rearrange some Appearance tab inputs (Border Type <-> Width, Show Text <-> Font, Text/Font <-> Printing Scale/Size) to flow more naturally (hopefully) - GUI: save button "Save As..." -> "Save..." and add icon - CLI: add --bgcolor/colour & --fgcolor/colour synonyms
This commit is contained in:
parent
48eaa0cc4e
commit
ab2abccdb6
55 changed files with 1439 additions and 886 deletions
|
@ -1,7 +1,7 @@
|
|||
/* pcx.c - Handles output to ZSoft PCX file */
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2009-2022 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2009-2023 Robin Stuart <rstuart114@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
|
@ -42,8 +42,8 @@
|
|||
#include "pcx.h" /* PCX header structure */
|
||||
|
||||
/* ZSoft PCX File Format Technical Reference Manual http://bespin.org/~qz/pc-gpe/pcx.txt */
|
||||
INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) {
|
||||
int fgred, fggrn, fgblu, bgred, bggrn, bgblu;
|
||||
INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, const unsigned char *pixelbuf) {
|
||||
unsigned char fgred, fggrn, fgblu, fgalpha, bgred, bggrn, bgblu, bgalpha;
|
||||
int row, column, i, colour;
|
||||
int run_count;
|
||||
FILE *pcx_file;
|
||||
|
@ -55,17 +55,13 @@ INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
|
|||
|
||||
rle_row[bytes_per_line - 1] = 0; /* Will remain zero if bitmap_width odd */
|
||||
|
||||
fgred = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]);
|
||||
fggrn = (16 * ctoi(symbol->fgcolour[2])) + ctoi(symbol->fgcolour[3]);
|
||||
fgblu = (16 * ctoi(symbol->fgcolour[4])) + ctoi(symbol->fgcolour[5]);
|
||||
bgred = (16 * ctoi(symbol->bgcolour[0])) + ctoi(symbol->bgcolour[1]);
|
||||
bggrn = (16 * ctoi(symbol->bgcolour[2])) + ctoi(symbol->bgcolour[3]);
|
||||
bgblu = (16 * ctoi(symbol->bgcolour[4])) + ctoi(symbol->bgcolour[5]);
|
||||
(void) out_colour_get_rgb(symbol->fgcolour, &fgred, &fggrn, &fgblu, &fgalpha);
|
||||
(void) out_colour_get_rgb(symbol->bgcolour, &bgred, &bggrn, &bgblu, &bgalpha);
|
||||
|
||||
header.manufacturer = 10; /* ZSoft */
|
||||
header.version = 5; /* Version 3.0 */
|
||||
header.encoding = 1; /* Run length encoding */
|
||||
header.bits_per_pixel = 8;
|
||||
header.bits_per_pixel = 8; /* TODO: 1-bit monochrome black/white */
|
||||
header.window_xmin = 0;
|
||||
header.window_ymin = 0;
|
||||
header.window_xmax = symbol->bitmap_width - 1;
|
||||
|
@ -78,7 +74,7 @@ INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
|
|||
}
|
||||
|
||||
header.reserved = 0;
|
||||
header.number_of_planes = 3;
|
||||
header.number_of_planes = 3 + (fgalpha != 0xFF || bgalpha != 0xFF); /* TODO: 1-bit monochrome black/white */
|
||||
|
||||
header.bytes_per_line = bytes_per_line;
|
||||
|
||||
|
@ -109,11 +105,13 @@ INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
|
|||
fwrite(&header, sizeof(pcx_header_t), 1, pcx_file);
|
||||
|
||||
for (row = 0; row < symbol->bitmap_height; row++) {
|
||||
for (colour = 0; colour < 3; colour++) {
|
||||
const unsigned char *const pb = pixelbuf + row * symbol->bitmap_width;
|
||||
for (colour = 0; colour < header.number_of_planes; colour++) {
|
||||
for (column = 0; column < symbol->bitmap_width; column++) {
|
||||
const unsigned char ch = pb[column];
|
||||
switch (colour) {
|
||||
case 0:
|
||||
switch (pixelbuf[(row * symbol->bitmap_width) + column]) {
|
||||
switch (ch) {
|
||||
case 'W': /* White */
|
||||
case 'M': /* Magenta */
|
||||
case 'R': /* Red */
|
||||
|
@ -135,7 +133,7 @@ INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
|
|||
}
|
||||
break;
|
||||
case 1:
|
||||
switch (pixelbuf[(row * symbol->bitmap_width) + column]) {
|
||||
switch (ch) {
|
||||
case 'W': /* White */
|
||||
case 'C': /* Cyan */
|
||||
case 'Y': /* Yellow */
|
||||
|
@ -157,7 +155,7 @@ INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
|
|||
}
|
||||
break;
|
||||
case 2:
|
||||
switch (pixelbuf[(row * symbol->bitmap_width) + column]) {
|
||||
switch (ch) {
|
||||
case 'W': /* White */
|
||||
case 'C': /* Cyan */
|
||||
case 'B': /* Blue */
|
||||
|
@ -178,6 +176,9 @@ INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
|
|||
break;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
rle_row[column] = ch != '0' ? fgalpha : bgalpha;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue