jabcode
 All Classes Files Functions Variables Enumerations Macros
jabcode.h
Go to the documentation of this file.
1 
14 #ifndef JABCODE_H
15 #define JABCODE_H
16 
17 #define VERSION "1.0.0"
18 #define BUILD_DATE __DATE__
19 
20 #define MAX_SYMBOL_NUMBER 61
21 #define MAX_COLOR_NUMBER 256
22 #define MAX_SIZE_ENCODING_MODE 256
23 #define JAB_ENCODING_MODES 6
24 #define ENC_MAX 1000000
25 #define NUMBER_OF_MASK_PATTERNS 8
26 
27 #define DEFAULT_SYMBOL_NUMBER 1
28 #define DEFAULT_MODULE_SIZE 12
29 #define DEFAULT_COLOR_NUMBER 8
30 #define DEFAULT_MODULE_COLOR_MODE 2
31 #define DEFAULT_ECC_LEVEL 3
32 #define DEFAULT_MASKING_REFERENCE 7
33 
34 
35 #define DISTANCE_TO_BORDER 4
36 #define MINIMUM_DISTANCE_BETWEEN_ALIGNMENTS 16
37 
38 #define BITMAP_BITS_PER_PIXEL 32
39 #define BITMAP_BITS_PER_CHANNEL 8
40 #define BITMAP_CHANNEL_COUNT 4
41 
42 #define JAB_SUCCESS 1
43 #define JAB_FAILURE 0
44 
45 #define NORMAL_DECODE 0
46 #define COMPATIBLE_DECODE 1
47 
48 #define VERSION2SIZE(x) (x * 4 + 17)
49 #define SIZE2VERSION(x) ((x - 17) / 4)
50 #define MAX(a,b) ({__typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _a : _b;})
51 #define MIN(a,b) ({__typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b;})
52 
53 #define JAB_REPORT_ERROR(x) { printf("JABCode Error: "); printf x; printf("\n"); }
54 #define JAB_REPORT_INFO(x) { printf("JABCode Info: "); printf x; printf("\n"); }
55 
56 typedef unsigned char jab_byte;
57 typedef char jab_char;
58 typedef unsigned char jab_boolean;
59 typedef int jab_int32;
60 typedef unsigned int jab_uint32;
61 typedef short jab_int16;
62 typedef unsigned short jab_uint16;
63 typedef long long jab_int64;
64 typedef unsigned long long jab_uint64;
65 typedef float jab_float;
66 typedef double jab_double;
67 
71 typedef struct {
72  jab_int32 x;
73  jab_int32 y;
75 
79 typedef struct {
80  jab_float x;
81  jab_float y;
82 }jab_point;
83 
87 typedef struct {
88  jab_int32 length;
89  jab_char data[];
90 }jab_data;
91 
95 typedef struct {
96  jab_int32 width;
97  jab_int32 height;
98  jab_int32 bits_per_pixel;
99  jab_int32 bits_per_channel;
100  jab_int32 channel_count;
101  jab_byte pixel[];
102 }jab_bitmap;
103 
107 typedef struct {
108  jab_int32 index;
109  jab_vector2d side_size;
110  jab_int32 host;
111  jab_int32 slaves[4];
112  jab_int32 wcwr[2];
113  jab_data* data;
114  jab_byte* data_map;
115  jab_data* metadata;
116  jab_byte* matrix;
117 }jab_symbol;
118 
122 typedef struct {
123  jab_int32 color_number;
124  jab_int32 symbol_number;
125  jab_int32 module_size;
126  jab_int32 master_symbol_width;
127  jab_int32 master_symbol_height;
128  jab_byte* palette;
129  jab_vector2d* symbol_versions;
130  jab_byte* symbol_ecc_levels;
131  jab_int32* symbol_positions;
133  jab_bitmap* bitmap;
134 }jab_encode;
135 
139 typedef struct {
140  jab_byte Nc;
141  jab_byte mask_type;
142  jab_byte docked_position;
143  jab_byte VF;
144  jab_vector2d side_version;
145  jab_vector2d ecl;
146 }jab_metadata;
147 
151 typedef struct {
152  jab_int32 index;
153  jab_int32 host_index;
154  jab_int32 host_position;
155  jab_vector2d side_size;
156  jab_float module_size;
157  jab_point pattern_positions[4];
158  jab_metadata metadata;
159  jab_metadata slave_metadata[4];
160  jab_byte* palette;
161  jab_data* data;
163 
164 
165 extern jab_encode* createEncode(jab_int32 color_number, jab_int32 symbol_number);
166 extern void destroyEncode(jab_encode* enc);
167 extern jab_int32 generateJABCode(jab_encode* enc, jab_data* data);
168 extern jab_data* decodeJABCode(jab_bitmap* bitmap, jab_int32 mode, jab_int32* status);
169 extern jab_data* decodeJABCodeEx(jab_bitmap* bitmap, jab_int32 mode, jab_int32* status, jab_decoded_symbol* symbols, jab_int32 max_symbol_number);
170 extern jab_boolean saveImage(jab_bitmap* bitmap, jab_char* filename);
171 extern jab_bitmap* readImage(jab_char* filename);
172 extern void reportError(jab_char* message);
173 
174 #endif
Decoded metadata.
Definition: jabcode.h:139
Decoded symbol.
Definition: jabcode.h:151
2-dimensional float vector
Definition: jabcode.h:79
jab_data * decodeJABCode(jab_bitmap *bitmap, jab_int32 mode, jab_int32 *status)
Decode a JAB Code.
Definition: detector.c:3074
Code bitmap.
Definition: jabcode.h:95
void destroyEncode(jab_encode *enc)
Destroy encode object.
Definition: encoder.c:249
jab_encode * createEncode(jab_int32 color_number, jab_int32 symbol_number)
Create encode object.
Definition: encoder.c:177
jab_boolean saveImage(jab_bitmap *bitmap, jab_char *filename)
Save code bitmap as png image.
Definition: image.c:26
jab_int32 generateJABCode(jab_encode *enc, jab_data *data)
Generate JABCode.
Definition: encoder.c:2215
Data structure.
Definition: jabcode.h:87
jab_byte * palette
Palette holding used module colors in format RGB.
Definition: jabcode.h:128
2-dimensional integer vector
Definition: jabcode.h:71
jab_symbol * symbols
Pointer to internal representation of JAB Code symbols.
Definition: jabcode.h:132
Symbol parameters.
Definition: jabcode.h:107
Encode parameters.
Definition: jabcode.h:122
void reportError(jab_char *message)
Report error message.
Definition: encoder.c:2352
jab_data * decodeJABCodeEx(jab_bitmap *bitmap, jab_int32 mode, jab_int32 *status, jab_decoded_symbol *symbols, jab_int32 max_symbol_number)
Extended function to decode a JAB Code.
Definition: detector.c:2926
jab_bitmap * readImage(jab_char *filename)
Read image into code bitmap.
Definition: image.c:64