raster/vector: revert to floats for performance, doubles ([2a19b8]) unnecessary

This commit is contained in:
gitlost 2020-08-09 20:20:16 +01:00
parent f4bb0cee0a
commit 121f89581b
4 changed files with 135 additions and 137 deletions

View File

@ -503,9 +503,9 @@ INTERNAL int output_process_upcean(struct zint_symbol *symbol, int *p_main_width
} }
/* Calculate large bar height i.e. linear bars */ /* Calculate large bar height i.e. linear bars */
INTERNAL double output_large_bar_height(struct zint_symbol *symbol) { INTERNAL float output_large_bar_height(struct zint_symbol *symbol) {
int i, large_bar_count, preset_height; int i, large_bar_count, preset_height;
double large_bar_height; float large_bar_height;
large_bar_count = 0; large_bar_count = 0;
preset_height = 0; preset_height = 0;
@ -517,9 +517,9 @@ INTERNAL double output_large_bar_height(struct zint_symbol *symbol) {
} }
if (large_bar_count) { if (large_bar_count) {
large_bar_height = (double) (symbol->height - preset_height) / large_bar_count; large_bar_height = (float) (symbol->height - preset_height) / large_bar_count;
} else { } else {
large_bar_height = 0.0; /* Not used if large_bar_count zero */ large_bar_height = 0.0f; /* Not used if large_bar_count zero */
} }
return large_bar_height; return large_bar_height;

View File

@ -40,7 +40,7 @@ extern "C" {
INTERNAL int output_check_colour_options(struct zint_symbol *symbol); INTERNAL int output_check_colour_options(struct zint_symbol *symbol);
INTERNAL void output_set_whitespace_offsets(struct zint_symbol *symbol, int *xoffset, int *yoffset, int *roffset, int *boffset); INTERNAL void output_set_whitespace_offsets(struct zint_symbol *symbol, int *xoffset, int *yoffset, int *roffset, int *boffset);
INTERNAL int output_process_upcean(struct zint_symbol *symbol, int *p_main_width, int *p_comp_offset, unsigned char addon[6], int *p_addon_gap); INTERNAL int output_process_upcean(struct zint_symbol *symbol, int *p_main_width, int *p_comp_offset, unsigned char addon[6], int *p_addon_gap);
INTERNAL double output_large_bar_height(struct zint_symbol *symbol); INTERNAL float output_large_bar_height(struct zint_symbol *symbol);
INTERNAL void output_upcean_split_text(int upceanflag, unsigned char text[], INTERNAL void output_upcean_split_text(int upceanflag, unsigned char text[],
unsigned char textpart1[], unsigned char textpart2[], unsigned char textpart3[], unsigned char textpart4[]); unsigned char textpart1[], unsigned char textpart2[], unsigned char textpart3[], unsigned char textpart4[]);

View File

@ -287,7 +287,7 @@ static void draw_bar(char *pixelbuf, int xpos, int xlen, int ypos, int ylen, int
} }
} }
static void draw_circle(char *pixelbuf, int image_width, int image_height, int x0, int y0, double radius, char fill) { static void draw_circle(char *pixelbuf, int image_width, int image_height, int x0, int y0, float radius, char fill) {
int x, y; int x, y;
int radius_i = (int) radius; int radius_i = (int) radius;
@ -305,19 +305,19 @@ static void draw_circle(char *pixelbuf, int image_width, int image_height, int x
static void draw_bullseye(char *pixelbuf, int image_width, int image_height, int xoffset, int yoffset, int scaler) { static void draw_bullseye(char *pixelbuf, int image_width, int image_height, int xoffset, int yoffset, int scaler) {
/* Central bullseye in Maxicode symbols */ /* Central bullseye in Maxicode symbols */
double x = 14.5 * scaler; float x = 14.5f * scaler;
double y = 15.0 * scaler; float y = 15.0f * scaler;
if(scaler < 10) { if (scaler < 10) {
x = 16.0 * scaler; x = 16.0f * scaler;
y = 16.5 * scaler; y = 16.5f * scaler;
} }
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, (4.571f * scaler) + 1.0f, 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, (3.779f * scaler) + 1.0f, 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.988f * scaler) + 1.0f, 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, (2.196f * scaler) + 1.0f, 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, (1.394f * scaler) + 1.0f, DEFAULT_INK);
draw_circle(pixelbuf, image_width, image_height, x + xoffset, y + yoffset, (0.602 * scaler) + 1, DEFAULT_PAPER); draw_circle(pixelbuf, image_width, image_height, x + xoffset, y + yoffset, (0.602f * scaler) + 1.0f, DEFAULT_PAPER);
} }
static void draw_hexagon(char *pixelbuf, int image_width, char *scaled_hexagon, int hexagon_size, int xposn, int yposn) { static void draw_hexagon(char *pixelbuf, int image_width, char *scaled_hexagon, int hexagon_size, int xposn, int yposn) {
@ -477,17 +477,17 @@ static void draw_string(char *pixbuf, unsigned char input_string[], int xposn, i
} }
} }
static void plot_hexline(char *scaled_hexagon, int hexagon_size, double start_x, double start_y, double end_x, double end_y) { static void plot_hexline(char *scaled_hexagon, int hexagon_size, float start_x, float start_y, float end_x, float end_y) {
/* Draw a straight line from start to end */ /* Draw a straight line from start to end */
int i; int i;
double inc_x, inc_y; float inc_x, inc_y;
inc_x = (end_x - start_x) / hexagon_size; inc_x = (end_x - start_x) / hexagon_size;
inc_y = (end_y - start_y) / hexagon_size; inc_y = (end_y - start_y) / hexagon_size;
for (i = 0; i < hexagon_size; i++) { for (i = 0; i < hexagon_size; i++) {
double this_x = start_x + (i * inc_x); float this_x = start_x + (i * inc_x);
double this_y = start_y + (i * inc_y); float this_y = start_y + (i * inc_y);
if (((this_x >= 0) && (this_x < hexagon_size)) && ((this_y >= 0) && (this_y < hexagon_size))) { 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] = DEFAULT_INK; scaled_hexagon[(hexagon_size * (int)this_y) + (int)this_x] = DEFAULT_INK;
} }
@ -498,37 +498,37 @@ static void plot_hexagon(char *scaled_hexagon, int hexagon_size) {
/* Create a hexagon shape and fill it */ /* Create a hexagon shape and fill it */
int line, i; int line, i;
double x_offset[6]; float x_offset[6];
double y_offset[6]; float y_offset[6];
double start_x, start_y; float start_x, start_y;
double end_x, end_y; float end_x, end_y;
x_offset[0] = 0.0; x_offset[0] = 0.0f;
x_offset[1] = 0.86; x_offset[1] = 0.86f;
x_offset[2] = 0.86; x_offset[2] = 0.86f;
x_offset[3] = 0.0; x_offset[3] = 0.0f;
x_offset[4] = -0.86; x_offset[4] = -0.86f;
x_offset[5] = -0.86; x_offset[5] = -0.86f;
y_offset[0] = 1.0; y_offset[0] = 1.0f;
y_offset[1] = 0.5; y_offset[1] = 0.5f;
y_offset[2] = -0.5; y_offset[2] = -0.5f;
y_offset[3] = -1.0; y_offset[3] = -1.0f;
y_offset[4] = -0.5; y_offset[4] = -0.5f;
y_offset[5] = 0.5; y_offset[5] = 0.5f;
/* Plot hexagon outline */ /* Plot hexagon outline */
for (line = 0; line < 5; line++) { for (line = 0; line < 5; line++) {
start_x = (hexagon_size / 2.0) + ((hexagon_size / 2.0) * x_offset[line]); start_x = (hexagon_size / 2.0f) + ((hexagon_size / 2.0f) * x_offset[line]);
start_y = (hexagon_size / 2.0) + ((hexagon_size / 2.0) * y_offset[line]); start_y = (hexagon_size / 2.0f) + ((hexagon_size / 2.0f) * y_offset[line]);
end_x = (hexagon_size / 2.0) + ((hexagon_size / 2.0) * x_offset[line + 1]); end_x = (hexagon_size / 2.0f) + ((hexagon_size / 2.0f) * x_offset[line + 1]);
end_y = (hexagon_size / 2.0) + ((hexagon_size / 2.0) * y_offset[line + 1]); end_y = (hexagon_size / 2.0f) + ((hexagon_size / 2.0f) * y_offset[line + 1]);
plot_hexline(scaled_hexagon, hexagon_size, start_x, start_y, end_x, end_y); plot_hexline(scaled_hexagon, hexagon_size, start_x, start_y, end_x, end_y);
} }
start_x = (hexagon_size / 2.0) + ((hexagon_size / 2.0) * x_offset[line]); start_x = (hexagon_size / 2.0f) + ((hexagon_size / 2.0f) * x_offset[line]);
start_y = (hexagon_size / 2.0) + ((hexagon_size / 2.0) * y_offset[line]); start_y = (hexagon_size / 2.0f) + ((hexagon_size / 2.0f) * y_offset[line]);
end_x = (hexagon_size / 2.0) + ((hexagon_size / 2.0) * x_offset[0]); end_x = (hexagon_size / 2.0f) + ((hexagon_size / 2.0f) * x_offset[0]);
end_y = (hexagon_size / 2.0) + ((hexagon_size / 2.0) * y_offset[0]); end_y = (hexagon_size / 2.0f) + ((hexagon_size / 2.0f) * y_offset[0]);
plot_hexline(scaled_hexagon, hexagon_size, start_x, start_y, end_x, end_y); plot_hexline(scaled_hexagon, hexagon_size, start_x, start_y, end_x, end_y);
/* Fill hexagon */ /* Fill hexagon */
@ -558,12 +558,12 @@ static int plot_raster_maxicode(struct zint_symbol *symbol, int rotate_angle, in
int error_number; int error_number;
int xoffset, yoffset; int xoffset, yoffset;
int roffset, boffset; int roffset, boffset;
double scaler = symbol->scale; float scaler = symbol->scale;
char *scaled_hexagon; char *scaled_hexagon;
int hexagon_size; int hexagon_size;
if (scaler <= 0) { if (scaler <= 0.0f) {
scaler = 0.5; scaler = 0.5f;
} }
output_set_whitespace_offsets(symbol, &xoffset, &yoffset, &roffset, &boffset); output_set_whitespace_offsets(symbol, &xoffset, &yoffset, &roffset, &boffset);
@ -605,7 +605,7 @@ static int plot_raster_maxicode(struct zint_symbol *symbol, int rotate_angle, in
} }
} }
draw_bullseye(pixelbuf, image_width, image_height, (2.0 * xoffset), (2.0 * yoffset), scaler * 10); draw_bullseye(pixelbuf, image_width, image_height, (2 * xoffset), (2 * yoffset), scaler * 10);
// Virtual hexagon // Virtual hexagon
//draw_hexagon(pixelbuf, image_width, scaled_hexagon, hexagon_size, ((14 * 10) + (2 * xoffset)) * scaler, ((16 * 9) + (2 * yoffset)) * scaler); //draw_hexagon(pixelbuf, image_width, scaled_hexagon, hexagon_size, ((14 * 10) + (2 * xoffset)) * scaler, ((16 * 9) + (2 * yoffset)) * scaler);
@ -631,8 +631,8 @@ static int plot_raster_maxicode(struct zint_symbol *symbol, int rotate_angle, in
} }
static int plot_raster_dotty(struct zint_symbol *symbol, int rotate_angle, int data_type) { static int plot_raster_dotty(struct zint_symbol *symbol, int rotate_angle, int data_type) {
double scaler = 2 * symbol->scale; float scaler = 2 * symbol->scale;
double half_scaler, dot_size_scaled; float half_scaler, dot_size_scaled;
char *scaled_pixelbuf; char *scaled_pixelbuf;
int r, i; int r, i;
int scale_width, scale_height; int scale_width, scale_height;
@ -647,8 +647,8 @@ static int plot_raster_dotty(struct zint_symbol *symbol, int rotate_angle, int d
image_width = symbol->width + xoffset + roffset; image_width = symbol->width + xoffset + roffset;
image_height = symbol->height + yoffset + boffset; image_height = symbol->height + yoffset + boffset;
if (scaler < 2.0) { if (scaler < 2.0f) {
scaler = 2.0; scaler = 2.0f;
} }
scale_width = (image_width * scaler) + 1; scale_width = (image_width * scaler) + 1;
scale_height = (image_height * scaler) + 1; scale_height = (image_height * scaler) + 1;
@ -661,10 +661,10 @@ static int plot_raster_dotty(struct zint_symbol *symbol, int rotate_angle, int d
memset(scaled_pixelbuf, DEFAULT_PAPER, scale_width * scale_height); memset(scaled_pixelbuf, DEFAULT_PAPER, scale_width * scale_height);
/* Plot the body of the symbol to the pixel buffer */ /* Plot the body of the symbol to the pixel buffer */
half_scaler = scaler / 2.0; half_scaler = scaler / 2.0f;
dot_size_scaled = (symbol->dot_size * scaler) / 2.0; dot_size_scaled = (symbol->dot_size * scaler) / 2.0f;
for (r = 0; r < symbol->rows; r++) { for (r = 0; r < symbol->rows; r++) {
double row_scaled = (r + yoffset) * scaler + half_scaler; float row_scaled = (r + yoffset) * scaler + half_scaler;
for (i = 0; i < symbol->width; i++) { for (i = 0; i < symbol->width; i++) {
if (module_is_set(symbol, r, i)) { if (module_is_set(symbol, r, i)) {
draw_circle(scaled_pixelbuf, scale_width, scale_height, draw_circle(scaled_pixelbuf, scale_width, scale_height,
@ -725,15 +725,15 @@ static void to_iso8859_1(const unsigned char source[], unsigned char preprocesse
static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int data_type) { static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int data_type) {
int error_number; int error_number;
double large_bar_height; float large_bar_height;
int textdone; int textdone;
int main_width, comp_offset, addon_gap; int main_width, comp_offset, addon_gap;
unsigned char addon[6]; unsigned char addon[6];
int xoffset, yoffset, roffset, boffset; int xoffset, yoffset, roffset, boffset;
double addon_text_posn; float addon_text_posn;
int textoffset; int textoffset;
int default_text_posn; int default_text_posn;
double row_height, row_posn; float row_height, row_posn;
int upceanflag = 0; int upceanflag = 0;
int addon_latch = 0; int addon_latch = 0;
unsigned char textpart1[5], textpart2[7], textpart3[7], textpart4[2]; unsigned char textpart1[5], textpart2[7], textpart3[7], textpart4[2];
@ -747,7 +747,7 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int
int next_yposn; int next_yposn;
int latch; int latch;
int block_width; int block_width;
double scaler = symbol->scale; float scaler = symbol->scale;
int scale_width, scale_height; int scale_width, scale_height;
char *scaled_pixelbuf; char *scaled_pixelbuf;
int horiz, vert; int horiz, vert;
@ -764,7 +764,7 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int
output_set_whitespace_offsets(symbol, &xoffset, &yoffset, &roffset, &boffset); output_set_whitespace_offsets(symbol, &xoffset, &yoffset, &roffset, &boffset);
addon_text_posn = 0.0; addon_text_posn = 0.0f;
hide_text = ((!symbol->show_hrt) || (ustrlen(symbol->text) == 0)); hide_text = ((!symbol->show_hrt) || (ustrlen(symbol->text) == 0));
if (symbol->output_options & SMALL_TEXT) { if (symbol->output_options & SMALL_TEXT) {
@ -790,7 +790,7 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int
default_text_posn = image_height - 17; default_text_posn = image_height - 17;
row_height = 0.0; row_height = 0.0f;
row_posn = textoffset + yoffset; row_posn = textoffset + yoffset;
next_yposn = textoffset + yoffset; next_yposn = textoffset + yoffset;
@ -821,11 +821,11 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int
if ((addon_latch == 0) && (r == 0) && (i > main_width)) { if ((addon_latch == 0) && (r == 0) && (i > main_width)) {
if (upceanflag == 12 || upceanflag == 6) { /* UPC-A/E add-ons don't descend */ if (upceanflag == 12 || upceanflag == 6) { /* UPC-A/E add-ons don't descend */
plot_height = row_height > 8.0 ? row_height - 8.0 : 1; plot_height = row_height > 8.0f ? row_height - 8.0f : 1;
plot_yposn = row_posn; plot_yposn = row_posn;
} else { } else {
plot_height = row_height > 3.0 ? row_height - 3.0 : 1; plot_height = row_height > 3.0f ? row_height - 3.0f : 1;
plot_yposn = row_posn - 5; plot_yposn = row_posn - 5.0f;
} }
addon_latch = 1; addon_latch = 1;
} }
@ -1008,7 +1008,7 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int
// Binding and boxes // Binding and boxes
if ((symbol->output_options & BARCODE_BIND) != 0) { if ((symbol->output_options & BARCODE_BIND) != 0) {
if ((symbol->rows > 1) && (is_stackable(symbol->symbology) == 1)) { if ((symbol->rows > 1) && (is_stackable(symbol->symbology) == 1)) {
double sep_height = 1; float sep_height = 1.0f;
if (symbol->option_3 > 0 && symbol->option_3 <= 4) { if (symbol->option_3 > 0 && symbol->option_3 <= 4) {
sep_height = symbol->option_3; sep_height = symbol->option_3;
} }
@ -1043,11 +1043,11 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int
} }
} }
if (scaler <= 0) { if (scaler <= 0.0f) {
scaler = 0.5; scaler = 0.5f;
} }
if (scaler != 1.0) { if (scaler != 1.0f) {
scale_width = image_width * scaler; scale_width = image_width * scaler;
scale_height = image_height * scaler; scale_height = image_height * scaler;

View File

@ -44,7 +44,7 @@ INTERNAL int ps_plot(struct zint_symbol *symbol);
INTERNAL int svg_plot(struct zint_symbol *symbol); INTERNAL int svg_plot(struct zint_symbol *symbol);
INTERNAL int emf_plot(struct zint_symbol *symbol); INTERNAL int emf_plot(struct zint_symbol *symbol);
static struct zint_vector_rect *vector_plot_create_rect(double x, double y, double width, double height) { static struct zint_vector_rect *vector_plot_create_rect(float x, float y, float width, float height) {
struct zint_vector_rect *rect; struct zint_vector_rect *rect;
rect = (struct zint_vector_rect*) malloc(sizeof (struct zint_vector_rect)); rect = (struct zint_vector_rect*) malloc(sizeof (struct zint_vector_rect));
@ -71,7 +71,7 @@ static int vector_plot_add_rect(struct zint_symbol *symbol, struct zint_vector_r
return 1; return 1;
} }
static struct zint_vector_hexagon *vector_plot_create_hexagon(double x, double y, double diameter) { static struct zint_vector_hexagon *vector_plot_create_hexagon(float x, float y, float diameter) {
struct zint_vector_hexagon *hexagon; struct zint_vector_hexagon *hexagon;
hexagon = (struct zint_vector_hexagon*) malloc(sizeof (struct zint_vector_hexagon)); hexagon = (struct zint_vector_hexagon*) malloc(sizeof (struct zint_vector_hexagon));
@ -79,7 +79,7 @@ static struct zint_vector_hexagon *vector_plot_create_hexagon(double x, double y
hexagon->next = NULL; hexagon->next = NULL;
hexagon->x = x; hexagon->x = x;
hexagon->y = y; hexagon->y = y;
hexagon->diameter = (diameter * 5.0) / 4.0; // Ugly kludge for legacy support hexagon->diameter = (diameter * 5.0f) / 4.0f; // Ugly kludge for legacy support
hexagon->rotation = 0; hexagon->rotation = 0;
return hexagon; return hexagon;
@ -96,7 +96,7 @@ static int vector_plot_add_hexagon(struct zint_symbol *symbol, struct zint_vecto
return 1; return 1;
} }
static struct zint_vector_circle *vector_plot_create_circle(double x, double y, double diameter, int colour) { static struct zint_vector_circle *vector_plot_create_circle(float x, float y, float diameter, int colour) {
struct zint_vector_circle *circle; struct zint_vector_circle *circle;
circle = (struct zint_vector_circle *) malloc(sizeof (struct zint_vector_circle)); circle = (struct zint_vector_circle *) malloc(sizeof (struct zint_vector_circle));
@ -122,7 +122,7 @@ static int vector_plot_add_circle(struct zint_symbol *symbol, struct zint_vector
} }
static int vector_plot_add_string(struct zint_symbol *symbol, static int vector_plot_add_string(struct zint_symbol *symbol,
unsigned char *text, double x, double y, double fsize, double width, unsigned char *text, float x, float y, float fsize, float width,
struct zint_vector_string **last_string) { struct zint_vector_string **last_string) {
struct zint_vector_string *string; struct zint_vector_string *string;
@ -197,7 +197,7 @@ static void vector_scale(struct zint_symbol *symbol, int file_type) {
struct zint_vector_hexagon *hex; struct zint_vector_hexagon *hex;
struct zint_vector_circle *circle; struct zint_vector_circle *circle;
struct zint_vector_string *string; struct zint_vector_string *string;
double scale = symbol->scale * 2.0; float scale = symbol->scale * 2.0f;
if ((file_type == OUT_EMF_FILE) && (symbol->symbology == BARCODE_MAXICODE)) { if ((file_type == OUT_EMF_FILE) && (symbol->symbology == BARCODE_MAXICODE)) {
// Increase size to overcome limitations in EMF file format // Increase size to overcome limitations in EMF file format
@ -381,15 +381,15 @@ static void vector_reduce_rectangles(struct zint_symbol *symbol) {
INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_type) { INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_type) {
int error_number; int error_number;
double large_bar_height; float large_bar_height;
int textdone; int textdone;
int main_width, comp_offset, addon_gap; int main_width, comp_offset, addon_gap;
unsigned char addon[6]; unsigned char addon[6];
int xoffset, yoffset, roffset, boffset; int xoffset, yoffset, roffset, boffset;
double addon_text_posn; float addon_text_posn;
int textoffset; int textoffset;
int default_text_posn; int default_text_posn;
double row_height, row_posn; float row_height, row_posn;
int upceanflag = 0; int upceanflag = 0;
int addon_latch = 0; int addon_latch = 0;
unsigned char textpart1[5], textpart2[7], textpart3[7], textpart4[2]; unsigned char textpart1[5], textpart2[7], textpart3[7], textpart4[2];
@ -397,7 +397,7 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
int hide_text = 0; int hide_text = 0;
int i, r; int i, r;
double text_height; float text_height;
int rect_count, last_row_start; int rect_count, last_row_start;
int this_row; int this_row;
@ -407,8 +407,6 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
struct zint_vector_string *last_string = NULL; struct zint_vector_string *last_string = NULL;
struct zint_vector_circle *last_circle = NULL; struct zint_vector_circle *last_circle = NULL;
(void)rotate_angle; /* Not currently implemented */
// Free any previous rendering structures // Free any previous rendering structures
vector_free(symbol); vector_free(symbol);
@ -438,18 +436,18 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
output_set_whitespace_offsets(symbol, &xoffset, &yoffset, &roffset, &boffset); output_set_whitespace_offsets(symbol, &xoffset, &yoffset, &roffset, &boffset);
addon_text_posn = 0.0; addon_text_posn = 0.0f;
hide_text = ((!symbol->show_hrt) || (ustrlen(symbol->text) == 0)); hide_text = ((!symbol->show_hrt) || (ustrlen(symbol->text) == 0));
if (hide_text) { if (hide_text) {
text_height = 0.0; text_height = 0.0f;
textoffset = upceanflag ? 9.0 : 0.0; textoffset = upceanflag ? 9.0f : 0.0f;
} else { } else {
text_height = upceanflag ? 11.0 : 9.0; text_height = upceanflag ? 11.0f : 9.0f;
textoffset = 9.0; textoffset = 9.0f;
} }
if (symbol->output_options & SMALL_TEXT) if (symbol->output_options & SMALL_TEXT)
text_height *= 0.8; text_height *= 0.8f;
vector->width = ceil(symbol->width + (xoffset + roffset)); vector->width = ceil(symbol->width + (xoffset + roffset));
vector->height = ceil(symbol->height + textoffset + (yoffset + boffset)); vector->height = ceil(symbol->height + textoffset + (yoffset + boffset));
@ -460,7 +458,7 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
default_text_posn = symbol->height + textoffset; default_text_posn = symbol->height + textoffset;
} }
row_height = 0.0; row_height = 0.0f;
rect_count = 0; rect_count = 0;
last_row_start = 0; last_row_start = 0;
@ -474,7 +472,7 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
} else { } else {
row_height = symbol->row_height[this_row]; row_height = symbol->row_height[this_row];
} }
row_posn = 0; row_posn = 0.0f;
for (i = 0; i < r; i++) { for (i = 0; i < r; i++) {
if (symbol->row_height[i] == 0) { if (symbol->row_height[i] == 0) {
row_posn += large_bar_height; row_posn += large_bar_height;
@ -492,7 +490,7 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
block_width++; block_width++;
} while (i + block_width < symbol->width && module_is_set(symbol, this_row, i + block_width) == module_is_set(symbol, this_row, i)); } 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 == (symbol->rows - 1)) && (i > main_width)) { if ((addon_latch == 0) && (r == (symbol->rows - 1)) && (i > main_width)) {
addon_text_posn = row_posn + 8.0; addon_text_posn = row_posn + 8.0f;
addon_latch = 1; addon_latch = 1;
} }
if (module_is_set(symbol, this_row, i)) { if (module_is_set(symbol, this_row, i)) {
@ -504,9 +502,9 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
} }
} else { } else {
if (upceanflag == 12 || upceanflag == 6) { /* UPC-A/E don't descend */ if (upceanflag == 12 || upceanflag == 6) { /* UPC-A/E don't descend */
rectangle = vector_plot_create_rect(i + xoffset, row_posn + 10.0, block_width, row_height > 10.0 ? row_height - 10.0 : 1.0); rectangle = vector_plot_create_rect(i + xoffset, row_posn + 10.0f, block_width, row_height > 10.0f ? row_height - 10.0f : 1.0f);
} else { } else {
rectangle = vector_plot_create_rect(i + xoffset, row_posn + 10.0, block_width, row_height > 5.0 ? row_height - 5.0 : 1.0); rectangle = vector_plot_create_rect(i + xoffset, row_posn + 10.0f, block_width, row_height > 5.0f ? row_height - 5.0f : 1.0f);
} }
} }
vector_plot_add_rect(symbol, rectangle, &last_rectangle); vector_plot_add_rect(symbol, rectangle, &last_rectangle);
@ -521,21 +519,21 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
// Plot Maxicode symbols // Plot Maxicode symbols
if (symbol->symbology == BARCODE_MAXICODE) { if (symbol->symbology == BARCODE_MAXICODE) {
struct zint_vector_circle *circle; struct zint_vector_circle *circle;
vector->width = 37.0 + (xoffset + roffset); vector->width = 37.0f + (xoffset + roffset);
vector->height = 36.0 + (yoffset + boffset); vector->height = 36.0f + (yoffset + boffset);
// Bullseye // Bullseye
circle = vector_plot_create_circle(17.88 + xoffset, 17.8 + yoffset, 10.85, 0); circle = vector_plot_create_circle(17.88f + xoffset, 17.8f + yoffset, 10.85f, 0);
vector_plot_add_circle(symbol, circle, &last_circle); vector_plot_add_circle(symbol, circle, &last_circle);
circle = vector_plot_create_circle(17.88 + xoffset, 17.8 + yoffset, 8.97, 1); circle = vector_plot_create_circle(17.88f + xoffset, 17.8f + yoffset, 8.97f, 1);
vector_plot_add_circle(symbol, circle, &last_circle); vector_plot_add_circle(symbol, circle, &last_circle);
circle = vector_plot_create_circle(17.88 + xoffset, 17.8 + yoffset, 7.10, 0); circle = vector_plot_create_circle(17.88f + xoffset, 17.8f + yoffset, 7.10f, 0);
vector_plot_add_circle(symbol, circle, &last_circle); vector_plot_add_circle(symbol, circle, &last_circle);
circle = vector_plot_create_circle(17.88 + xoffset, 17.8 + yoffset, 5.22, 1); circle = vector_plot_create_circle(17.88f + xoffset, 17.8f + yoffset, 5.22f, 1);
vector_plot_add_circle(symbol, circle, &last_circle); vector_plot_add_circle(symbol, circle, &last_circle);
circle = vector_plot_create_circle(17.88 + xoffset, 17.8 + yoffset, 3.31, 0); circle = vector_plot_create_circle(17.88f + xoffset, 17.8f + yoffset, 3.31f, 0);
vector_plot_add_circle(symbol, circle, &last_circle); vector_plot_add_circle(symbol, circle, &last_circle);
circle = vector_plot_create_circle(17.88 + xoffset, 17.8 + yoffset, 1.43, 1); circle = vector_plot_create_circle(17.88f + xoffset, 17.8f + yoffset, 1.43f, 1);
vector_plot_add_circle(symbol, circle, &last_circle); vector_plot_add_circle(symbol, circle, &last_circle);
/* Hexagons */ /* Hexagons */
@ -543,8 +541,8 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
for (i = 0; i < symbol->width; i++) { for (i = 0; i < symbol->width; i++) {
if (module_is_set(symbol, r, i)) { if (module_is_set(symbol, r, i)) {
//struct zint_vector_hexagon *hexagon = vector_plot_create_hexagon(((i * 0.88) + ((r & 1) ? 1.76 : 1.32)), ((r * 0.76) + 0.76), symbol->dot_size); //struct zint_vector_hexagon *hexagon = vector_plot_create_hexagon(((i * 0.88) + ((r & 1) ? 1.76 : 1.32)), ((r * 0.76) + 0.76), symbol->dot_size);
struct zint_vector_hexagon *hexagon = vector_plot_create_hexagon(((i * 1.23) + 0.615 + ((r & 1) ? 0.615 : 0.0)) + xoffset, struct zint_vector_hexagon *hexagon = vector_plot_create_hexagon(((i * 1.23f) + 0.615f + ((r & 1) ? 0.615f : 0.0f)) + xoffset,
((r * 1.067) + 0.715) + yoffset, symbol->dot_size); ((r * 1.067f) + 0.715f) + yoffset, symbol->dot_size);
vector_plot_add_hexagon(symbol, hexagon, &last_hexagon); vector_plot_add_hexagon(symbol, hexagon, &last_hexagon);
} }
} }
@ -556,7 +554,7 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
for (r = 0; r < symbol->rows; r++) { for (r = 0; r < symbol->rows; r++) {
for (i = 0; i < symbol->width; i++) { for (i = 0; i < symbol->width; i++) {
if (module_is_set(symbol, r, i)) { if (module_is_set(symbol, r, i)) {
struct zint_vector_circle *circle = vector_plot_create_circle(i + 0.5 + xoffset, r + 0.5 + yoffset, 1.0, 0); struct zint_vector_circle *circle = vector_plot_create_circle(i + 0.5f + xoffset, r + 0.5f + yoffset, 1.0f, 0);
vector_plot_add_circle(symbol, circle, &last_circle); vector_plot_add_circle(symbol, circle, &last_circle);
} }
} }
@ -574,7 +572,7 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
case 14: case 14:
case 15: case 15:
case 16: case 16:
rect->height += 5.0; rect->height += 5.0f;
break; break;
} }
i++; i++;
@ -589,7 +587,7 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
case 11: case 11:
case 20: case 20:
case 21: case 21:
rect->height += 5.0; rect->height += 5.0f;
break; break;
} }
i++; i++;
@ -608,7 +606,7 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
case 27: case 27:
case 28: case 28:
case 29: case 29:
rect->height += 5.0; rect->height += 5.0f;
break; break;
} }
i++; i++;
@ -623,7 +621,7 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
case 15: case 15:
case 28: case 28:
case 29: case 29:
rect->height += 5.0; rect->height += 5.0f;
break; break;
} }
i++; i++;
@ -638,36 +636,36 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
xoffset += comp_offset; xoffset += comp_offset;
if (upceanflag) { if (upceanflag) {
double textwidth; float textwidth;
output_upcean_split_text(upceanflag, symbol->text, textpart1, textpart2, textpart3, textpart4); output_upcean_split_text(upceanflag, symbol->text, textpart1, textpart2, textpart3, textpart4);
if (upceanflag == 6) { /* UPC-E */ if (upceanflag == 6) { /* UPC-E */
textpos = -5 + xoffset; textpos = -5 + xoffset;
textwidth = 6.2; textwidth = 6.2f;
vector_plot_add_string(symbol, textpart1, textpos, default_text_posn - 2.0, text_height * (8.0 / 11.0), textwidth, &last_string); vector_plot_add_string(symbol, textpart1, textpos, default_text_posn - 2.0f, text_height * (8.0f / 11.0f), textwidth, &last_string);
textpos = 24 + xoffset; textpos = 24 + xoffset;
textwidth = 6.0 * 8.5; textwidth = 6.0f * 8.5f;
vector_plot_add_string(symbol, textpart2, textpos, default_text_posn, text_height, textwidth, &last_string); vector_plot_add_string(symbol, textpart2, textpos, default_text_posn, text_height, textwidth, &last_string);
textpos = 55 + xoffset; textpos = 55 + xoffset;
textwidth = 6.2; textwidth = 6.2f;
vector_plot_add_string(symbol, textpart3, textpos, default_text_posn - 2.0, text_height * (8.0 / 11.0), textwidth, &last_string); vector_plot_add_string(symbol, textpart3, textpos, default_text_posn - 2.0f, text_height * (8.0f / 11.0f), textwidth, &last_string);
textdone = 1; textdone = 1;
switch (ustrlen(addon)) { switch (ustrlen(addon)) {
case 2: case 2:
textpos = 61 + xoffset + addon_gap; textpos = 61 + xoffset + addon_gap;
textwidth = 2.0 * 8.5; textwidth = 2.0f * 8.5f;
vector_plot_add_string(symbol, addon, textpos, addon_text_posn, text_height, textwidth, &last_string); vector_plot_add_string(symbol, addon, textpos, addon_text_posn, text_height, textwidth, &last_string);
break; break;
case 5: case 5:
textpos = 75 + xoffset + addon_gap; textpos = 75 + xoffset + addon_gap;
textwidth = 5.0 * 8.5; textwidth = 5.0f * 8.5f;
vector_plot_add_string(symbol, addon, textpos, addon_text_posn, text_height, textwidth, &last_string); vector_plot_add_string(symbol, addon, textpos, addon_text_posn, text_height, textwidth, &last_string);
break; break;
} }
} else if (upceanflag == 8) { /* EAN-8 */ } else if (upceanflag == 8) { /* EAN-8 */
textpos = 17 + xoffset; textpos = 17 + xoffset;
textwidth = 4.0 * 8.5; textwidth = 4.0f * 8.5f;
vector_plot_add_string(symbol, textpart1, textpos, default_text_posn, text_height, textwidth, &last_string); vector_plot_add_string(symbol, textpart1, textpos, default_text_posn, text_height, textwidth, &last_string);
textpos = 50 + xoffset; textpos = 50 + xoffset;
vector_plot_add_string(symbol, textpart2, textpos, default_text_posn, text_height, textwidth, &last_string); vector_plot_add_string(symbol, textpart2, textpos, default_text_posn, text_height, textwidth, &last_string);
@ -675,48 +673,48 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
switch (ustrlen(addon)) { switch (ustrlen(addon)) {
case 2: case 2:
textpos = 77 + xoffset + addon_gap; textpos = 77 + xoffset + addon_gap;
textwidth = 2.0 * 8.5; textwidth = 2.0f * 8.5f;
vector_plot_add_string(symbol, addon, textpos, addon_text_posn, text_height, textwidth, &last_string); vector_plot_add_string(symbol, addon, textpos, addon_text_posn, text_height, textwidth, &last_string);
break; break;
case 5: case 5:
textpos = 91 + xoffset + addon_gap; textpos = 91 + xoffset + addon_gap;
textwidth = 5.0 * 8.5; textwidth = 5.0f * 8.5f;
vector_plot_add_string(symbol, addon, textpos, addon_text_posn, text_height, textwidth, &last_string); vector_plot_add_string(symbol, addon, textpos, addon_text_posn, text_height, textwidth, &last_string);
break; break;
} }
} else if (upceanflag == 12) { /* UPC-A */ } else if (upceanflag == 12) { /* UPC-A */
textpos = -5 + xoffset; textpos = -5 + xoffset;
textwidth = 6.2; textwidth = 6.2f;
vector_plot_add_string(symbol, textpart1, textpos, default_text_posn - 2.0, text_height * (8.0 / 11.0), textwidth, &last_string); vector_plot_add_string(symbol, textpart1, textpos, default_text_posn - 2.0f, text_height * (8.0f / 11.0f), textwidth, &last_string);
textpos = 27 + xoffset; textpos = 27 + xoffset;
textwidth = 5.0 * 8.5; textwidth = 5.0f * 8.5f;
vector_plot_add_string(symbol, textpart2, textpos, default_text_posn, text_height, textwidth, &last_string); vector_plot_add_string(symbol, textpart2, textpos, default_text_posn, text_height, textwidth, &last_string);
textpos = 68 + xoffset; textpos = 68 + xoffset;
vector_plot_add_string(symbol, textpart3, textpos, default_text_posn, text_height, textwidth, &last_string); vector_plot_add_string(symbol, textpart3, textpos, default_text_posn, text_height, textwidth, &last_string);
textpos = 100 + xoffset; textpos = 100 + xoffset;
textwidth = 6.2; textwidth = 6.2f;
vector_plot_add_string(symbol, textpart4, textpos, default_text_posn - 2.0, text_height * (8.0 / 11.0), textwidth, &last_string); vector_plot_add_string(symbol, textpart4, textpos, default_text_posn - 2.0f, text_height * (8.0f / 11.0f), textwidth, &last_string);
textdone = 1; textdone = 1;
switch (ustrlen(addon)) { switch (ustrlen(addon)) {
case 2: case 2:
textpos = 107 + xoffset + addon_gap; textpos = 107 + xoffset + addon_gap;
textwidth = 2.0 * 8.5; textwidth = 2.0f * 8.5f;
vector_plot_add_string(symbol, addon, textpos, addon_text_posn, text_height, textwidth, &last_string); vector_plot_add_string(symbol, addon, textpos, addon_text_posn, text_height, textwidth, &last_string);
break; break;
case 5: case 5:
textpos = 121 + xoffset + addon_gap; textpos = 121 + xoffset + addon_gap;
textwidth = 5.0 * 8.5; textwidth = 5.0f * 8.5f;
vector_plot_add_string(symbol, addon, textpos, addon_text_posn, text_height, textwidth, &last_string); vector_plot_add_string(symbol, addon, textpos, addon_text_posn, text_height, textwidth, &last_string);
break; break;
} }
} else if (upceanflag == 13) { /* EAN-13 */ } else if (upceanflag == 13) { /* EAN-13 */
textpos = -7 + xoffset; textpos = -7 + xoffset;
textwidth = 8.5; textwidth = 8.5f;
vector_plot_add_string(symbol, textpart1, textpos, default_text_posn, text_height, textwidth, &last_string); vector_plot_add_string(symbol, textpart1, textpos, default_text_posn, text_height, textwidth, &last_string);
textpos = 24 + xoffset; textpos = 24 + xoffset;
textwidth = 6.0 * 8.5; textwidth = 6.0f * 8.5f;
vector_plot_add_string(symbol, textpart2, textpos, default_text_posn, text_height, textwidth, &last_string); vector_plot_add_string(symbol, textpart2, textpos, default_text_posn, text_height, textwidth, &last_string);
textpos = 71 + xoffset; textpos = 71 + xoffset;
vector_plot_add_string(symbol, textpart3, textpos, default_text_posn, text_height, textwidth, &last_string); vector_plot_add_string(symbol, textpart3, textpos, default_text_posn, text_height, textwidth, &last_string);
@ -724,12 +722,12 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
switch (ustrlen(addon)) { switch (ustrlen(addon)) {
case 2: case 2:
textpos = 105 + xoffset + addon_gap; textpos = 105 + xoffset + addon_gap;
textwidth = 2.0 * 8.5; textwidth = 2.0f * 8.5f;
vector_plot_add_string(symbol, addon, textpos, addon_text_posn, text_height, textwidth, &last_string); vector_plot_add_string(symbol, addon, textpos, addon_text_posn, text_height, textwidth, &last_string);
break; break;
case 5: case 5:
textpos = 119 + xoffset + addon_gap; textpos = 119 + xoffset + addon_gap;
textwidth = 5.0 * 8.5; textwidth = 5.0f * 8.5f;
vector_plot_add_string(symbol, addon, textpos, addon_text_posn, text_height, textwidth, &last_string); vector_plot_add_string(symbol, addon, textpos, addon_text_posn, text_height, textwidth, &last_string);
break; break;
} }
@ -739,7 +737,7 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
if (!textdone) { if (!textdone) {
/* Put normal human readable text at the bottom (and centered) */ /* Put normal human readable text at the bottom (and centered) */
// calculate start xoffset to center text // calculate start xoffset to center text
vector_plot_add_string(symbol, symbol->text, main_width / 2.0 + xoffset, default_text_posn, text_height, symbol->width, &last_string); vector_plot_add_string(symbol, symbol->text, main_width / 2.0f + xoffset, default_text_posn, text_height, symbol->width, &last_string);
} }
xoffset -= comp_offset; // Restore xoffset xoffset -= comp_offset; // Restore xoffset
@ -748,7 +746,7 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
// Binding and boxes // Binding and boxes
if ((symbol->output_options & BARCODE_BIND) != 0) { if ((symbol->output_options & BARCODE_BIND) != 0) {
if ((symbol->rows > 1) && (is_stackable(symbol->symbology) == 1)) { if ((symbol->rows > 1) && (is_stackable(symbol->symbology) == 1)) {
double sep_height = 1; float sep_height = 1.0f;
if (symbol->option_3 > 0 && symbol->option_3 <= 4) { if (symbol->option_3 > 0 && symbol->option_3 <= 4) {
sep_height = symbol->option_3; sep_height = symbol->option_3;
} }
@ -770,26 +768,26 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
if (symbol->border_width > 0) { if (symbol->border_width > 0) {
if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) { if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) {
// Top // Top
rectangle = vector_plot_create_rect(0.0, 0.0, vector->width, symbol->border_width); rectangle = vector_plot_create_rect(0.0f, 0.0f, vector->width, symbol->border_width);
if (!(symbol->output_options & BARCODE_BOX) && (symbol->symbology == BARCODE_CODABLOCKF || symbol->symbology == BARCODE_HIBC_BLOCKF)) { if (!(symbol->output_options & BARCODE_BOX) && (symbol->symbology == BARCODE_CODABLOCKF || symbol->symbology == BARCODE_HIBC_BLOCKF)) {
rectangle->x = xoffset; rectangle->x = xoffset;
rectangle->width -= (2.0 * xoffset); rectangle->width -= (2.0f * xoffset);
} }
vector_plot_add_rect(symbol, rectangle, &last_rectangle); vector_plot_add_rect(symbol, rectangle, &last_rectangle);
// Bottom // Bottom
rectangle = vector_plot_create_rect(0.0, vector->height - symbol->border_width - textoffset, vector->width, symbol->border_width); rectangle = vector_plot_create_rect(0.0f, vector->height - symbol->border_width - textoffset, vector->width, symbol->border_width);
if (!(symbol->output_options & BARCODE_BOX) && (symbol->symbology == BARCODE_CODABLOCKF || symbol->symbology == BARCODE_HIBC_BLOCKF)) { if (!(symbol->output_options & BARCODE_BOX) && (symbol->symbology == BARCODE_CODABLOCKF || symbol->symbology == BARCODE_HIBC_BLOCKF)) {
rectangle->x = xoffset; rectangle->x = xoffset;
rectangle->width -= (2.0 * xoffset); rectangle->width -= (2.0f * xoffset);
} }
vector_plot_add_rect(symbol, rectangle, &last_rectangle); vector_plot_add_rect(symbol, rectangle, &last_rectangle);
} }
if (symbol->output_options & BARCODE_BOX) { if (symbol->output_options & BARCODE_BOX) {
// Left // Left
rectangle = vector_plot_create_rect(0.0, 0.0, symbol->border_width, vector->height - textoffset); rectangle = vector_plot_create_rect(0.0f, 0.0f, symbol->border_width, vector->height - textoffset);
vector_plot_add_rect(symbol, rectangle, &last_rectangle); vector_plot_add_rect(symbol, rectangle, &last_rectangle);
// Right // Right
rectangle = vector_plot_create_rect(vector->width - symbol->border_width, 0.0, symbol->border_width, vector->height - textoffset); rectangle = vector_plot_create_rect(vector->width - symbol->border_width, 0.0f, symbol->border_width, vector->height - textoffset);
vector_plot_add_rect(symbol, rectangle, &last_rectangle); vector_plot_add_rect(symbol, rectangle, &last_rectangle);
} }
} }