diff --git a/backend/library.c b/backend/library.c
index 4d59db8e..ac71cbca 100644
--- a/backend/library.c
+++ b/backend/library.c
@@ -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:
diff --git a/backend/ps.c b/backend/ps.c
index 1bd4c9db..707771d1 100644
--- a/backend/ps.c
+++ b/backend/ps.c
@@ -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 {
diff --git a/backend/raster.c b/backend/raster.c
index 7fcf3120..6611fdec 100644
--- a/backend/raster.c
+++ b/backend/raster.c
@@ -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');
}
}
diff --git a/backend/svg.c b/backend/svg.c
index 9442b3e9..6e76355d 100644
--- a/backend/svg.c
+++ b/backend/svg.c
@@ -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, " \n", ((i + xoffset) * scaler) + (scaler / 2.0), (row_posn * scaler) + (scaler / 2.0), (2.0 / 5.0) * scaler, symbol->fgcolour);
+ fprintf(fsvg, " \n", ((i + xoffset) * scaler) + (scaler / 2.0), (row_posn * scaler) + (scaler / 2.0), (symbol->dot_size / 2.0) * scaler, symbol->fgcolour);
}
}
} else {
diff --git a/backend/zint.h b/backend/zint.h
index a88355a7..3ad4c4d7 100644
--- a/backend/zint.h
+++ b/backend/zint.h
@@ -94,6 +94,7 @@ extern "C" {
int bitmap_width;
int bitmap_height;
unsigned int bitmap_byte_length;
+ float dot_size;
struct zint_render *rendered;
};
diff --git a/backend_qt4/qzint.cpp b/backend_qt4/qzint.cpp
index 15557bb5..10a9ad09 100644
--- a/backend_qt4/qzint.cpp
+++ b/backend_qt4/qzint.cpp
@@ -41,6 +41,7 @@ namespace Zint {
m_scale = 1.0;
m_option_3 = 0;
m_hidetext = FALSE;
+ m_dot_size = 4.0 / 5.0;
}
QZint::~QZint() {
@@ -62,6 +63,7 @@ namespace Zint {
m_zintSymbol->option_1 = m_securityLevel;
m_zintSymbol->input_mode = m_input_mode;
m_zintSymbol->option_2 = m_width;
+ m_zintSymbol->dot_size = m_dot_size;
if (m_hidetext) {
m_zintSymbol->show_hrt = 0;
} else {
@@ -151,6 +153,10 @@ namespace Zint {
void QZint::setScale(float scale) {
m_scale = scale;
}
+
+ void QZint::setDotSize(float dot_size) {
+ m_dot_size = dot_size;
+ }
QColor QZint::fgColor() {
return m_fgColor;
@@ -239,6 +245,7 @@ namespace Zint {
m_zintSymbol->option_1 = m_securityLevel;
m_zintSymbol->input_mode = m_input_mode;
m_zintSymbol->option_2 = m_width;
+ m_zintSymbol->dot_size = m_dot_size;
if (m_hidetext) {
m_zintSymbol->show_hrt = 0;
} else {
@@ -493,7 +500,7 @@ namespace Zint {
for (int c = 0; c < m_zintSymbol->width; c++) {
if (module_set(r, c)) {
- painter.drawEllipse(QPointF((c + 1.0), (r + 1.0)), 0.5, 0.5);
+ painter.drawEllipse(QPointF((c + 1.0), (r + 1.0)), m_dot_size / 2.0, m_dot_size / 2.0);
}
}
}
diff --git a/backend_qt4/qzint.h b/backend_qt4/qzint.h
index 7b6eaaa5..212c8945 100644
--- a/backend_qt4/qzint.h
+++ b/backend_qt4/qzint.h
@@ -73,6 +73,8 @@ public:
float scale();
void setScale(float scale);
+
+ void setDotSize(float dot_size);
int mode();
void setMode(int securityLevel);
@@ -116,6 +118,7 @@ private:
float m_scale;
int m_option_3;
bool m_hidetext;
+ float m_dot_size;
};
}
#endif
diff --git a/frontend/main.c b/frontend/main.c
index d051c583..91274b20 100644
--- a/frontend/main.c
+++ b/frontend/main.c
@@ -106,7 +106,7 @@ void usage(void) {
" --notext Remove human readable text\n"
" --square Force Data Matrix symbols to be square\n"
" --dmre Allow Data Matrix Rectangular Extended\n"
- " --init Create reader initialisation symbol (Code 128)\n"
+ " --init Create reader initialisation/programming symbol\n"
" --smalltext Use half-size text in PNG images\n"
" --boldtext Use bold text in PNG images\n"
" --batch Treat each line of input as a separate data set\n"
@@ -114,6 +114,8 @@ void usage(void) {
" --mirroreps Use batch data to determine filename (EPS output)\n"
" --mirrorsvg Use batch data to determine filename (SVG output)\n"
" --eci=NUMBER Set the ECI mode for raw data\n"
+ " --dotty Use dots instead of squares for matrix symbols\n"
+ " --dotsize=NUMBER Set radius of dots in dotty mode\n"
, ZINT_VERSION);
}
@@ -508,6 +510,7 @@ int main(int argc, char **argv) {
{"mirroreps", 0, 0, 0},
{"mirrorsvg", 0, 0, 0},
{"dotty", 0, 0, 0},
+ {"dotsize", 1, 0, 0},
{"eci", 1, 0, 'e'},
{0, 0, 0, 0}
};
@@ -591,6 +594,15 @@ int main(int argc, char **argv) {
my_symbol->scale = 1.0;
}
}
+ if (!strcmp(long_options[option_index].name, "dotsize")) {
+ my_symbol->dot_size = (float) (atof(optarg));
+ if (my_symbol->dot_size < 0.01) {
+ /* Zero and negative values are not permitted */
+ fprintf(stderr, "Invalid dot radius value\n");
+ fflush(stderr);
+ my_symbol->dot_size = 4.0 / 5.0;
+ }
+ }
if (!strcmp(long_options[option_index].name, "border")) {
error_number = validator(NESET, optarg);
if (error_number == ZINT_ERROR_INVALID_DATA) {
@@ -630,7 +642,7 @@ int main(int argc, char **argv) {
if ((atoi(optarg) >= 1) && (atoi(optarg) <= 44)) {
my_symbol->option_1 = atoi(optarg);
} else {
- fprintf(stderr, "Number of columns out of range\n");
+ fprintf(stderr, "Number of rows out of range\n");
fflush(stderr);
}
}
diff --git a/frontend_qt4/grpDotCode.ui b/frontend_qt4/grpDotCode.ui
index b39cc75c..8730e0a6 100644
--- a/frontend_qt4/grpDotCode.ui
+++ b/frontend_qt4/grpDotCode.ui
@@ -281,7 +281,7 @@
-
- false
+ true
Dot Size:
@@ -307,10 +307,10 @@
-
- false
+ true
- 1.0
+ 0.8
diff --git a/frontend_qt4/mainwindow.cpp b/frontend_qt4/mainwindow.cpp
index 3b37d239..b1a2ae80 100644
--- a/frontend_qt4/mainwindow.cpp
+++ b/frontend_qt4/mainwindow.cpp
@@ -298,6 +298,7 @@ void MainWindow::change_options()
connect(m_optionWidget->findChild("cmbDotCols"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
connect(m_optionWidget->findChild("radDotStan"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild("radDotGs1"), SIGNAL(clicked( bool )), SLOT(update_preview()));
+ connect(m_optionWidget->findChild("txtDotSize"), SIGNAL(textChanged( QString )), SLOT(update_preview()));
}
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_AZTEC)
@@ -713,6 +714,7 @@ void MainWindow::update_preview()
m_bc.bc.setWidth(m_optionWidget->findChild("cmbDotCols")->currentIndex());
if(m_optionWidget->findChild("radDotGs1")->isChecked())
m_bc.bc.setInputMode(GS1_MODE);
+ m_bc.bc.setDotSize(m_optionWidget->findChild("txtDotSize")->text().toFloat());
break;
case BARCODE_AZTEC: