aboutsummaryrefslogtreecommitdiff
path: root/lpg/libqr/qr-bitmap.c
diff options
context:
space:
mode:
authorLeo Howell <leo@lwh.jp>2009-11-14 20:24:57 +0900
committerLeo Howell <leo@lwh.jp>2009-11-14 20:24:57 +0900
commitc2e4639d2ebefbeb7f8b7e1826ae2391c6876a5a (patch)
tree8f208b60816aa1f7390b249c21f0771a8bce7c6e /lpg/libqr/qr-bitmap.c
parent2a5548351d9814a8a23eff1e43e14008ea4ae1d0 (diff)
downloadpdf-simple-sign-c2e4639d2ebefbeb7f8b7e1826ae2391c6876a5a.tar.gz
pdf-simple-sign-c2e4639d2ebefbeb7f8b7e1826ae2391c6876a5a.tar.xz
pdf-simple-sign-c2e4639d2ebefbeb7f8b7e1826ae2391c6876a5a.zip
Merge some files
Diffstat (limited to 'lpg/libqr/qr-bitmap.c')
-rw-r--r--lpg/libqr/qr-bitmap.c89
1 files changed, 0 insertions, 89 deletions
diff --git a/lpg/libqr/qr-bitmap.c b/lpg/libqr/qr-bitmap.c
deleted file mode 100644
index 7d2d900..0000000
--- a/lpg/libqr/qr-bitmap.c
+++ /dev/null
@@ -1,89 +0,0 @@
-#include <assert.h>
-#include <limits.h>
-#include <stdlib.h>
-#include <string.h>
-#include <qr/bitmap.h>
-
-struct qr_bitmap * qr_bitmap_create(int width, int height, int masked)
-{
- struct qr_bitmap * out;
- size_t size;
-
- out = malloc(sizeof(*out));
- if (!out)
- goto fail;
-
- out->width = width;
- out->height = height;
- out->stride = (width / CHAR_BIT) + (width % CHAR_BIT ? 1 : 0);
-
- size = out->stride * height;
-
- out->mask = 0;
- out->bits = malloc(size);
- if (!out->bits)
- goto fail;
- memset(out->bits, 0, size);
-
- if (masked) {
- out->mask = malloc(out->stride * width);
- if (!out->mask)
- goto fail;
- memset(out->mask, 0xFF, size);
- }
-
- return out;
-
-fail:
- qr_bitmap_destroy(out);
- return 0;
-}
-
-void qr_bitmap_destroy(struct qr_bitmap * bmp)
-{
- if (bmp) {
- free(bmp->bits);
- free(bmp->mask);
- free(bmp);
- }
-}
-
-struct qr_bitmap * qr_bitmap_clone(const struct qr_bitmap * src)
-{
- struct qr_bitmap * bmp;
- size_t size;
-
- bmp = qr_bitmap_create(src->width, src->height, !!src->mask);
- if (!bmp)
- return 0;
-
- assert(bmp->stride == src->stride);
-
- size = bmp->width * bmp->stride;
- memcpy(bmp->bits, src->bits, size);
- if (bmp->mask)
- memcpy(bmp->mask, src->mask, size);
-
- return bmp;
-}
-
-void qr_bitmap_merge(struct qr_bitmap * dest, const struct qr_bitmap * src)
-{
- unsigned char * d, * s, * m;
- size_t n;
-
- assert(dest->stride == src->stride);
- assert(dest->height == src->height);
- assert(src->mask);
-
- n = dest->stride * dest->height;
- d = dest->bits;
- s = src->bits;
- m = src->mask;
-
- while (n--) {
- *d &= ~*m;
- *d++ |= *s++ & *m++;
- }
-}
-