mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-29 06:15:23 -04:00
Add alpha channel support and --nobackground option
Alpha channel for PNG and SVG and option to remove background from EMF
This commit is contained in:
parent
18e3b41e0f
commit
47cac63e7f
9 changed files with 195 additions and 72 deletions
|
@ -186,6 +186,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol) {
|
|||
int rectangle_count_bycolour[8];
|
||||
unsigned char *this_string[6];
|
||||
uint32_t spacing;
|
||||
int draw_background = 1;
|
||||
|
||||
float ax, ay, bx, by, cx, cy, dx, dy, ex, ey, fx, fy;
|
||||
|
||||
|
@ -223,6 +224,12 @@ INTERNAL int emf_plot(struct zint_symbol *symbol) {
|
|||
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]);
|
||||
|
||||
if (strlen(symbol->bgcolour) > 6) {
|
||||
if ((ctoi(symbol->bgcolour[6]) == 0) && (ctoi(symbol->bgcolour[7]) == 0)) {
|
||||
draw_background = 0;
|
||||
}
|
||||
}
|
||||
|
||||
rectangle_count = count_rectangles(symbol);
|
||||
circle_count = count_circles(symbol);
|
||||
|
@ -372,15 +379,17 @@ INTERNAL int emf_plot(struct zint_symbol *symbol) {
|
|||
bytecount += 12;
|
||||
recordcount++;
|
||||
|
||||
/* Make background from a rectangle */
|
||||
background.type = 0x0000002b; // EMR_RECTANGLE;
|
||||
background.size = 24;
|
||||
background.box.top = 0;
|
||||
background.box.left = 0;
|
||||
background.box.right = emr_header.emf_header.bounds.right;
|
||||
background.box.bottom = emr_header.emf_header.bounds.bottom;
|
||||
bytecount += 24;
|
||||
recordcount++;
|
||||
if (draw_background) {
|
||||
/* Make background from a rectangle */
|
||||
background.type = 0x0000002b; // EMR_RECTANGLE;
|
||||
background.size = 24;
|
||||
background.box.top = 0;
|
||||
background.box.left = 0;
|
||||
background.box.right = emr_header.emf_header.bounds.right;
|
||||
background.box.bottom = emr_header.emf_header.bounds.bottom;
|
||||
bytecount += 24;
|
||||
recordcount++;
|
||||
}
|
||||
|
||||
//Rectangles
|
||||
rect = symbol->vector->rectangles;
|
||||
|
@ -578,7 +587,9 @@ INTERNAL int emf_plot(struct zint_symbol *symbol) {
|
|||
|
||||
fwrite(&emr_selectobject_bgbrush, sizeof (emr_selectobject_t), 1, emf_file);
|
||||
fwrite(&emr_selectobject_pen, sizeof (emr_selectobject_t), 1, emf_file);
|
||||
fwrite(&background, sizeof (emr_rectangle_t), 1, emf_file);
|
||||
if (draw_background) {
|
||||
fwrite(&background, sizeof (emr_rectangle_t), 1, emf_file);
|
||||
}
|
||||
|
||||
if (symbol->symbology == BARCODE_ULTRA) {
|
||||
for(i = 0; i < 8; i++) {
|
||||
|
|
|
@ -55,7 +55,9 @@ struct zint_symbol *ZBarcode_Create() {
|
|||
symbol->rows = 0;
|
||||
symbol->width = 0;
|
||||
strcpy(symbol->fgcolour, "000000");
|
||||
symbol->fgcolor = &symbol->fgcolour[0];
|
||||
strcpy(symbol->bgcolour, "ffffff");
|
||||
symbol->bgcolor = &symbol->bgcolour[0];
|
||||
strcpy(symbol->outfile, "out.png");
|
||||
symbol->scale = 1.0;
|
||||
symbol->option_1 = -1;
|
||||
|
@ -67,6 +69,7 @@ struct zint_symbol *ZBarcode_Create() {
|
|||
symbol->bitmap = NULL;
|
||||
symbol->bitmap_width = 0;
|
||||
symbol->bitmap_height = 0;
|
||||
symbol->alphamap = NULL;
|
||||
symbol->eci = 0; // Default 0 uses ECI 3
|
||||
symbol->dot_size = 4.0 / 5.0;
|
||||
symbol->vector = NULL;
|
||||
|
|
|
@ -39,11 +39,11 @@
|
|||
INTERNAL int output_check_colour_options(struct zint_symbol *symbol) {
|
||||
int error_number;
|
||||
|
||||
if (strlen(symbol->fgcolour) != 6) {
|
||||
if ((strlen(symbol->fgcolour) != 6) && (strlen(symbol->fgcolour) != 8)) {
|
||||
strcpy(symbol->errtxt, "651: Malformed foreground colour target");
|
||||
return ZINT_ERROR_INVALID_OPTION;
|
||||
}
|
||||
if (strlen(symbol->bgcolour) != 6) {
|
||||
if ((strlen(symbol->bgcolour) != 6) && (strlen(symbol->bgcolour) != 8)) {
|
||||
strcpy(symbol->errtxt, "652: Malformed background colour target");
|
||||
return ZINT_ERROR_INVALID_OPTION;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ INTERNAL int output_check_colour_options(struct zint_symbol *symbol) {
|
|||
return ZINT_ERROR_INVALID_OPTION;
|
||||
}
|
||||
|
||||
error_number = is_sane(SSET, (unsigned char *) symbol->bgcolour, strlen(symbol->fgcolour));
|
||||
error_number = is_sane(SSET, (unsigned char *) symbol->bgcolour, strlen(symbol->bgcolour));
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "654: Malformed background colour target");
|
||||
return ZINT_ERROR_INVALID_OPTION;
|
||||
|
|
|
@ -79,11 +79,12 @@ INTERNAL int png_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) {
|
|||
png_infop info_ptr;
|
||||
int i, row, column;
|
||||
int fgred, fggrn, fgblu, bgred, bggrn, bgblu;
|
||||
int fgalpha, bgalpha, use_alpha;
|
||||
|
||||
#ifndef _MSC_VER
|
||||
unsigned char outdata[symbol->bitmap_width * 3];
|
||||
unsigned char outdata[symbol->bitmap_width * 4];
|
||||
#else
|
||||
unsigned char* outdata = (unsigned char*) _alloca(symbol->bitmap_width * 3);
|
||||
unsigned char* outdata = (unsigned char*) _alloca(symbol->bitmap_width * 4);
|
||||
#endif
|
||||
|
||||
graphic = &wpng_info;
|
||||
|
@ -98,6 +99,22 @@ INTERNAL int png_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) {
|
|||
bggrn = (16 * ctoi(symbol->bgcolour[2])) + ctoi(symbol->bgcolour[3]);
|
||||
bgblu = (16 * ctoi(symbol->bgcolour[4])) + ctoi(symbol->bgcolour[5]);
|
||||
|
||||
use_alpha = 0;
|
||||
|
||||
if (strlen(symbol->fgcolour) > 6) {
|
||||
fgalpha = (16 * ctoi(symbol->fgcolour[6])) + ctoi(symbol->fgcolour[7]);
|
||||
if (fgalpha != 0xff) use_alpha = 1;
|
||||
} else {
|
||||
fgalpha = 0xff;
|
||||
}
|
||||
|
||||
if (strlen(symbol->bgcolour) > 6) {
|
||||
bgalpha = (16 * ctoi(symbol->bgcolour[6])) + ctoi(symbol->bgcolour[7]);
|
||||
if (bgalpha != 0xff) use_alpha = 1;
|
||||
} else {
|
||||
bgalpha = 0xff;
|
||||
}
|
||||
|
||||
/* Open output file in binary mode */
|
||||
if (symbol->output_options & BARCODE_STDOUT) {
|
||||
#ifdef _MSC_VER
|
||||
|
@ -142,10 +159,14 @@ INTERNAL int png_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) {
|
|||
png_set_compression_level(png_ptr, 9);
|
||||
|
||||
/* set Header block */
|
||||
png_set_IHDR(png_ptr, info_ptr, graphic->width, graphic->height,
|
||||
8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
|
||||
PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
|
||||
|
||||
if (use_alpha)
|
||||
png_set_IHDR(png_ptr, info_ptr, graphic->width, graphic->height,
|
||||
8, PNG_COLOR_TYPE_RGBA, PNG_INTERLACE_NONE,
|
||||
PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
|
||||
else
|
||||
png_set_IHDR(png_ptr, info_ptr, graphic->width, graphic->height,
|
||||
8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
|
||||
PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
|
||||
/* write all chunks up to (but not including) first IDAT */
|
||||
png_write_info(png_ptr, info_ptr);
|
||||
|
||||
|
@ -158,56 +179,67 @@ INTERNAL int png_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) {
|
|||
unsigned char *image_data;
|
||||
for (column = 0; column < symbol->bitmap_width; column++) {
|
||||
i = column * 3;
|
||||
if (use_alpha) i += column;
|
||||
switch (*(pixelbuf + (symbol->bitmap_width * row) + column)) {
|
||||
case 'W': // White
|
||||
outdata[i] = 255;
|
||||
outdata[i + 1] = 255;
|
||||
outdata[i + 2] = 255;
|
||||
if (use_alpha) outdata[i + 3] = fgalpha;
|
||||
break;
|
||||
case 'C': // Cyan
|
||||
outdata[i] = 0;
|
||||
outdata[i + 1] = 255;
|
||||
outdata[i + 2] = 255;
|
||||
if (use_alpha) outdata[i + 3] = fgalpha;
|
||||
break;
|
||||
case 'B': // Blue
|
||||
outdata[i] = 0;
|
||||
outdata[i + 1] = 0;
|
||||
outdata[i + 2] = 255;
|
||||
if (use_alpha) outdata[i + 3] = fgalpha;
|
||||
break;
|
||||
case 'M': // Magenta
|
||||
outdata[i] = 255;
|
||||
outdata[i + 1] = 0;
|
||||
outdata[i + 2] = 255;
|
||||
if (use_alpha) outdata[i + 3] = fgalpha;
|
||||
break;
|
||||
case 'R': // Red
|
||||
outdata[i] = 255;
|
||||
outdata[i + 1] = 0;
|
||||
outdata[i + 2] = 0;
|
||||
if (use_alpha) outdata[i + 3] = fgalpha;
|
||||
break;
|
||||
case 'Y': // Yellow
|
||||
outdata[i] = 255;
|
||||
outdata[i + 1] = 255;
|
||||
outdata[i + 2] = 0;
|
||||
if (use_alpha) outdata[i + 3] = fgalpha;
|
||||
break;
|
||||
case 'G': // Green
|
||||
outdata[i] = 0;
|
||||
outdata[i + 1] = 255;
|
||||
outdata[i + 2] = 0;
|
||||
if (use_alpha) outdata[i + 3] = fgalpha;
|
||||
break;
|
||||
case 'K': // Black
|
||||
outdata[i] = 0;
|
||||
outdata[i + 1] = 0;
|
||||
outdata[i + 2] = 0;
|
||||
if (use_alpha) outdata[i + 3] = fgalpha;
|
||||
break;
|
||||
case '1':
|
||||
outdata[i] = fgred;
|
||||
outdata[i + 1] = fggrn;
|
||||
outdata[i + 2] = fgblu;
|
||||
if (use_alpha) outdata[i + 3] = fgalpha;
|
||||
break;
|
||||
default:
|
||||
outdata[i] = bgred;
|
||||
outdata[i + 1] = bggrn;
|
||||
outdata[i + 2] = bgblu;
|
||||
if (use_alpha) outdata[i + 3] = bgalpha;
|
||||
break;
|
||||
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ static const char ultra_colour[] = "WCBMRYGK";
|
|||
static int buffer_plot(struct zint_symbol *symbol, char *pixelbuf) {
|
||||
/* Place pixelbuffer into symbol */
|
||||
int fgred, fggrn, fgblu, bgred, bggrn, bgblu;
|
||||
int fgalpha, bgalpha;
|
||||
int row, column, i;
|
||||
|
||||
/* Free any previous bitmap */
|
||||
|
@ -74,6 +75,11 @@ static int buffer_plot(struct zint_symbol *symbol, char *pixelbuf) {
|
|||
strcpy(symbol->errtxt, "661: Insufficient memory for bitmap buffer");
|
||||
return ZINT_ERROR_MEMORY;
|
||||
}
|
||||
symbol->alphamap = (unsigned char *) malloc(symbol->bitmap_width * symbol->bitmap_height);
|
||||
if (symbol->alphamap == NULL) {
|
||||
strcpy(symbol->errtxt, "662: Insufficient memory for alphamap buffer");
|
||||
return ZINT_ERROR_MEMORY;
|
||||
}
|
||||
|
||||
fgred = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]);
|
||||
fggrn = (16 * ctoi(symbol->fgcolour[2])) + ctoi(symbol->fgcolour[3]);
|
||||
|
@ -81,6 +87,18 @@ static int buffer_plot(struct zint_symbol *symbol, char *pixelbuf) {
|
|||
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]);
|
||||
|
||||
if (strlen(symbol->fgcolour) > 6) {
|
||||
fgalpha = (16 * ctoi(symbol->fgcolour[6])) + ctoi(symbol->fgcolour[7]);
|
||||
} else {
|
||||
fgalpha = 0xff;
|
||||
}
|
||||
|
||||
if (strlen(symbol->bgcolour) > 6) {
|
||||
bgalpha = (16 * ctoi(symbol->bgcolour[6])) + ctoi(symbol->bgcolour[7]);
|
||||
} else {
|
||||
bgalpha = 0xff;
|
||||
}
|
||||
|
||||
for (row = 0; row < symbol->bitmap_height; row++) {
|
||||
for (column = 0; column < symbol->bitmap_width; column++) {
|
||||
|
@ -90,51 +108,61 @@ static int buffer_plot(struct zint_symbol *symbol, char *pixelbuf) {
|
|||
symbol->bitmap[i] = 255;
|
||||
symbol->bitmap[i + 1] = 255;
|
||||
symbol->bitmap[i + 2] = 255;
|
||||
symbol->alphamap[i / 3] = fgalpha;
|
||||
break;
|
||||
case 'C': // Cyan
|
||||
symbol->bitmap[i] = 0;
|
||||
symbol->bitmap[i + 1] = 255;
|
||||
symbol->bitmap[i + 2] = 255;
|
||||
symbol->alphamap[i / 3] = fgalpha;
|
||||
break;
|
||||
case 'B': // Blue
|
||||
symbol->bitmap[i] = 0;
|
||||
symbol->bitmap[i + 1] = 0;
|
||||
symbol->bitmap[i + 2] = 255;
|
||||
symbol->alphamap[i / 3] = fgalpha;
|
||||
break;
|
||||
case 'M': // Magenta
|
||||
symbol->bitmap[i] = 255;
|
||||
symbol->bitmap[i + 1] = 0;
|
||||
symbol->bitmap[i + 2] = 255;
|
||||
symbol->alphamap[i / 3] = fgalpha;
|
||||
break;
|
||||
case 'R': // Red
|
||||
symbol->bitmap[i] = 255;
|
||||
symbol->bitmap[i + 1] = 0;
|
||||
symbol->bitmap[i + 2] = 0;
|
||||
symbol->alphamap[i / 3] = fgalpha;
|
||||
break;
|
||||
case 'Y': // Yellow
|
||||
symbol->bitmap[i] = 255;
|
||||
symbol->bitmap[i + 1] = 255;
|
||||
symbol->bitmap[i + 2] = 0;
|
||||
symbol->alphamap[i / 3] = fgalpha;
|
||||
break;
|
||||
case 'G': // Green
|
||||
symbol->bitmap[i] = 0;
|
||||
symbol->bitmap[i + 1] = 255;
|
||||
symbol->bitmap[i + 2] = 0;
|
||||
symbol->alphamap[i / 3] = fgalpha;
|
||||
break;
|
||||
case 'K': // Black
|
||||
symbol->bitmap[i] = 0;
|
||||
symbol->bitmap[i + 1] = 0;
|
||||
symbol->bitmap[i + 2] = 0;
|
||||
symbol->alphamap[i / 3] = fgalpha;
|
||||
break;
|
||||
case DEFAULT_INK:
|
||||
symbol->bitmap[i] = fgred;
|
||||
symbol->bitmap[i + 1] = fggrn;
|
||||
symbol->bitmap[i + 2] = fgblu;
|
||||
symbol->alphamap[i / 3] = fgalpha;
|
||||
break;
|
||||
default: // DEFAULT_PAPER
|
||||
symbol->bitmap[i] = bgred;
|
||||
symbol->bitmap[i + 1] = bggrn;
|
||||
symbol->bitmap[i + 2] = bgblu;
|
||||
symbol->alphamap[i / 3] = bgalpha;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,6 +121,10 @@ INTERNAL int svg_plot(struct zint_symbol *symbol) {
|
|||
float ax, ay, bx, by, cx, cy, dx, dy, ex, ey, fx, fy;
|
||||
float radius;
|
||||
int i;
|
||||
char fgcolour_string[7];
|
||||
char bgcolour_string[7];
|
||||
int bg_alpha = 0xff;
|
||||
int fg_alpha = 0xff;
|
||||
|
||||
struct zint_vector_rect *rect;
|
||||
struct zint_vector_hexagon *hex;
|
||||
|
@ -133,6 +137,20 @@ INTERNAL int svg_plot(struct zint_symbol *symbol) {
|
|||
char* html_string;
|
||||
#endif
|
||||
|
||||
for (i = 0; i < 6; i++) {
|
||||
fgcolour_string[i] = symbol->fgcolour[i];
|
||||
bgcolour_string[i] = symbol->bgcolour[i];
|
||||
}
|
||||
fgcolour_string[6] = '\0';
|
||||
bgcolour_string[6] = '\0';
|
||||
|
||||
if (strlen(symbol->fgcolour) > 6) {
|
||||
fg_alpha = (16 * ctoi(symbol->fgcolour[6])) + ctoi(symbol->fgcolour[7]);
|
||||
}
|
||||
if (strlen(symbol->bgcolour) > 6) {
|
||||
bg_alpha = (16 * ctoi(symbol->bgcolour[6])) + ctoi(symbol->bgcolour[7]);
|
||||
}
|
||||
|
||||
int html_len = strlen((char *)symbol->text) + 1;
|
||||
|
||||
for (i = 0; i < (int) strlen((char *)symbol->text); i++) {
|
||||
|
@ -178,18 +196,27 @@ INTERNAL int svg_plot(struct zint_symbol *symbol) {
|
|||
fprintf(fsvg, " xmlns=\"http://www.w3.org/2000/svg\">\n");
|
||||
fprintf(fsvg, " <desc>Zint Generated Symbol\n");
|
||||
fprintf(fsvg, " </desc>\n");
|
||||
fprintf(fsvg, "\n <g id=\"barcode\" fill=\"#%s\">\n", symbol->fgcolour);
|
||||
fprintf(fsvg, "\n <g id=\"barcode\" fill=\"#%s\">\n", fgcolour_string);
|
||||
|
||||
fprintf(fsvg, " <rect x=\"0\" y=\"0\" width=\"%d\" height=\"%d\" fill=\"#%s\" />\n", (int) ceil(symbol->vector->width), (int) ceil(symbol->vector->height), symbol->bgcolour);
|
||||
if (bg_alpha != 0) {
|
||||
fprintf(fsvg, " <rect x=\"0\" y=\"0\" width=\"%d\" height=\"%d\" fill=\"#%s\"", (int) ceil(symbol->vector->width), (int) ceil(symbol->vector->height), bgcolour_string);
|
||||
if (bg_alpha != 0xff) {
|
||||
fprintf(fsvg, " opacity=\"%.3f\"", (float) bg_alpha / 255.0);
|
||||
}
|
||||
fprintf(fsvg, " />\n");
|
||||
}
|
||||
|
||||
rect = symbol->vector->rectangles;
|
||||
while (rect) {
|
||||
if (rect->colour == -1) {
|
||||
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", rect->x, rect->y, rect->width, rect->height);
|
||||
} else {
|
||||
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\"", rect->x, rect->y, rect->width, rect->height);
|
||||
if (rect->colour != -1) {
|
||||
pick_colour(rect->colour, colour_code);
|
||||
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" fill=\"#%s\" />\n", rect->x, rect->y, rect->width, rect->height, colour_code);
|
||||
fprintf(fsvg, " fill=\"#%s\"", colour_code);
|
||||
}
|
||||
if (fg_alpha != 0xff) {
|
||||
fprintf(fsvg, " opacity=\"%.3f\"", (float) fg_alpha / 255.0);
|
||||
}
|
||||
fprintf(fsvg, " />\n");
|
||||
rect = rect->next;
|
||||
}
|
||||
|
||||
|
@ -208,24 +235,41 @@ INTERNAL int svg_plot(struct zint_symbol *symbol) {
|
|||
dx = hex->x;
|
||||
ex = hex->x - (0.86 * radius);
|
||||
fx = hex->x - (0.86 * radius);
|
||||
fprintf(fsvg, " <path d=\"M %.2f %.2f L %.2f %.2f L %.2f %.2f L %.2f %.2f L %.2f %.2f L %.2f %.2f Z\" />\n", ax, ay, bx, by, cx, cy, dx, dy, ex, ey, fx, fy);
|
||||
fprintf(fsvg, " <path d=\"M %.2f %.2f L %.2f %.2f L %.2f %.2f L %.2f %.2f L %.2f %.2f L %.2f %.2f Z\"", ax, ay, bx, by, cx, cy, dx, dy, ex, ey, fx, fy);
|
||||
if (fg_alpha != 0xff) {
|
||||
fprintf(fsvg, " opacity=\"%.3f\"", (float) fg_alpha / 255.0);
|
||||
}
|
||||
fprintf(fsvg, " />\n");
|
||||
hex = hex->next;
|
||||
}
|
||||
|
||||
circle = symbol->vector->circles;
|
||||
while (circle) {
|
||||
fprintf(fsvg, " <circle cx=\"%.2f\" cy=\"%.2f\" r=\"%.2f\"", circle->x, circle->y, circle->diameter / 2.0);
|
||||
|
||||
if (circle->colour) {
|
||||
fprintf(fsvg, " <circle cx=\"%.2f\" cy=\"%.2f\" r=\"%.2f\" fill=\"#%s\" />\n", circle->x, circle->y, circle->diameter / 2.0, symbol->bgcolour);
|
||||
fprintf(fsvg, " fill=\"#%s\"", bgcolour_string);
|
||||
if (bg_alpha != 0xff) {
|
||||
// This doesn't work how the user is likely to expect - more work needed!
|
||||
fprintf(fsvg, " opacity=\"%.3f\"", (float) bg_alpha / 255.0);
|
||||
}
|
||||
} else {
|
||||
fprintf(fsvg, " <circle cx=\"%.2f\" cy=\"%.2f\" r=\"%.2f\" fill=\"#%s\" />\n", circle->x, circle->y, circle->diameter / 2.0, symbol->fgcolour);
|
||||
if (fg_alpha != 0xff) {
|
||||
fprintf(fsvg, " opacity=\"%.3f\"", (float) fg_alpha / 255.0);
|
||||
}
|
||||
}
|
||||
fprintf(fsvg, " />\n");
|
||||
circle = circle->next;
|
||||
}
|
||||
|
||||
string = symbol->vector->strings;
|
||||
while (string) {
|
||||
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", string->x, string->y);
|
||||
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", string->fsize, symbol->fgcolour);
|
||||
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\"", string->fsize);
|
||||
if (fg_alpha != 0xff) {
|
||||
fprintf(fsvg, " opacity=\"%.3f\"", (float) fg_alpha / 255.0);
|
||||
}
|
||||
fprintf(fsvg, " >\n");
|
||||
make_html_friendly(string->text, html_string);
|
||||
fprintf(fsvg, " %s\n", html_string);
|
||||
fprintf(fsvg, " </text>\n");
|
||||
|
|
|
@ -37,25 +37,12 @@
|
|||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
struct zint_render_line {
|
||||
float x, y, length, width;
|
||||
struct zint_render_line *next; /* Pointer to next line */
|
||||
};
|
||||
|
||||
struct zint_vector_rect {
|
||||
float x, y, height, width;
|
||||
int colour;
|
||||
struct zint_vector_rect *next;
|
||||
};
|
||||
|
||||
struct zint_render_string {
|
||||
float x, y, fsize;
|
||||
float width; /* Suggested string width, may be 0 if none recommended */
|
||||
int length;
|
||||
unsigned char *text;
|
||||
struct zint_render_string *next; /* Pointer to next character */
|
||||
};
|
||||
|
||||
|
||||
struct zint_vector_string {
|
||||
float x, y, fsize;
|
||||
float width; /* Suggested string width, may be 0 if none recommended */
|
||||
|
@ -64,35 +51,17 @@ extern "C" {
|
|||
struct zint_vector_string *next; /* Pointer to next character */
|
||||
};
|
||||
|
||||
struct zint_render_ring {
|
||||
float x, y, radius, line_width;
|
||||
struct zint_render_ring *next; /* Pointer to next ring */
|
||||
};
|
||||
|
||||
struct zint_vector_circle {
|
||||
float x, y, diameter;
|
||||
int colour;
|
||||
struct zint_vector_circle *next; /* Pointer to next circle */
|
||||
};
|
||||
|
||||
struct zint_render_hexagon {
|
||||
float x, y, height;
|
||||
struct zint_render_hexagon *next; /* Pointer to next hexagon */
|
||||
};
|
||||
|
||||
struct zint_vector_hexagon {
|
||||
float x, y, diameter;
|
||||
struct zint_vector_hexagon *next; /* Pointer to next hexagon */
|
||||
};
|
||||
|
||||
struct zint_render {
|
||||
float width, height;
|
||||
struct zint_render_line *lines; /* Pointer to first line */
|
||||
struct zint_render_string *strings; /* Pointer to first string */
|
||||
struct zint_render_ring *rings; /* Pointer to first ring */
|
||||
struct zint_render_hexagon *hexagons; /* Pointer to first hexagon */
|
||||
};
|
||||
|
||||
struct zint_vector {
|
||||
float width, height;
|
||||
struct zint_vector_rect *rectangles; /* Pointer to first rectangle */
|
||||
|
@ -108,7 +77,9 @@ extern "C" {
|
|||
int border_width;
|
||||
int output_options;
|
||||
char fgcolour[10];
|
||||
char *fgcolor; // pointer to fgcolour
|
||||
char bgcolour[10];
|
||||
char *bgcolor; // pointer to bgcolour
|
||||
char outfile[256];
|
||||
float scale;
|
||||
int option_1;
|
||||
|
@ -128,6 +99,7 @@ extern "C" {
|
|||
unsigned char *bitmap;
|
||||
int bitmap_width;
|
||||
int bitmap_height;
|
||||
unsigned char *alphamap;
|
||||
unsigned int bitmap_byte_length;
|
||||
float dot_size;
|
||||
struct zint_vector *vector;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue