mirror of
https://git.code.sf.net/p/zint/code
synced 2026-05-11 08:33:48 +00:00
Allow adjustment of dot size when in dotty mode
This commit is contained in:
@@ -74,6 +74,7 @@ struct zint_symbol *ZBarcode_Create() {
|
||||
symbol->bitmap_width = 0;
|
||||
symbol->bitmap_height = 0;
|
||||
symbol->eci = 3;
|
||||
symbol->dot_size = 4.0 / 5.0;
|
||||
return symbol;
|
||||
}
|
||||
|
||||
@@ -1016,6 +1017,11 @@ int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *source, int lengt
|
||||
memcpy(local_source, source, length);
|
||||
local_source[length] = '\0';
|
||||
}
|
||||
|
||||
if ((symbol->dot_size < 0.01) || (symbol->dot_size > 20.0)) {
|
||||
strcpy(symbol->errtxt, "Invalid dot size");
|
||||
return ZINT_ERROR_INVALID_OPTION;
|
||||
}
|
||||
|
||||
switch (symbol->symbology) {
|
||||
case BARCODE_QRCODE:
|
||||
|
||||
@@ -430,7 +430,7 @@ int ps_plot(struct zint_symbol *symbol) {
|
||||
/* Use dots instead of squares */
|
||||
for (i = 0; i < symbol->width; i++) {
|
||||
if (module_is_set(symbol, this_row, i)) {
|
||||
fprintf(feps, "%.2f %.2f %.2f TD\n", ((i + xoffset) * scaler) + (scaler / 2.0), (row_posn * scaler) + (scaler / 2.0), (2.0 / 5.0) * scaler);
|
||||
fprintf(feps, "%.2f %.2f %.2f TD\n", ((i + xoffset) * scaler) + (scaler / 2.0), (row_posn * scaler) + (scaler / 2.0), (symbol->dot_size / 2.0) * scaler);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -171,12 +171,13 @@ void draw_bar(char *pixelbuf, int xpos, int xlen, int ypos, int ylen, int image_
|
||||
}
|
||||
}
|
||||
|
||||
void draw_circle(char *pixelbuf, int image_width, int image_height, int x0, int y0, int radius, char fill) {
|
||||
void draw_circle(char *pixelbuf, int image_width, int image_height, int x0, int y0, float radius, char fill) {
|
||||
int x, y;
|
||||
|
||||
for (y = -radius; y <= radius; y++) {
|
||||
for (x = -radius; x <= radius; x++) {
|
||||
if ((x * x) + (y * y) <= (radius * radius)) {
|
||||
int radius_i = (int) radius;
|
||||
|
||||
for (y = -radius_i; y <= radius_i; y++) {
|
||||
for (x = -radius_i; x <= radius_i; x++) {
|
||||
if ((x * x) + (y * y) <= (radius_i * radius_i)) {
|
||||
if ((y + y0 >= 0) && (y + y0 < image_height)
|
||||
&& (x + x0 >= 0) && (x + x0 < image_width)) {
|
||||
*(pixelbuf + ((y + y0) * image_width) + (x + x0)) = fill;
|
||||
@@ -544,7 +545,7 @@ int plot_raster_dotty(struct zint_symbol *symbol, int rotate_angle, int data_typ
|
||||
draw_circle(scaled_pixelbuf, scale_width, scale_height,
|
||||
(int) ((i + xoffset) * scaler) + (scaler / 2.0),
|
||||
(int) ((r + yoffset) * scaler) + (scaler / 2.0),
|
||||
(int) (scaler / 2.0),
|
||||
(symbol->dot_size / 2.0) * scaler,
|
||||
'1');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,7 +316,7 @@ int svg_plot(struct zint_symbol *symbol) {
|
||||
/* Use (currently undocumented) dot mode - see SF ticket #29 */
|
||||
for (i = 0; i < symbol->width; i++) {
|
||||
if (module_is_set(symbol, this_row, i)) {
|
||||
fprintf(fsvg, " <circle cx=\"%.2f\" cy=\"%.2f\" r=\"%.2f\" fill=\"#%s\" />\n", ((i + xoffset) * scaler) + (scaler / 2.0), (row_posn * scaler) + (scaler / 2.0), (2.0 / 5.0) * scaler, symbol->fgcolour);
|
||||
fprintf(fsvg, " <circle cx=\"%.2f\" cy=\"%.2f\" r=\"%.2f\" fill=\"#%s\" />\n", ((i + xoffset) * scaler) + (scaler / 2.0), (row_posn * scaler) + (scaler / 2.0), (symbol->dot_size / 2.0) * scaler, symbol->fgcolour);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -94,6 +94,7 @@ extern "C" {
|
||||
int bitmap_width;
|
||||
int bitmap_height;
|
||||
unsigned int bitmap_byte_length;
|
||||
float dot_size;
|
||||
struct zint_render *rendered;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user