aboutsummaryrefslogtreecommitdiff
path: root/lpg/libqr/code-common.c
diff options
context:
space:
mode:
authorLeo Howell <leo@lwh.jp>2009-09-05 09:33:22 +0900
committerLeo Howell <leo@lwh.jp>2009-09-05 09:33:22 +0900
commitef01767c732629b7eff7d1601e76a1bac58f5bfd (patch)
treeac29871fd3c6f1bab8dc8e3c51e33292d5544a96 /lpg/libqr/code-common.c
downloadpdf-simple-sign-ef01767c732629b7eff7d1601e76a1bac58f5bfd.tar.gz
pdf-simple-sign-ef01767c732629b7eff7d1601e76a1bac58f5bfd.tar.xz
pdf-simple-sign-ef01767c732629b7eff7d1601e76a1bac58f5bfd.zip
The story so far
Diffstat (limited to 'lpg/libqr/code-common.c')
-rw-r--r--lpg/libqr/code-common.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/lpg/libqr/code-common.c b/lpg/libqr/code-common.c
new file mode 100644
index 0000000..08b16df
--- /dev/null
+++ b/lpg/libqr/code-common.c
@@ -0,0 +1,36 @@
+#include <stdlib.h>
+#include <qr/code.h>
+
+#include "code-common.h"
+
+void qr_code_destroy(struct qr_code * code)
+{
+ free(code->modules);
+ free(code);
+}
+
+int qr_code_width(const struct qr_code * code)
+{
+ return code_side_length(code->format);
+}
+
+int code_side_length(int format)
+{
+ return format * 4 + 17;
+}
+
+int code_finder_count(int format)
+{
+ int x = format / 7;
+ return format > 1 ? x*x + 4*x + 1 : 0;
+}
+
+size_t code_total_capacity(int format)
+{
+ /* XXX: figure out the "correct" formula */
+ return 160
+ + 25 * code_finder_count(format)
+ - 10 * (format / 7)
+ + 2 * code_side_length(format);
+}
+