diff options
Diffstat (limited to 'lpg/libqr/qr')
-rw-r--r-- | lpg/libqr/qr/bitmap.h | 37 | ||||
-rw-r--r-- | lpg/libqr/qr/bitstream.h | 57 | ||||
-rw-r--r-- | lpg/libqr/qr/code.h | 25 | ||||
-rw-r--r-- | lpg/libqr/qr/common.h | 32 | ||||
-rw-r--r-- | lpg/libqr/qr/data.h | 41 | ||||
-rw-r--r-- | lpg/libqr/qr/layout.h | 22 | ||||
-rw-r--r-- | lpg/libqr/qr/parse.h | 24 | ||||
-rw-r--r-- | lpg/libqr/qr/types.h | 34 | ||||
-rw-r--r-- | lpg/libqr/qr/version.h | 18 |
9 files changed, 290 insertions, 0 deletions
diff --git a/lpg/libqr/qr/bitmap.h b/lpg/libqr/qr/bitmap.h new file mode 100644 index 0000000..098d9c3 --- /dev/null +++ b/lpg/libqr/qr/bitmap.h @@ -0,0 +1,37 @@ +#ifndef QR_BITMAP_H +#define QR_BITMAP_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct qr_bitmap { + unsigned char * bits; + unsigned char * mask; + size_t stride; + size_t width, height; +}; + +struct qr_bitmap * qr_bitmap_create(size_t width, size_t height, int masked); +void qr_bitmap_destroy(struct qr_bitmap *); + +int qr_bitmap_add_mask(struct qr_bitmap *); + +struct qr_bitmap * qr_bitmap_clone(const struct qr_bitmap *); + +void qr_bitmap_merge(struct qr_bitmap * dest, const struct qr_bitmap * src); + +void qr_bitmap_render(const struct qr_bitmap * bmp, + void * buffer, + int mod_bits, + long line_stride, + int line_repeat, + unsigned long mark, + unsigned long space); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/lpg/libqr/qr/bitstream.h b/lpg/libqr/qr/bitstream.h new file mode 100644 index 0000000..aa431e8 --- /dev/null +++ b/lpg/libqr/qr/bitstream.h @@ -0,0 +1,57 @@ +#ifndef QR_BITSTREAM_H +#define QR_BITSTREAM_H + +#include <stddef.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Note: when writing / reading multiple bits, the + * _most_ significant bits come first in the stream. + * (That is, the order you would naturally write the + * number in binary) + */ + +struct qr_bitstream; + +struct qr_bitstream * qr_bitstream_create(void); +int qr_bitstream_resize(struct qr_bitstream *, size_t bits); +void qr_bitstream_destroy(struct qr_bitstream *); +struct qr_bitstream * qr_bitstream_dup(const struct qr_bitstream *); + +void qr_bitstream_seek(struct qr_bitstream *, size_t pos); +size_t qr_bitstream_tell(const struct qr_bitstream *); +size_t qr_bitstream_remaining(const struct qr_bitstream *); +size_t qr_bitstream_size(const struct qr_bitstream *); + +unsigned long qr_bitstream_read(struct qr_bitstream *, int bits); + +void qr_bitstream_unpack(struct qr_bitstream *, + unsigned int * result, + size_t count, + int bitsize); + +int qr_bitstream_write(struct qr_bitstream *, + unsigned long value, + int bits); + +int qr_bitstream_pack(struct qr_bitstream *, + const unsigned int * values, + size_t count, + int bitsize); + +int qr_bitstream_cat(struct qr_bitstream *, + const struct qr_bitstream * src); + +int qr_bitstream_copy(struct qr_bitstream * dest, + struct qr_bitstream * src, + size_t count); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/lpg/libqr/qr/code.h b/lpg/libqr/qr/code.h new file mode 100644 index 0000000..0f5d49c --- /dev/null +++ b/lpg/libqr/qr/code.h @@ -0,0 +1,25 @@ +#ifndef QR_CODE_H +#define QR_CODE_H + +#include <stddef.h> +#include "types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct qr_code { + int version; + struct qr_bitmap * modules; +}; + +struct qr_code * qr_code_create(const struct qr_data * data); + +void qr_code_destroy(struct qr_code *); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/lpg/libqr/qr/common.h b/lpg/libqr/qr/common.h new file mode 100644 index 0000000..b7052ad --- /dev/null +++ b/lpg/libqr/qr/common.h @@ -0,0 +1,32 @@ +#ifndef QR_COMMON_H +#define QR_COMMON_H + +#include <qr/types.h> + +#ifdef __cplusplus +extern "C" { +#endif + +void qr_mask_apply(struct qr_bitmap * bmp, int mask); + +size_t qr_code_total_capacity(int version); + +int qr_code_width(const struct qr_code *); + +/* See table 19 of the spec for the layout of EC data. There are at + * most two different block lengths, so the total number of data+ec + * blocks is the sum of block_count[]. The total number of 8-bit + * words in each kind of block is data_length + ec_length. + */ +void qr_get_rs_block_sizes(int version, + enum qr_ec_level ec, + int block_count[2], + int data_length[2], + int ec_length[2]); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/lpg/libqr/qr/data.h b/lpg/libqr/qr/data.h new file mode 100644 index 0000000..06600ab --- /dev/null +++ b/lpg/libqr/qr/data.h @@ -0,0 +1,41 @@ +#ifndef QR_DATA_H +#define QR_DATA_H + +#include <stddef.h> +#include "types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct qr_data { + int version; /* 1 ~ 40 */ + enum qr_ec_level ec; + struct qr_bitstream * bits; + size_t offset; +}; + +struct qr_data * qr_data_create(int format, /* 1 ~ 40; 0=auto */ + enum qr_ec_level ec, + enum qr_data_type type, + const char * input, + size_t length); + +void qr_data_destroy(struct qr_data *); + +enum qr_data_type qr_data_type(const struct qr_data *); + +size_t qr_data_length(const struct qr_data *); +size_t qr_data_size_field_length(int version, enum qr_data_type); +size_t qr_data_dpart_length(enum qr_data_type type, size_t nchars); + +enum qr_data_type qr_parse_data(const struct qr_data * input, + char ** output, + size_t * length); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/lpg/libqr/qr/layout.h b/lpg/libqr/qr/layout.h new file mode 100644 index 0000000..e691bdb --- /dev/null +++ b/lpg/libqr/qr/layout.h @@ -0,0 +1,22 @@ +#ifndef QR_CODE_LAYOUT_H +#define QR_CODE_LAYOUT_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct qr_iterator; + +void qr_layout_init_mask(struct qr_code *); + +struct qr_iterator * qr_layout_begin(struct qr_code * code); +unsigned int qr_layout_read(struct qr_iterator *); +void qr_layout_write(struct qr_iterator *, unsigned int); +void qr_layout_end(struct qr_iterator *); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/lpg/libqr/qr/parse.h b/lpg/libqr/qr/parse.h new file mode 100644 index 0000000..0e08354 --- /dev/null +++ b/lpg/libqr/qr/parse.h @@ -0,0 +1,24 @@ +#ifndef QR_PARSE_H +#define QR_PARSE_H + +#include "data.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int qr_code_parse(const void * buffer, + size_t line_bits, + size_t line_stride, + size_t line_count, + struct qr_data ** data); + +int qr_decode_format(unsigned long bits, enum qr_ec_level * ec, int * mask); +int qr_decode_version(unsigned long bits, int * version); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/lpg/libqr/qr/types.h b/lpg/libqr/qr/types.h new file mode 100644 index 0000000..ae760ab --- /dev/null +++ b/lpg/libqr/qr/types.h @@ -0,0 +1,34 @@ +#ifndef QR_TYPES_H +#define QR_TYPES_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct qr_data; +struct qr_code; + +enum qr_data_type { + QR_DATA_INVALID = -1, + QR_DATA_ECI = 7, + QR_DATA_NUMERIC = 1, + QR_DATA_ALPHA = 2, + QR_DATA_8BIT = 4, + QR_DATA_KANJI = 8, /* JIS X 0208 */ + QR_DATA_MIXED = 3, + QR_DATA_FNC1 = 9 +}; + +enum qr_ec_level { + QR_EC_LEVEL_L = 0x1, + QR_EC_LEVEL_M = 0x0, + QR_EC_LEVEL_Q = 0x3, + QR_EC_LEVEL_H = 0x2 +}; + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/lpg/libqr/qr/version.h b/lpg/libqr/qr/version.h new file mode 100644 index 0000000..ce540f4 --- /dev/null +++ b/lpg/libqr/qr/version.h @@ -0,0 +1,18 @@ +#ifndef QR_VERSION_H +#define QR_VERSION_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define QR_VERSION_MAJOR 0 +#define QR_VERSION_MINOR 3 + +#define QR_VERSION "0.3" + +#ifdef __cplusplus +} +#endif + +#endif + |