aboutsummaryrefslogtreecommitdiff
path: root/lpg/libqr/code-create.c
diff options
context:
space:
mode:
authorLeo Howell <leo@lwh.jp>2009-11-03 00:12:30 +0900
committerLeo Howell <leo@lwh.jp>2009-11-03 15:30:52 +0900
commit688c1b52ed356d024ba2e72ba52f7da64b7d74ed (patch)
treea68195f38f309e6aecc20f9b85318890417c477e /lpg/libqr/code-create.c
parent4eee8658be637fde410f429e69e86b034cd39185 (diff)
downloadpdf-simple-sign-688c1b52ed356d024ba2e72ba52f7da64b7d74ed.tar.gz
pdf-simple-sign-688c1b52ed356d024ba2e72ba52f7da64b7d74ed.tar.xz
pdf-simple-sign-688c1b52ed356d024ba2e72ba52f7da64b7d74ed.zip
generate alignment pattern
Diffstat (limited to 'lpg/libqr/code-create.c')
-rw-r--r--lpg/libqr/code-create.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/lpg/libqr/code-create.c b/lpg/libqr/code-create.c
index 36ebb24..ae23acc 100644
--- a/lpg/libqr/code-create.c
+++ b/lpg/libqr/code-create.c
@@ -79,6 +79,8 @@ static int draw_functional(struct qr_code * code,
struct qr_bitmap * bmp;
int dim = qr_code_width(code);
int i;
+ int x, y;
+ int am_side;
bmp = qr_bitmap_create(dim, dim, 0);
if (!bmp)
@@ -95,7 +97,26 @@ static int draw_functional(struct qr_code * code,
setpx(bmp, 6, i);
}
- /* XXX: alignment pattern */
+ /* Alignment pattern */
+ am_side = code->version > 1 ? (code->version / 7) + 2 : 0;
+ for (y = 0; y < am_side; ++y) {
+ const int * am_pos = QR_ALIGNMENT_LOCATION[code->version - 1];
+
+ for (x = 0; x < am_side; ++x) {
+ if ((x == 0 && y == 0) ||
+ (x == 0 && y == am_side - 1) ||
+ (x == am_side - 1 && y == 0))
+ continue;
+
+ for (i = -2; i < 2; ++i) {
+ setpx(bmp, am_pos[x] + i, am_pos[y] - 2);
+ setpx(bmp, am_pos[x] + 2, am_pos[y] + i);
+ setpx(bmp, am_pos[x] - i, am_pos[y] + 2);
+ setpx(bmp, am_pos[x] - 2, am_pos[y] - i);
+ }
+ setpx(bmp, am_pos[x], am_pos[y]);
+ }
+ }
/* Format info */
setpx(bmp, 8, dim - 8);