Merge branch Ultra

This commit is contained in:
Robin Stuart 2020-04-06 17:05:22 +01:00
commit 0d26948baa
16 changed files with 1671 additions and 192 deletions

View File

@ -74,6 +74,46 @@ INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) {
for (column = 0; column < symbol->bitmap_width; column++) {
i = (3 * column) + (row * row_size);
switch (*(pixelbuf + (symbol->bitmap_width * (symbol->bitmap_height - row - 1)) + column)) {
case 'W': // White
bitmap[i] = 255;
bitmap[i + 1] = 255;
bitmap[i + 2] = 255;
break;
case 'C': // Cyan
bitmap[i] = 255;
bitmap[i + 1] = 255;
bitmap[i + 2] = 0;
break;
case 'B': // Blue
bitmap[i] = 255;
bitmap[i + 1] = 0;
bitmap[i + 2] = 0;
break;
case 'M': // Magenta
bitmap[i] = 255;
bitmap[i + 1] = 0;
bitmap[i + 2] = 255;
break;
case 'R': // Red
bitmap[i] = 0;
bitmap[i + 1] = 0;
bitmap[i + 2] = 255;
break;
case 'Y': // Yellow
bitmap[i] = 0;
bitmap[i + 1] = 255;
bitmap[i + 2] = 255;
break;
case 'G': // Green
bitmap[i] = 0;
bitmap[i + 1] = 255;
bitmap[i + 2] = 0;
break;
case 'K': // Black
bitmap[i] = 0;
bitmap[i + 1] = 0;
bitmap[i + 2] = 0;
break;
case '1':
bitmap[i] = fgblu;
bitmap[i + 1] = fggrn;

View File

@ -152,8 +152,12 @@ INTERNAL int ustrchr_cnt(const unsigned char string[], const size_t length, cons
/* Return true (1) if a module is dark/black, otherwise false (0) */
INTERNAL int module_is_set(const struct zint_symbol *symbol, const int y_coord, const int x_coord) {
if (symbol->symbology == BARCODE_ULTRA) {
return symbol->encoded_data[y_coord][x_coord];
} else {
return (symbol->encoded_data[y_coord][x_coord / 7] >> (x_coord % 7)) & 1;
}
}
/* Set a module to dark/black */
INTERNAL void set_module(struct zint_symbol *symbol, const int y_coord, const int x_coord) {

View File

@ -42,6 +42,51 @@
#include "common.h"
#include "emf.h"
int colour_to_red(int colour) {
int return_val = 0;
switch(colour) {
case 0: // White
case 3: // Magenta
case 4: // Red
case 5: // Yellow
return_val = 255;
break;
}
return return_val;
}
int colour_to_green(int colour) {
int return_val = 0;
switch(colour) {
case 0: // White
case 1: // Cyan
case 5: // Yellow
case 6: // Green
return_val = 255;
break;
}
return return_val;
}
int colour_to_blue(int colour) {
int return_val = 0;
switch(colour) {
case 0: // White
case 1: // Cyan
case 2: // Blue
case 3: // Magenta
return_val = 255;
break;
}
return return_val;
}
static int count_rectangles(struct zint_symbol *symbol) {
int rectangles = 0;
struct zint_vector_rect *rect;
@ -137,6 +182,8 @@ INTERNAL int emf_plot(struct zint_symbol *symbol) {
int string_count, this_text;
int bytecount, recordcount;
float radius;
int colours_used = 0;
int rectangle_count_bycolour[8];
unsigned char *this_string[6];
uint32_t spacing;
@ -151,8 +198,10 @@ INTERNAL int emf_plot(struct zint_symbol *symbol) {
emr_eof_t emr_eof;
emr_createbrushindirect_t emr_createbrushindirect_fg;
emr_createbrushindirect_t emr_createbrushindirect_bg;
emr_createbrushindirect_t emr_createbrushindirect_colour[8]; // Used for colour symbols only
emr_selectobject_t emr_selectobject_fgbrush;
emr_selectobject_t emr_selectobject_bgbrush;
emr_selectobject_t emr_selectobject_colour[8]; // Used for colour symbols only
emr_createpen_t emr_createpen;
emr_selectobject_t emr_selectobject_pen;
emr_rectangle_t background;
@ -192,6 +241,23 @@ INTERNAL int emf_plot(struct zint_symbol *symbol) {
text = (emr_exttextoutw_t*) _alloca(string_count * sizeof (emr_exttextoutw_t));
#endif
//Calculate how many coloured rectangles
if (symbol->symbology == BARCODE_ULTRA) {
for (i = 0; i < 8; i++) {
rectangle_count_bycolour[i] = 0;
}
rect = symbol->vector->rectangles;
this_rectangle = 0;
while (rect) {
if (rectangle_count_bycolour[rect->colour] == 0) {
colours_used++;
}
rectangle_count_bycolour[rect->colour]++;
rect = rect->next;
}
}
/* Header */
emr_header.type = 0x00000001; // EMR_HEADER
emr_header.size = 88; // Assuming no additional data in header
@ -218,21 +284,9 @@ INTERNAL int emf_plot(struct zint_symbol *symbol) {
recordcount = 1;
/* Create Brushes */
emr_createbrushindirect_fg.type = 0x00000027; // EMR_CREATEBRUSHINDIRECT
emr_createbrushindirect_fg.size = 24;
emr_createbrushindirect_fg.ih_brush = 1;
emr_createbrushindirect_fg.log_brush.brush_style = 0x0000; // BS_SOLID
emr_createbrushindirect_fg.log_brush.color.red = fgred;
emr_createbrushindirect_fg.log_brush.color.green = fggrn;
emr_createbrushindirect_fg.log_brush.color.blue = fgblu;
emr_createbrushindirect_fg.log_brush.color.reserved = 0;
emr_createbrushindirect_fg.log_brush.brush_hatch = 0x0006; // HS_SOLIDCLR
bytecount += 24;
recordcount++;
emr_createbrushindirect_bg.type = 0x00000027; // EMR_CREATEBRUSHINDIRECT
emr_createbrushindirect_bg.size = 24;
emr_createbrushindirect_bg.ih_brush = 2;
emr_createbrushindirect_bg.ih_brush = 1;
emr_createbrushindirect_bg.log_brush.brush_style = 0x0000; // BS_SOLID
emr_createbrushindirect_bg.log_brush.color.red = bgred;
emr_createbrushindirect_bg.log_brush.color.green = bggrn;
@ -242,22 +296,60 @@ INTERNAL int emf_plot(struct zint_symbol *symbol) {
bytecount += 24;
recordcount++;
emr_selectobject_fgbrush.type = 0x00000025; // EMR_SELECTOBJECT
emr_selectobject_fgbrush.size = 12;
emr_selectobject_fgbrush.ih_object = 1;
bytecount += 12;
if (symbol->symbology == BARCODE_ULTRA) {
for (i = 0; i < 8; i++) {
emr_createbrushindirect_colour[i].type = 0x00000027; // EMR_CREATEBRUSHINDIRECT
emr_createbrushindirect_colour[i].size = 24;
emr_createbrushindirect_colour[i].ih_brush = 2 + i;
emr_createbrushindirect_colour[i].log_brush.brush_style = 0x0000; // BS_SOLID
emr_createbrushindirect_colour[i].log_brush.color.red = colour_to_red(i);
emr_createbrushindirect_colour[i].log_brush.color.green = colour_to_green(i);
emr_createbrushindirect_colour[i].log_brush.color.blue = colour_to_blue(i);
emr_createbrushindirect_colour[i].log_brush.color.reserved = 0;
emr_createbrushindirect_colour[i].log_brush.brush_hatch = 0x0006; // HS_SOLIDCLR
}
bytecount += colours_used * 24;
recordcount += colours_used;
} else {
emr_createbrushindirect_fg.type = 0x00000027; // EMR_CREATEBRUSHINDIRECT
emr_createbrushindirect_fg.size = 24;
emr_createbrushindirect_fg.ih_brush = 2;
emr_createbrushindirect_fg.log_brush.brush_style = 0x0000; // BS_SOLID
emr_createbrushindirect_fg.log_brush.color.red = fgred;
emr_createbrushindirect_fg.log_brush.color.green = fggrn;
emr_createbrushindirect_fg.log_brush.color.blue = fgblu;
emr_createbrushindirect_fg.log_brush.color.reserved = 0;
emr_createbrushindirect_fg.log_brush.brush_hatch = 0x0006; // HS_SOLIDCLR
bytecount += 24;
recordcount++;
}
emr_selectobject_bgbrush.type = 0x00000025; // EMR_SELECTOBJECT
emr_selectobject_bgbrush.size = 12;
emr_selectobject_bgbrush.ih_object = 2;
emr_selectobject_bgbrush.ih_object = 1;
bytecount += 12;
recordcount++;
if (symbol->symbology == BARCODE_ULTRA) {
for (i = 0; i < 8; i++) {
emr_selectobject_colour[i].type = 0x00000025; // EMR_SELECTOBJECT
emr_selectobject_colour[i].size = 12;
emr_selectobject_colour[i].ih_object = 2 + i;
}
bytecount += colours_used * 12;
recordcount += colours_used;
} else {
emr_selectobject_fgbrush.type = 0x00000025; // EMR_SELECTOBJECT
emr_selectobject_fgbrush.size = 12;
emr_selectobject_fgbrush.ih_object = 2;
bytecount += 12;
recordcount++;
}
/* Create Pens */
emr_createpen.type = 0x00000026; // EMR_CREATEPEN
emr_createpen.size = 28;
emr_createpen.ih_pen = 3;
emr_createpen.ih_pen = 10;
emr_createpen.log_pen.pen_style = 0x00000005; // PS_NULL
emr_createpen.log_pen.width.x = 1;
emr_createpen.log_pen.width.y = 0; // ignored
@ -270,7 +362,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol) {
emr_selectobject_pen.type = 0x00000025; // EMR_SELECTOBJECT
emr_selectobject_pen.size = 12;
emr_selectobject_pen.ih_object = 3;
emr_selectobject_pen.ih_object = 10;
bytecount += 12;
recordcount++;
@ -460,8 +552,18 @@ INTERNAL int emf_plot(struct zint_symbol *symbol) {
fwrite(&emr_header, sizeof (emr_header_t), 1, emf_file);
fwrite(&emr_createbrushindirect_fg, sizeof (emr_createbrushindirect_t), 1, emf_file);
fwrite(&emr_createbrushindirect_bg, sizeof (emr_createbrushindirect_t), 1, emf_file);
if (symbol->symbology == BARCODE_ULTRA) {
for (i = 0; i < 8; i++) {
if (rectangle_count_bycolour[i]) {
fwrite(&emr_createbrushindirect_colour[i], sizeof (emr_createbrushindirect_t), 1, emf_file);
}
}
} else {
fwrite(&emr_createbrushindirect_fg, sizeof (emr_createbrushindirect_t), 1, emf_file);
}
fwrite(&emr_createpen, sizeof (emr_createpen_t), 1, emf_file);
if (symbol->vector->strings) {
@ -472,12 +574,30 @@ INTERNAL int emf_plot(struct zint_symbol *symbol) {
fwrite(&emr_selectobject_pen, sizeof (emr_selectobject_t), 1, emf_file);
fwrite(&background, sizeof (emr_rectangle_t), 1, emf_file);
if (symbol->symbology == BARCODE_ULTRA) {
for(i = 0; i < 8; i++) {
if (rectangle_count_bycolour[i]) {
fwrite(&emr_selectobject_colour[i], sizeof (emr_selectobject_t), 1, emf_file);
rect = symbol->vector->rectangles;
this_rectangle = 0;
while (rect) {
if (rect->colour == i) {
fwrite(&rectangle[this_rectangle], sizeof (emr_rectangle_t), 1, emf_file);
}
this_rectangle++;
rect = rect->next;
}
}
}
} else {
fwrite(&emr_selectobject_fgbrush, sizeof (emr_selectobject_t), 1, emf_file);
// Rectangles
for (i = 0; i < rectangle_count; i++) {
fwrite(&rectangle[i], sizeof (emr_rectangle_t), 1, emf_file);
}
}
// Hexagons
for (i = 0; i < hexagon_count; i++) {

View File

@ -124,24 +124,69 @@ INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) {
for (column = 0; column < symbol->bitmap_width; column++) {
switch (colour) {
case 0:
if (pixelbuf[(row * symbol->bitmap_width) + column] == '1') {
switch(pixelbuf[(row * symbol->bitmap_width) + column]) {
case 'W': // White
case 'M': // Magenta
case 'R': // Red
case 'Y': // Yellow
rle_row[column] = 255;
break;
case 'C': // Cyan
case 'B': // Blue
case 'G': // Green
case 'K': // Black
rle_row[column] = 0;
break;
case '1':
rle_row[column] = fgred;
} else {
break;
default:
rle_row[column] = bgred;
break;
}
break;
case 1:
if (pixelbuf[(row * symbol->bitmap_width) + column] == '1') {
switch(pixelbuf[(row * symbol->bitmap_width) + column]) {
case 'W': // White
case 'C': // Cyan
case 'Y': // Yellow
case 'G': // Green
rle_row[column] = 255;
break;
case 'B': // Blue
case 'M': // Magenta
case 'R': // Red
case 'K': // Black
rle_row[column] = 0;
break;
case '1':
rle_row[column] = fggrn;
} else {
break;
default:
rle_row[column] = bggrn;
break;
}
break;
case 2:
if (pixelbuf[(row * symbol->bitmap_width) + column] == '1') {
switch(pixelbuf[(row * symbol->bitmap_width) + column]) {
case 'W': // White
case 'C': // Cyan
case 'B': // Blue
case 'M': // Magenta
rle_row[column] = 255;
break;
case 'R': // Red
case 'Y': // Yellow
case 'G': // Green
case 'K': // Black
rle_row[column] = 0;
break;
case '1':
rle_row[column] = fgblu;
} else {
break;
default:
rle_row[column] = bgblu;
break;
}
break;
}

View File

@ -159,6 +159,46 @@ INTERNAL int png_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) {
for (column = 0; column < symbol->bitmap_width; column++) {
i = column * 3;
switch (*(pixelbuf + (symbol->bitmap_width * row) + column)) {
case 'W': // White
outdata[i] = 255;
outdata[i + 1] = 255;
outdata[i + 2] = 255;
break;
case 'C': // Cyan
outdata[i] = 0;
outdata[i + 1] = 255;
outdata[i + 2] = 255;
break;
case 'B': // Blue
outdata[i] = 0;
outdata[i + 1] = 0;
outdata[i + 2] = 255;
break;
case 'M': // Magenta
outdata[i] = 255;
outdata[i + 1] = 0;
outdata[i + 2] = 255;
break;
case 'R': // Red
outdata[i] = 255;
outdata[i + 1] = 0;
outdata[i + 2] = 0;
break;
case 'Y': // Yellow
outdata[i] = 255;
outdata[i + 1] = 255;
outdata[i + 2] = 0;
break;
case 'G': // Green
outdata[i] = 0;
outdata[i + 1] = 255;
outdata[i + 2] = 0;
break;
case 'K': // Black
outdata[i] = 0;
outdata[i + 1] = 0;
outdata[i + 2] = 0;
break;
case '1':
outdata[i] = fgred;
outdata[i + 1] = fggrn;

View File

@ -38,6 +38,69 @@
#include <math.h>
#include "common.h"
void colour_to_pscolor(int option, int colour, char* output) {
strcpy(output, "");
if ((option & CMYK_COLOUR) == 0) {
// Use RGB colour space
switch(colour) {
case 0: // White
strcat(output, "1.00 1.00 1.00");
break;
case 1: // Cyan
strcat(output, "0.00 1.00 1.00");
break;
case 2: // Blue
strcat(output, "0.00 0.00 1.00");
break;
case 3: // Magenta
strcat(output, "1.00 0.00 1.00");
break;
case 4: // Red
strcat(output, "1.00 0.00 0.00");
break;
case 5: // Yellow
strcat(output, "1.00 1.00 0.00");
break;
case 6: // Green
strcat(output, "0.00 1.00 0.00");
break;
default: // Black
strcat(output, "0.00 0.00 0.00");
break;
}
strcat(output, " setrgbcolor");
} else {
// Use CMYK colour space
switch(colour) {
case 0: // White
strcat(output, "0.00 0.00 0.00 0.00");
break;
case 1: // Cyan
strcat(output, "1.00 0.00 0.00 0.00");
break;
case 2: // Blue
strcat(output, "1.00 1.00 0.00 0.00");
break;
case 3: // Magenta
strcat(output, "0.00 1.00 0.00 0.00");
break;
case 4: // Red
strcat(output, "0.00 1.00 1.00 0.00");
break;
case 5: // Yellow
strcat(output, "0.00 0.00 1.00 0.00");
break;
case 6: // Green
strcat(output, "1.00 0.00 1.00 0.00");
break;
default: // Black
strcat(output, "0.00 0.00 0.00 1.00");
break;
}
strcat(output, " setcmykcolor");
}
}
INTERNAL int ps_plot(struct zint_symbol *symbol) {
FILE *feps;
int fgred, fggrn, fgblu, bgred, bggrn, bgblu;
@ -47,6 +110,8 @@ INTERNAL int ps_plot(struct zint_symbol *symbol) {
int error_number = 0;
float ax, ay, bx, by, cx, cy, dx, dy, ex, ey, fx, fy;
float radius;
int colour_index, colour_rect_counter;
char ps_color[30];
struct zint_vector_rect *rect;
struct zint_vector_hexagon *hex;
@ -153,19 +218,41 @@ INTERNAL int ps_plot(struct zint_symbol *symbol) {
fprintf(feps, "%.2f 0.00 TB 0.00 %.2f TR\n", symbol->vector->height, symbol->vector->width);
fprintf(feps, "TE\n");
if (symbol->symbology != BARCODE_ULTRA) {
if ((symbol->output_options & CMYK_COLOUR) == 0) {
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
} else {
fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_ink, magenta_ink, yellow_ink, black_ink);
}
}
// Rectangles
if (symbol->symbology == BARCODE_ULTRA) {
for (colour_index = 0; colour_index <= 7; colour_index++) {
colour_rect_counter = 0;
rect = symbol->vector->rectangles;
while (rect) {
if (rect->colour == colour_index) {
if (colour_rect_counter == 0) {
//Set new colour
colour_to_pscolor(symbol->output_options, colour_index, ps_color);
fprintf(feps, "%s\n", ps_color);
}
colour_rect_counter++;
fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n", rect->height, (symbol->vector->height - rect->y) - rect->height, rect->x, rect->width);
fprintf(feps, "TE\n");
}
rect = rect->next;
}
}
} else {
rect = symbol->vector->rectangles;
while (rect) {
fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n", rect->height, (symbol->vector->height - rect->y) - rect->height, rect->x, rect->width);
fprintf(feps, "TE\n");
rect = rect->next;
}
}
// Hexagons
hex = symbol->vector->hexagons;

View File

@ -47,6 +47,9 @@
#define SSET "0123456789ABCDEF"
#define DEFAULT_INK '1'
#define DEFAULT_PAPER '0'
#ifndef NO_PNG
INTERNAL int png_pixel_plot(struct zint_symbol *symbol, char *pixelbuf);
#endif /* NO_PNG */
@ -55,6 +58,8 @@ INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, char *pixelbuf);
INTERNAL int gif_pixel_plot(struct zint_symbol *symbol, char *pixelbuf);
INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, char *pixelbuf);
static const char ultra_colour[] = "WCBMRYGK";
static void buffer_plot(struct zint_symbol *symbol, char *pixelbuf) {
/* Place pixelbuffer into symbol */
int fgred, fggrn, fgblu, bgred, bggrn, bgblu;
@ -73,12 +78,52 @@ static void buffer_plot(struct zint_symbol *symbol, char *pixelbuf) {
for (column = 0; column < symbol->bitmap_width; column++) {
i = ((row * symbol->bitmap_width) + column) * 3;
switch (*(pixelbuf + (symbol->bitmap_width * row) + column)) {
case '1':
case 'W': // White
symbol->bitmap[i] = 255;
symbol->bitmap[i + 1] = 255;
symbol->bitmap[i + 2] = 255;
break;
case 'C': // Cyan
symbol->bitmap[i] = 0;
symbol->bitmap[i + 1] = 255;
symbol->bitmap[i + 2] = 255;
break;
case 'B': // Blue
symbol->bitmap[i] = 0;
symbol->bitmap[i + 1] = 0;
symbol->bitmap[i + 2] = 255;
break;
case 'M': // Magenta
symbol->bitmap[i] = 255;
symbol->bitmap[i + 1] = 0;
symbol->bitmap[i + 2] = 255;
break;
case 'R': // Red
symbol->bitmap[i] = 255;
symbol->bitmap[i + 1] = 0;
symbol->bitmap[i + 2] = 0;
break;
case 'Y': // Yellow
symbol->bitmap[i] = 255;
symbol->bitmap[i + 1] = 255;
symbol->bitmap[i + 2] = 0;
break;
case 'G': // Green
symbol->bitmap[i] = 0;
symbol->bitmap[i + 1] = 255;
symbol->bitmap[i + 2] = 0;
break;
case 'K': // Black
symbol->bitmap[i] = 0;
symbol->bitmap[i + 1] = 0;
symbol->bitmap[i + 2] = 0;
break;
case DEFAULT_INK:
symbol->bitmap[i] = fgred;
symbol->bitmap[i + 1] = fggrn;
symbol->bitmap[i + 2] = fgblu;
break;
default:
default: // DEFAULT_PAPER
symbol->bitmap[i] = bgred;
symbol->bitmap[i + 1] = bggrn;
symbol->bitmap[i + 2] = bgblu;
@ -207,7 +252,7 @@ static int save_raster_image_to_file(struct zint_symbol *symbol, int image_heigh
return error_number;
}
static void draw_bar(char *pixelbuf, int xpos, int xlen, int ypos, int ylen, int image_width, int image_height) {
static void draw_bar(char *pixelbuf, int xpos, int xlen, int ypos, int ylen, int image_width, int image_height, char fill) {
/* Draw a rectangle */
int i, j, png_ypos;
@ -217,7 +262,7 @@ static void draw_bar(char *pixelbuf, int xpos, int xlen, int ypos, int ylen, int
for (i = (xpos); i < (xpos + xlen); i++) {
for (j = (png_ypos); j < (png_ypos + ylen); j++) {
*(pixelbuf + (image_width * j) + i) = '1';
*(pixelbuf + (image_width * j) + i) = fill;
}
}
}
@ -247,12 +292,12 @@ static void draw_bullseye(char *pixelbuf, int image_width, int image_height, int
y = 16.5 * scaler;
}
draw_circle(pixelbuf, image_width, image_height, x + xoffset, y + yoffset, (4.571 * scaler) + 1, '1');
draw_circle(pixelbuf, image_width, image_height, x + xoffset, y + yoffset, (3.779 * scaler) + 1, '0');
draw_circle(pixelbuf, image_width, image_height, x + xoffset, y + yoffset, (2.988 * scaler) + 1, '1');
draw_circle(pixelbuf, image_width, image_height, x + xoffset, y + yoffset, (2.196 * scaler) + 1, '0');
draw_circle(pixelbuf, image_width, image_height, x + xoffset, y + yoffset, (1.394 * scaler) + 1, '1');
draw_circle(pixelbuf, image_width, image_height, x + xoffset, y + yoffset, (0.602 * scaler) + 1, '0');
draw_circle(pixelbuf, image_width, image_height, x + xoffset, y + yoffset, (4.571 * scaler) + 1, DEFAULT_INK);
draw_circle(pixelbuf, image_width, image_height, x + xoffset, y + yoffset, (3.779 * scaler) + 1, DEFAULT_PAPER);
draw_circle(pixelbuf, image_width, image_height, x + xoffset, y + yoffset, (2.988 * scaler) + 1, DEFAULT_INK);
draw_circle(pixelbuf, image_width, image_height, x + xoffset, y + yoffset, (2.196 * scaler) + 1, DEFAULT_PAPER);
draw_circle(pixelbuf, image_width, image_height, x + xoffset, y + yoffset, (1.394 * scaler) + 1, DEFAULT_INK);
draw_circle(pixelbuf, image_width, image_height, x + xoffset, y + yoffset, (0.602 * scaler) + 1, DEFAULT_PAPER);
}
static void draw_hexagon(char *pixelbuf, int image_width, char *scaled_hexagon, int hexagon_size, int xposn, int yposn) {
@ -261,8 +306,8 @@ static void draw_hexagon(char *pixelbuf, int image_width, char *scaled_hexagon,
for (i = 0; i < hexagon_size; i++) {
for (j = 0; j < hexagon_size; j++) {
if (scaled_hexagon[(i * hexagon_size) + j] == '1') {
*(pixelbuf + (image_width * i) + (image_width * yposn) + xposn + j) = '1';
if (scaled_hexagon[(i * hexagon_size) + j] == DEFAULT_INK) {
*(pixelbuf + (image_width * i) + (image_width * yposn) + xposn + j) = DEFAULT_INK;
}
}
}
@ -313,7 +358,7 @@ static void draw_letter(char *pixelbuf, unsigned char letter, int xposn, int ypo
for (y = 0; y < max_y; y++) {
for (x = 0; x < max_x; x++) {
if (small_font[(glyph_no * 9) + y] & (0x10 >> x)) {
*(pixelbuf + (y * image_width) + (yposn * image_width) + xposn + x) = '1';
*(pixelbuf + (y * image_width) + (yposn * image_width) + xposn + x) = DEFAULT_INK;
}
}
}
@ -339,11 +384,11 @@ static void draw_letter(char *pixelbuf, unsigned char letter, int xposn, int ypo
int extra_dot = 0;
for (x = 0; x < 7; x++) {
if (ascii_font[(glyph_no * 14) + y] & (0x40 >> x)) {
*pixelPtr = '1';
*pixelPtr = DEFAULT_INK;
extra_dot = 1;
} else {
if (extra_dot) {
*pixelPtr = '1';
*pixelPtr = DEFAULT_INK;
}
extra_dot = 0;
@ -353,7 +398,7 @@ static void draw_letter(char *pixelbuf, unsigned char letter, int xposn, int ypo
}
if (extra_dot) {
*pixelPtr = '1';
*pixelPtr = DEFAULT_INK;
}
linePtr += image_width;
@ -376,7 +421,7 @@ static void draw_letter(char *pixelbuf, unsigned char letter, int xposn, int ypo
for (y = 0; y < max_y; y++) {
for (x = 0; x < 7; x++) {
if (ascii_font[(glyph_no * 14) + y] & (0x40 >> x)) {
*(pixelbuf + (y * image_width) + (yposn * image_width) + xposn + x) = '1';
*(pixelbuf + (y * image_width) + (yposn * image_width) + xposn + x) = DEFAULT_INK;
}
}
}
@ -424,7 +469,7 @@ static void plot_hexline(char *scaled_hexagon, int hexagon_size, float start_x,
float this_x = start_x + ((float)i * inc_x);
float this_y = start_y + ((float)i * inc_y);
if (((this_x >= 0) && (this_x < hexagon_size)) && ((this_y >= 0) && (this_y < hexagon_size))) {
scaled_hexagon[(hexagon_size * (int)this_y) + (int)this_x] = '1';
scaled_hexagon[(hexagon_size * (int)this_y) + (int)this_x] = DEFAULT_INK;
}
}
}
@ -468,17 +513,17 @@ static void plot_hexagon(char *scaled_hexagon, int hexagon_size) {
/* Fill hexagon */
for (line = 0; line < hexagon_size; line++) {
char ink = '0';
char ink = DEFAULT_PAPER;
for (i = 0; i < hexagon_size; i++) {
if (scaled_hexagon[(hexagon_size * line) + i] == '1') {
if (scaled_hexagon[(hexagon_size * line) + i] == DEFAULT_INK) {
if (i < (hexagon_size / 2)) {
ink = '1';
ink = DEFAULT_INK;
} else {
ink = '0';
ink = DEFAULT_PAPER;
}
}
if (ink == '1') {
if (ink == DEFAULT_INK) {
scaled_hexagon[(hexagon_size * line) + i] = ink;
}
}
@ -506,7 +551,7 @@ static int plot_raster_maxicode(struct zint_symbol *symbol, int rotate_angle, in
return ZINT_ERROR_ENCODING_PROBLEM;
} else {
for (i = 0; i < (image_width * image_height); i++) {
*(pixelbuf + i) = '0';
*(pixelbuf + i) = DEFAULT_PAPER;
}
}
@ -518,7 +563,7 @@ static int plot_raster_maxicode(struct zint_symbol *symbol, int rotate_angle, in
return ZINT_ERROR_ENCODING_PROBLEM;
} else {
for (i = 0; i < (hexagon_size * hexagon_size); i++) {
*(scaled_hexagon + i) = '0';
*(scaled_hexagon + i) = DEFAULT_PAPER;
}
}
@ -548,14 +593,14 @@ static int plot_raster_maxicode(struct zint_symbol *symbol, int rotate_angle, in
if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) {
/* boundary bars */
draw_bar(pixelbuf, 0, image_width, 0, symbol->border_width * 2, image_width, image_height);
draw_bar(pixelbuf, 0, image_width, 300 + (symbol->border_width * 2), symbol->border_width * 2, image_width, image_height);
draw_bar(pixelbuf, 0, image_width, 0, symbol->border_width * 2, image_width, image_height, DEFAULT_INK);
draw_bar(pixelbuf, 0, image_width, 300 + (symbol->border_width * 2), symbol->border_width * 2, image_width, image_height, DEFAULT_INK);
}
if (symbol->output_options & BARCODE_BOX) {
/* side bars */
draw_bar(pixelbuf, 0, symbol->border_width * 2, 0, image_height, image_width, image_height);
draw_bar(pixelbuf, 300 + ((symbol->border_width + symbol->whitespace_width + symbol->whitespace_width) * 2), symbol->border_width * 2, 0, image_height, image_width, image_height);
draw_bar(pixelbuf, 0, symbol->border_width * 2, 0, image_height, image_width, image_height, DEFAULT_INK);
draw_bar(pixelbuf, 300 + ((symbol->border_width + symbol->whitespace_width + symbol->whitespace_width) * 2), symbol->border_width * 2, 0, image_height, image_width, image_height, DEFAULT_INK);
}
error_number = save_raster_image_to_file(symbol, image_height, image_width, pixelbuf, rotate_angle, data_type);
@ -630,7 +675,7 @@ static int plot_raster_dotty(struct zint_symbol *symbol, int rotate_angle, int d
return ZINT_ERROR_ENCODING_PROBLEM;
} else {
for (i = 0; i < (scale_width * scale_height); i++) {
*(scaled_pixelbuf + i) = '0';
*(scaled_pixelbuf + i) = DEFAULT_PAPER;
}
}
@ -642,7 +687,7 @@ static int plot_raster_dotty(struct zint_symbol *symbol, int rotate_angle, int d
(int) ((i + xoffset) * scaler) + (scaler / 2.0),
(int) ((r + yoffset) * scaler) + (scaler / 2.0),
(symbol->dot_size / 2.0) * scaler,
'1');
DEFAULT_INK);
}
}
}
@ -796,7 +841,7 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int
return ZINT_ERROR_ENCODING_PROBLEM;
} else {
for (i = 0; i < (image_width * image_height); i++) {
*(pixelbuf + i) = '0';
*(pixelbuf + i) = DEFAULT_PAPER;
}
}
@ -815,6 +860,7 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int
int plot_yposn;
int plot_height;
int this_row = symbol->rows - r - 1; /* invert r otherwise plots upside down */
int module_fill;
row_posn += row_height;
plot_yposn = next_yposn;
if (symbol->row_height[this_row] == 0) {
@ -826,30 +872,27 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int
plot_height = next_yposn - plot_yposn;
i = 0;
if (module_is_set(symbol, this_row, 0)) {
latch = 1;
} else {
latch = 0;
}
do {
module_fill = module_is_set(symbol, this_row, i);
block_width = 0;
do {
block_width++;
} while ((i + block_width < symbol->width) && module_is_set(symbol, this_row, i + block_width) == module_is_set(symbol, this_row, i));
if ((addon_latch == 0) && (r == 0) && (i > main_width)) {
plot_height = (int) (row_height - 5.0);
plot_yposn = (int) (row_posn - 5.0);
addon_text_posn = row_posn + row_height - 8.0;
addon_latch = 1;
}
if (latch == 1) {
if (module_fill) {
/* a bar */
draw_bar(pixelbuf, (i + xoffset) * 2, block_width * 2, plot_yposn * 2, plot_height * 2, image_width, image_height);
latch = 0;
if (symbol->symbology == BARCODE_ULTRA) {
draw_bar(pixelbuf, (i + xoffset) * 2, block_width * 2, plot_yposn * 2, plot_height * 2, image_width, image_height, ultra_colour[module_fill]);
} else {
/* a space */
latch = 1;
draw_bar(pixelbuf, (i + xoffset) * 2, block_width * 2, plot_yposn * 2, plot_height * 2, image_width, image_height, DEFAULT_INK);
}
}
i += block_width;
@ -865,12 +908,12 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int
case 8: /* EAN-8 */
case 11:
case 14:
draw_bar(pixelbuf, (0 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height);
draw_bar(pixelbuf, (2 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height);
draw_bar(pixelbuf, (32 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height);
draw_bar(pixelbuf, (34 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height);
draw_bar(pixelbuf, (64 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height);
draw_bar(pixelbuf, (66 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height);
draw_bar(pixelbuf, (0 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK);
draw_bar(pixelbuf, (2 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK);
draw_bar(pixelbuf, (32 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK);
draw_bar(pixelbuf, (34 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK);
draw_bar(pixelbuf, (64 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK);
draw_bar(pixelbuf, (66 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK);
for (i = 0; i < 4; i++) {
textpart[i] = local_text[i];
}
@ -900,12 +943,12 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int
case 13: /* EAN 13 */
case 16:
case 19:
draw_bar(pixelbuf, (0 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height);
draw_bar(pixelbuf, (2 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height);
draw_bar(pixelbuf, (46 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height);
draw_bar(pixelbuf, (48 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height);
draw_bar(pixelbuf, (92 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height);
draw_bar(pixelbuf, (94 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height);
draw_bar(pixelbuf, (0 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK);
draw_bar(pixelbuf, (2 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK);
draw_bar(pixelbuf, (46 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK);
draw_bar(pixelbuf, (48 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK);
draw_bar(pixelbuf, (92 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK);
draw_bar(pixelbuf, (94 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK);
textpart[0] = local_text[0];
textpart[1] = '\0';
@ -951,7 +994,7 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int
} while ((i + block_width < symbol->width) && module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i));
if (latch == 1) {
/* a bar */
draw_bar(pixelbuf, (i + xoffset - comp_offset) * 2, block_width * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height);
draw_bar(pixelbuf, (i + xoffset - comp_offset) * 2, block_width * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK);
latch = 0;
} else {
/* a space */
@ -959,8 +1002,8 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int
}
i += block_width;
} while (i < 11 + comp_offset);
draw_bar(pixelbuf, (46 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height);
draw_bar(pixelbuf, (48 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height);
draw_bar(pixelbuf, (46 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK);
draw_bar(pixelbuf, (48 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK);
latch = 1;
i = 85 + comp_offset;
do {
@ -970,7 +1013,7 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int
} while ((i + block_width < symbol->width) && module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i));
if (latch == 1) {
/* a bar */
draw_bar(pixelbuf, (i + xoffset - comp_offset) * 2, block_width * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height);
draw_bar(pixelbuf, (i + xoffset - comp_offset) * 2, block_width * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK);
latch = 0;
} else {
/* a space */
@ -1013,11 +1056,11 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int
} else if ((symbol->symbology == BARCODE_UPCE) || (symbol->symbology == BARCODE_UPCE_CHK)
|| (symbol->symbology == BARCODE_UPCE_CC)) {
/* guard bar extensions and text formatting for UPCE */
draw_bar(pixelbuf, (0 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height);
draw_bar(pixelbuf, (2 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height);
draw_bar(pixelbuf, (46 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height);
draw_bar(pixelbuf, (48 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height);
draw_bar(pixelbuf, (50 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height);
draw_bar(pixelbuf, (0 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK);
draw_bar(pixelbuf, (2 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK);
draw_bar(pixelbuf, (46 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK);
draw_bar(pixelbuf, (48 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK);
draw_bar(pixelbuf, (50 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK);
textpart[0] = local_text[0];
textpart[1] = '\0';
@ -1053,23 +1096,23 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int
if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) {
/* boundary bars */
if (symbol->symbology != BARCODE_CODABLOCKF) {
draw_bar(pixelbuf, 0, (symbol->width + xoffset + xoffset) * 2, textoffset * 2, symbol->border_width * 2, image_width, image_height);
draw_bar(pixelbuf, 0, (symbol->width + xoffset + xoffset) * 2, (textoffset + symbol->height + symbol->border_width) * 2, symbol->border_width * 2, image_width, image_height);
draw_bar(pixelbuf, 0, (symbol->width + xoffset + xoffset) * 2, textoffset * 2, symbol->border_width * 2, image_width, image_height, DEFAULT_INK);
draw_bar(pixelbuf, 0, (symbol->width + xoffset + xoffset) * 2, (textoffset + symbol->height + symbol->border_width) * 2, symbol->border_width * 2, image_width, image_height, DEFAULT_INK);
} else {
draw_bar(pixelbuf, xoffset * 2, symbol->width * 2, textoffset * 2, symbol->border_width * 2, image_width, image_height);
draw_bar(pixelbuf, xoffset * 2, symbol->width * 2, (textoffset + symbol->height + symbol->border_width) * 2, symbol->border_width * 2, image_width, image_height);
draw_bar(pixelbuf, xoffset * 2, symbol->width * 2, textoffset * 2, symbol->border_width * 2, image_width, image_height, DEFAULT_INK);
draw_bar(pixelbuf, xoffset * 2, symbol->width * 2, (textoffset + symbol->height + symbol->border_width) * 2, symbol->border_width * 2, image_width, image_height, DEFAULT_INK);
}
if ((symbol->output_options & BARCODE_BIND) != 0) {
if ((symbol->rows > 1) && (is_stackable(symbol->symbology) == 1)) {
/* row binding */
if (symbol->symbology != BARCODE_CODABLOCKF) {
for (r = 1; r < symbol->rows; r++) {
draw_bar(pixelbuf, xoffset * 2, symbol->width * 2, ((r * row_height) + textoffset + yoffset - 1) * 2, 2 * 2, image_width, image_height);
draw_bar(pixelbuf, xoffset * 2, symbol->width * 2, ((r * row_height) + textoffset + yoffset - 1) * 2, 2 * 2, image_width, image_height, DEFAULT_INK);
}
} else {
for (r = 1; r < symbol->rows; r++) {
/* Avoid 11-module start and stop chars */
draw_bar(pixelbuf, (xoffset + 11) * 2 , (symbol->width - 22) * 2, ((r * row_height) + textoffset + yoffset - 1) * 2, 2 * 2, image_width, image_height);
draw_bar(pixelbuf, (xoffset + 11) * 2 , (symbol->width - 22) * 2, ((r * row_height) + textoffset + yoffset - 1) * 2, 2 * 2, image_width, image_height, DEFAULT_INK);
}
}
}
@ -1078,8 +1121,8 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int
if (symbol->output_options & BARCODE_BOX) {
/* side bars */
draw_bar(pixelbuf, 0, symbol->border_width * 2, textoffset * 2, (symbol->height + (2 * symbol->border_width)) * 2, image_width, image_height);
draw_bar(pixelbuf, (symbol->width + xoffset + xoffset - symbol->border_width) * 2, symbol->border_width * 2, textoffset * 2, (symbol->height + (2 * symbol->border_width)) * 2, image_width, image_height);
draw_bar(pixelbuf, 0, symbol->border_width * 2, textoffset * 2, (symbol->height + (2 * symbol->border_width)) * 2, image_width, image_height, DEFAULT_INK);
draw_bar(pixelbuf, (symbol->width + xoffset + xoffset - symbol->border_width) * 2, symbol->border_width * 2, textoffset * 2, (symbol->height + (2 * symbol->border_width)) * 2, image_width, image_height, DEFAULT_INK);
}
/* Put the human readable text at the bottom */
@ -1102,7 +1145,7 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int
return ZINT_ERROR_ENCODING_PROBLEM;
} else {
for (i = 0; i < (scale_width * scale_height); i++) {
*(scaled_pixelbuf + i) = '0';
*(scaled_pixelbuf + i) = DEFAULT_PAPER;
}
}

View File

@ -41,6 +41,35 @@
#include "common.h"
void pick_colour(int colour, char colour_code[]) {
switch(colour) {
case 0: // White
strcpy(colour_code, "ffffff");
break;
case 1: // Cyan
strcpy(colour_code, "00ffff");
break;
case 2: // Blue
strcpy(colour_code, "0000ff");
break;
case 3: // Magenta
strcpy(colour_code, "ff00ff");
break;
case 4: // Red
strcpy(colour_code, "ff0000");
break;
case 5: // Yellow
strcpy(colour_code, "ffff00");
break;
case 6: // Green
strcpy(colour_code, "00ff00");
break;
default: // Black
strcpy(colour_code, "000000");
break;
}
}
static void make_html_friendly(unsigned char * string, char * html_version) {
/* Converts text to use HTML entity codes */
@ -98,6 +127,8 @@ INTERNAL int svg_plot(struct zint_symbol *symbol) {
struct zint_vector_circle *circle;
struct zint_vector_string *string;
char colour_code[7];
#ifdef _MSC_VER
char* html_string;
#endif
@ -153,7 +184,12 @@ INTERNAL int svg_plot(struct zint_symbol *symbol) {
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 {
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);
}
rect = rect->next;
}

View File

@ -146,14 +146,57 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) {
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') {
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);
} else {
break;
default:
putc(bgred, tif_file);
putc(bggrn, tif_file);
putc(bgblu, tif_file);
break;
}
bytes_put += 3;
}

File diff suppressed because it is too large Load Diff

View File

@ -253,8 +253,7 @@ static void vector_reduce_rectangles(struct zint_symbol *symbol) {
target = prev->next;
while (target) {
if ((rect->x == target->x) && (rect->width == target->width) && ((rect->y + rect->height) == target->y)) {
if ((rect->x == target->x) && (rect->width == target->width) && ((rect->y + rect->height) == target->y) && (rect->colour == target->colour)) {
rect->height += target->height;
prev->next = target->next;
free(target);
@ -483,20 +482,18 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
addon_text_posn = row_posn + 8.0f;
addon_latch = 1;
}
if (latch == 1) {
/* a bar */
if (module_is_set(symbol, this_row, i)) {
/* a bar or colour block */
if (addon_latch == 0) {
rectangle = vector_plot_create_rect((float)(i + xoffset), row_posn, (float)block_width, row_height);
if (symbol->symbology == BARCODE_ULTRA) {
rectangle->colour = module_is_set(symbol, this_row, i);
}
} else {
rectangle = vector_plot_create_rect((float)(i + xoffset), row_posn + 10.0f, (float)block_width, row_height - 5.0f);
}
latch = 0;
vector_plot_add_rect(symbol, rectangle, &last_rectangle);
rect_count++;
} else {
/* a space */
latch = 1;
}
i += block_width;

View File

@ -270,6 +270,9 @@ extern "C" {
// QR, Han Xin, Grid Matrix specific options (option_3)
#define ZINT_FULL_MULTIBYTE 200
// Ultracode specific option
#define ULTRA_COMPRESSION 128
// Warning and error conditions
#define ZINT_WARN_INVALID_OPTION 2
#define ZINT_WARN_USES_ECI 3

View File

@ -1,7 +1,7 @@
/***************************************************************************
* Copyright (C) 2008 by BogDan Vatra *
* bogdan@licentia.eu *
* Copyright (C) 2010-2017 Robin Stuart *
* Copyright (C) 2010-2020 Robin Stuart *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@ -316,7 +316,36 @@ namespace Zint {
// Plot rectangles
rect = m_zintSymbol->vector->rectangles;
while (rect) {
if (rect->colour == -1) {
painter.fillRect(rect->x, rect->y, rect->width, rect->height, QBrush(m_fgColor));
} else {
switch(rect->colour) {
case 0: // White
painter.fillRect(rect->x, rect->y, rect->width, rect->height, QBrush(Qt::white));
break;
case 1: // Cyan
painter.fillRect(rect->x, rect->y, rect->width, rect->height, QBrush(Qt::cyan));
break;
case 2: // Blue
painter.fillRect(rect->x, rect->y, rect->width, rect->height, QBrush(Qt::blue));
break;
case 3: // Magenta
painter.fillRect(rect->x, rect->y, rect->width, rect->height, QBrush(Qt::magenta));
break;
case 4: // Red
painter.fillRect(rect->x, rect->y, rect->width, rect->height, QBrush(Qt::red));
break;
case 5: // Yellow
painter.fillRect(rect->x, rect->y, rect->width, rect->height, QBrush(Qt::yellow));
break;
case 6: // Green
painter.fillRect(rect->x, rect->y, rect->width, rect->height, QBrush(Qt::green));
break;
default:
painter.fillRect(rect->x, rect->y, rect->width, rect->height, QBrush(Qt::black));
break;
}
}
rect = rect->next;
}

View File

@ -37,37 +37,38 @@
/* Print list of supported symbologies */
void types(void) {
printf( " 1: Code 11 51: Pharma One-Track 92: Aztec Code\n"
" 2: Standard 2of5 52: PZN 93: DAFT Code\n"
" 3: Interleaved 2of5 53: Pharma Two-Track 97: Micro QR Code\n"
" 4: IATA 2of5 55: PDF417 98: HIBC Code 128\n"
" 6: Data Logic 56: PDF417 Trunc 99: HIBC Code 39\n"
" 7: Industrial 2of5 57: Maxicode 102: HIBC Data Matrix\n"
" 8: Code 39 58: QR Code 104: HIBC QR Code\n"
" 9: Extended Code 39 60: Code 128-B 106: HIBC PDF417\n"
"13: EAN 63: AP Standard Customer 108: HIBC MicroPDF417\n"
"14: EAN + Check 66: AP Reply Paid 110: HIBC Codablock-F\n"
"16: GS1-128 67: AP Routing 112: HIBC Aztec Code\n"
"18: Codabar 68: AP Redirection 115: DotCode\n"
"20: Code 128 69: ISBN 116: Han Xin Code\n"
"21: Leitcode 70: RM4SCC 121: RM Mailmark\n"
"22: Identcode 71: Data Matrix 128: Aztec Runes\n"
"23: Code 16k 72: EAN-14 129: Code 32\n"
"24: Code 49 73: VIN (North America) 130: Comp EAN\n"
"25: Code 93 74: Codablock-F 131: Comp GS1-128\n"
"28: Flattermarken 75: NVE-18 132: Comp DataBar Omni\n"
"29: GS1 DataBar Omni 76: Japanese Post 133: Comp DataBar Ltd\n"
"30: GS1 DataBar Ltd 77: Korea Post 134: Comp DataBar ExpOm\n"
"31: GS1 DataBar ExpOm 79: GS1 DataBar Stack 135: Comp UPC-A\n"
"32: Telepen Alpha 80: GS1 DataBar Stack Omni 136: Comp UPC-E\n"
"34: UPC-A 81: GS1 DataBar ESO 137: Comp DataBar Stack\n"
"35: UPC-A + Check 82: Planet 138: Comp DataBar Stack Omni\n"
"37: UPC-E 84: MicroPDF 139: Comp DataBar ESO\n"
"38: UPC-E + Check 85: USPS OneCode 140: Channel Code\n"
"40: Postnet 86: UK Plessey 141: Code One\n"
"47: MSI Plessey 87: Telepen Numeric 142: Grid Matrix\n"
"49: FIM 89: ITF-14 143: UPNQR\n"
"50: Logmars 90: KIX Code 145: rMQR\n"
printf( " 1: Code 11 52: PZN 97: Micro QR Code\n"
" 2: Standard 2of5 53: Pharma Two-Track 98: HIBC Code 128\n"
" 3: Interleaved 2of5 55: PDF417 99: HIBC Code 39\n"
" 4: IATA 2of5 56: PDF417 Trunc 102: HIBC Data Matrix\n"
" 6: Data Logic 57: Maxicode 104: HIBC QR Code\n"
" 7: Industrial 2of5 58: QR Code 106: HIBC PDF417\n"
" 8: Code 39 60: Code 128-B 108: HIBC MicroPDF417\n"
" 9: Extended Code 39 63: AP Standard Customer 110: HIBC Codablock-F\n"
"13: EAN 66: AP Reply Paid 112: HIBC Aztec Code\n"
"14: EAN + Check 67: AP Routing 115: DotCode\n"
"16: GS1-128 68: AP Redirection 116: Han Xin Code\n"
"18: Codabar 69: ISBN 121: RM Mailmark\n"
"20: Code 128 70: RM4SCC 128: Aztec Runes\n"
"21: Leitcode 71: Data Matrix 129: Code 32\n"
"22: Identcode 72: EAN-14 130: Comp EAN\n"
"23: Code 16k 73: VIN (North America) 131: Comp GS1-128\n"
"24: Code 49 74: Codablock-F 132: Comp DataBar Omni\n"
"25: Code 93 75: NVE-18 133: Comp DataBar Ltd\n"
"28: Flattermarken 76: Japanese Post 134: Comp DataBar ExpOm\n"
"29: GS1 DataBar Omni 77: Korea Post 135: Comp UPC-A\n"
"30: GS1 DataBar Ltd 79: GS1 DataBar Stack 136: Comp UPC-E\n"
"31: GS1 DataBar ExpOm 80: GS1 DataBar Stack Omni 137: Comp DataBar Stack\n"
"32: Telepen Alpha 81: GS1 DataBar ESO 138: Comp DataBar Stack Omni\n"
"34: UPC-A 82: Planet 1139: Comp DataBar ESO\n"
"35: UPC-A + Check 84: MicroPDF 140: Channel Code\n"
"37: UPC-E 85: USPS OneCode 141: Code One\n"
"38: UPC-E + Check 86: UK Plessey 142: Grid Matrix\n"
"40: Postnet 87: Telepen Numeric 143: UPNQR\n"
"47: MSI Plessey 89: ITF-14 144: Ultracode\n"
"49: FIM 90: KIX Code 145: rMQR\n"
"50: Logmars 92: Aztec Code\n"
"51: Pharma One-Track 93: DAFT Code\n"
);
}

View File

@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2008 by BogDan Vatra <bogdan@licentia.eu> *
* Copyright (C) 2009-2019 by Robin Stuart <rstuart114@gmail.com> *
* Copyright (C) 2009-2020 by Robin Stuart <rstuart114@gmail.com> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@ -107,6 +107,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags fl)
"Telepen",
"Telepen Numeric",
"UK Plessey",
"Ultracode",
"UPNQR",
"Universal Product Code (UPC-A)",
"Universal Product Code (UPC-E)",

View File

@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2008 by BogDan Vatra <bogdan@licentia.eu> *
* Copyright (C) 2009-2019 by Robin Stuart <rstuart114@gmail.com> *
* Copyright (C) 2009-2020 by Robin Stuart <rstuart114@gmail.com> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@ -102,6 +102,7 @@ public:
TELEPEN = 32,
TELEPEN_NUM = 87,
PLESSEY = 86,
ULTRA = 144,
UPNQR = 143,
UPCA = 34,
UPCE = 37,