Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Micro QR Code support is marked as 'experimental'. More tests and doc…

…ument updates.
  • Loading branch information...
commit ac625373f38d1cd710d65459954ccf99d486d23d 1 parent 27b292d
@fukuchi fukuchi authored
View
18 ChangeLog
@@ -1,3 +1,21 @@
+2011.11.23 Kentaro FUKUCHI <kentaro@fukuchi.org>
+ [3.2.0]
+ * qrencode.1.in:
+ - Added descriptions of "-d" and "-M".
+
+2011.11.3 Kentaro FUKUCHI <kentaro@fukuchi.org>
+ [3.2.0]
+ * tests/view_qrcode.c:
+ - Messages improved.
+ * mmask.c:
+ - A bug in mask evaluation function has been eliminatd.
+ * tests/test_mmask.c:
+ - New test case has been added.
+ * qrenc.c:
+ - Micro QR Code support is now marked as "experimental" explicitly.
+ * tests/test_qrinput.c, tests/test_qrencode.c:
+ - Added some test cases.
+
2011.10.23 Kentaro FUKUCHI <kentaro@fukuchi.org>
[3.2.0]
* 3.2 branch has been started.
View
16 NEWS
@@ -1,7 +1,7 @@
libqrencode NEWS - Overview of changes
======================================
-Version 3.2.0 (2011.x.x)
+Version 3.2.0 (2011.11.23)
------------------------
* "--dpi" (or "-d") has been added to qrencode. This option set DPI information
in an output PNG image. (Thanks to David Dahl)
@@ -10,15 +10,15 @@ Version 3.2.0 (2011.x.x)
* QRcode_encodeData(), QRcode_encodeDataMQR, QRcode_encodeDataStructured() have
been added for binary data encoding including '\0'.
* Typo and bug fixes.
-* Micro QR Code support has been added. (experimental)
+* Experimental Micro QR Code support has been added.
* "--micro" (or "-M") option for Micro QR Code has been added to qrencode.
(experimental)
Release Note:
-Binary data including '\0' can be encoded now with qrencode. To encode a binary
-data, give "-8" option to qrencode, and let qrencode obtain data via standard
-input like "qrencode -8 -o output.png < binary". "--dpi" and "-d" are also
-added to embed DPI information to PNG file.
+Binary data including '\0' is now supported. To encode a binary data, give "-8"
+option to qrencode, and let qrencode obtain data via standard input like
+"qrencode -8 -o output.png < binary". "--dpi" and "-d" are also added to embed
+DPI information to PNG file.
A bug in the mask pattern evaluation routine has been fixed. In some cases,
libqrencode may generate a different symbol from the one that was generated by
@@ -26,8 +26,8 @@ the prior libqrencode because of this bug fix, but the embedded data are not
affected. The symbols generated by the old libqrencode are valid.
Experimental support of Micro QR Code encoder has been added. Some functions
-(QRcode_*MQR()) have been added to the library. The command line tool also
-accepts "--micro" and "-M" options.
+(QRcode_*MQR()) have been added to the library. The command line tool generates
+Micro QR Code when "--micro" or "-M" is given.
Version 3.1.1 (2010.2.3)
------------------------
View
13 README
@@ -64,11 +64,14 @@ You can generate a manual of the library by using Doxygen.
WARNINGS
========
-Some functions are THREAD UNSAFE. See qrencode.h for the details.
+The library is distributed WITHOUT ANY WRRANTY.
-Carefully use the qrencode command if it is used by a web application (CGI).
-For example, giving "-s" option with too large number to qrencode may cause DoS.
-You should limit the parameter by your application.
+Micro QR Code support is EXPERIMENTAL.
+
+Be careful to use the command line tool (qrencode) if it is used by a web
+application (e.g. CGI script). For example, giving "-s" option with a large
+number to qrencode may cause DoS. The parameters should be checked by the
+application.
LICENSING INFORMATION
@@ -114,7 +117,7 @@ ACKNOWLEDGMENTS
QR Code is registered trademarks of DENSO WAVE INCORPORATED in JAPAN and other
countries.
-Reed-Solomon code encoder is written by Phil Karn, KA9Q.
+Reed-Solomon encoder is written by Phil Karn, KA9Q.
Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q
NANKI Haruo - improved lower-case characteres encoding
View
2  TODO
@@ -1,3 +1,5 @@
+Micro QR code encoding is not tested well.
+
Documents (not only the README, but also the manual of the library) needs
revision of grammer, spell or to resolve ambiguity or incomplete descriptions.
Feel really free to send us your revision.
View
2  qrenc.c
@@ -98,7 +98,7 @@ static void usage(int help, int longopt)
" -i, --ignorecase\n"
" ignore case distinctions and use only upper-case characters.\n\n"
" -8, --8bit encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n\n"
-" -M, --micro encode in a Micro QR Code.\n\n"
+" -M, --micro encode in a Micro QR Code. (experimental)\n\n"
" -V, --version\n"
" display the version number and copyrights of the qrencode.\n\n"
" [STRING] input data. If it is not specified, data will be taken from\n"
View
10 qrencode.1.in
@@ -1,4 +1,4 @@
-.TH QRENCODE 1 "Jan. 23, 2008" "qrencode @VERSION@"
+.TH QRENCODE 1 "Nov. 23, 2011" "qrencode @VERSION@"
.SH NAME
qrencode \- Encode input data in a QR Code and save as a PNG image.
.SH SYNOPSIS
@@ -36,6 +36,9 @@ specify the version of the symbol. (default=auto)
.B \-m NUMBER, --margin=NUMBER
specify the width of margin. (default=4)
.TP
+.B \-d NUMBER, --dpi=NUMBER
+specify the DPI of the generated PNG. (default=72)
+.TP
.B \-S, --structured
make structured symbols. Version must be specified.
.TP
@@ -51,6 +54,9 @@ ignore case distinctions and use only upper-case characters.
.B \-8, --8bit
encode entire data in 8-bit mode. -k, -c and -i will be ignored.
.TP
+.B \-M, --micro
+encode in a Micro QR Code. (experimental)
+.TP
.B \-V, --version
display the version number and copyrights of the qrencode.
.TP
@@ -70,4 +76,4 @@ case-insensitive mode.
Written by Kentaro Fukuchi.
.SH COPYRIGHT
-Copyright (C) 2006, 2007, 2008, 2009, 2010 Kentaro Fukuchi.
+Copyright (C) 2006-2011 Kentaro Fukuchi.
View
38 tests/test_mmask.c
@@ -103,12 +103,50 @@ void test_masks(void)
testFinish();
}
+void test_maskEvaluation(void)
+{
+ static const int w = 11;
+ unsigned char pattern[w*w];
+ int i, score;
+
+ memset(pattern, 0, w*w);
+
+ testStart("Test mask evaluation");
+ score = MMask_evaluateSymbol(w, pattern);
+ assert_equal(score, 0, "Mask score caluculation is incorrect. (score=%d (%d expected)\n", score, 0);
+
+ for(i=0; i<w; i++) {
+ pattern[(w-1) * w + i] = 1;
+ }
+ score = MMask_evaluateSymbol(w, pattern);
+ assert_equal(score, 16 + w - 1, "Mask score caluculation is incorrect. (score=%d) (%d expected)\n", score, 16 + w - 1);
+
+ for(i=0; i<w; i++) {
+ pattern[(w-1) * w + i] = 0;
+ pattern[i * w + w - 1] = 1;
+ }
+ score = MMask_evaluateSymbol(w, pattern);
+ assert_equal(score, 16 + w - 1, "Mask score caluculation is incorrect. (score=%d) (%d expected)\n", score, 16 + w - 1);
+
+ for(i=0; i<w; i++) {
+ pattern[(w-1) * w + i] = 1;
+ pattern[i * w + w - 1] = 1;
+ }
+ score = MMask_evaluateSymbol(w, pattern);
+ assert_equal(score, 16 * (w - 1) + w - 1, "Mask score caluculation is incorrect. (score=%d) (%d expected)\n", score, 16 * (w - 1) + w - 1);
+
+ testFinish();
+}
+
int main(void)
{
//print_masks();
test_masks();
+ test_maskEvaluation();
report();
+ MQRspec_clearCache();
+
return 0;
}
View
48 tests/test_qrencode.c
@@ -813,6 +813,53 @@ void test_decodeShortMQR(void)
testFinish();
}
+void test_mqrencode(void)
+{
+ char *str = "MICROQR";
+ char pattern[] = {
+ "#######_#_#_#_#"
+ "#_____#_#__####"
+ "#_###_#_#_####_"
+ "#_###_#_#__##_#"
+ "#_###_#___#__##"
+ "#_____#____#_#_"
+ "#######__##_#_#"
+ "_________#__#__"
+ "#___#__####_#_#"
+ "_#######_#_##_#"
+ "##___#_#____#__"
+ "_##_#_####____#"
+ "#__###___#__##_"
+ "_###_#_###_#_#_"
+ "##____####_###_"
+ };
+ QRcode qrcode;
+ QRdata *qrdata;
+ unsigned char *frame;
+ int i;
+
+ testStart("Encoding test (MQR).");
+
+ qrcode.width = 15;
+ qrcode.version = 3;
+
+ frame = MQRspec_newFrame(qrcode.version);
+ for(i=0; i<225; i++) {
+ frame[i] ^= (pattern[i] == '#')?1:0;
+ }
+
+ qrcode.data = frame;
+ qrdata = QRcode_decodeMQR(&qrcode);
+ assert_equal(qrdata->version, 3, "Format info decoder returns wrong version number: %d (%d expected)\n", qrdata->version, 3);
+ assert_equal(qrdata->level, 1, "Format info decoder returns wrong level: %d (%d expected)\n", qrdata->level, 1);
+ assert_zero(strcmp((char *)qrdata->data, str), "Decoded data (%s) mismatched (%s)\n", (char *)qrdata->data, str);
+
+ QRdata_free(qrdata);
+ free(frame);
+
+ testFinish();
+}
+
int main(void)
{
test_iterate();
@@ -846,6 +893,7 @@ int main(void)
test_formatInfoMQR();
test_encodeTooLongMQR();
test_decodeShortMQR();
+ test_mqrencode();
QRcode_clearCache();
View
15 tests/test_qrinput.c
@@ -883,6 +883,20 @@ void test_padding2MQR(void)
testFinish();
}
+void test_textMQR(void)
+{
+ int version = 3;
+ QRecLevel level = QR_ECLEVEL_M;
+ char *str = "MICROQR";
+ char *correct = {"01 0111 01111110000 01000110111 10001010010 011011 0000000 0000 11101100 0000"};
+ int ret;
+
+ testStart("Text encoding (Micro QR)");
+ ret = encodeAndCheckBStream(1, version, level, QR_MODE_AN, str, correct);
+ assert_zero(ret, "AlphaNumeric string '%s' incorrectly encoded.\n", str);
+ testFinish();
+}
+
void test_ECIinvalid(void)
{
QRinput *stream;
@@ -961,6 +975,7 @@ int main(void)
test_mqr_setlevel();
test_paddingMQR();
test_padding2MQR();
+ test_textMQR();
test_ECIinvalid();
test_encodeECI();
View
3  tests/view_qrcode.c
@@ -72,7 +72,7 @@ static void usage(int help, int longopt)
" -i, --ignorecase\n"
" ignore case distinctions and use only upper-case characters.\n\n"
" -8, --8bit encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n\n"
-" -M, --micro encode in a Micro QR Code.\n\n"
+" -M, --micro encode in a Micro QR Code. (experimental)\n\n"
" -V, --version\n"
" display the version number and copyrights of the qrencode.\n\n"
" [STRING] input data. If it is not specified, data will be taken from\n"
@@ -166,6 +166,7 @@ void draw_singleQRcode(QRinput *stream, int mask)
}
if(qrcode == NULL) {
width = (11 + margin * 2) * size;
+ fprintf(stderr, "Input data does not fit to this setting.\n");
} else {
version = qrcode->version;
width = (qrcode->width + margin * 2) * size;
Please sign in to comment.
Something went wrong with that request. Please try again.