From b86a7e6560052364e3f01246fd107641c734e060 Mon Sep 17 00:00:00 2001 From: Harald Oehlmann Date: Mon, 2 Sep 2019 11:26:30 +0200 Subject: [PATCH] 2019-09-01 Codemonkey82 Draw Maxicode bullseye for scale = 0.5 Ticket #119 --- backend/raster.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/backend/raster.c b/backend/raster.c index 4a5d1fc0..a5a41387 100644 --- a/backend/raster.c +++ b/backend/raster.c @@ -238,15 +238,21 @@ void draw_circle(char *pixelbuf, int image_width, int image_height, int x0, int } } -void draw_bullseye(char *pixelbuf, int image_width, int image_height, int cx, int cy, int scaler) { - /* Central bullseye in Maxicode symbols */ - - draw_circle(pixelbuf, image_width, image_height, cx, cy, (int)(4.571 * scaler) + 1, '1'); - draw_circle(pixelbuf, image_width, image_height, cx, cy, (int)(3.779 * scaler) + 1, '0'); - draw_circle(pixelbuf, image_width, image_height, cx, cy, (int)(2.988 * scaler) + 1, '1'); - draw_circle(pixelbuf, image_width, image_height, cx, cy, (int)(2.196 * scaler) + 1, '0'); - draw_circle(pixelbuf, image_width, image_height, cx, cy, (int)(1.394 * scaler) + 1, '1'); - draw_circle(pixelbuf, image_width, image_height, cx, cy, (int)(0.602 * scaler) + 1, '0'); +void draw_bullseye(char pixelbuf, int image_width, int image_height, int xoffset, int yoffset, int scaler) { + / Central bullseye in Maxicode symbols */ + float x = 14.5 * scaler; + float y = 15.0 * scaler; + if(scaler < 10) { + x = 16.0 * scaler; + 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'); } void draw_hexagon(char *pixelbuf, int image_width, char *scaled_hexagon, int hexagon_size, int xposn, int yposn) { @@ -535,7 +541,7 @@ int plot_raster_maxicode(struct zint_symbol *symbol, int rotate_angle, int data_ } } - draw_bullseye(pixelbuf, image_width, image_height, (int)(((14.5 * 10.0) + (2.0 * xoffset)) * scaler), (int)(((16.5 * 9.0) + (2.0 * yoffset)) * scaler), scaler * 10); + draw_bullseye(pixelbuf, image_width, image_height, (2.0 * xoffset), (2.0 * yoffset)) * scaler), scaler * 10); // Virtual hexagon //draw_hexagon(pixelbuf, image_width, scaled_hexagon, hexagon_size, ((14 * 10) + (2 * xoffset)) * scaler, ((16 * 9) + (2 * yoffset)) * scaler);