1 /**
2  * libdmtx - Data Matrix Encoding/Decoding Library
3  * Copyright 2008, 2009 Mike Laughton. All rights reserved.
4  * Copyright 2012-2016 Vadim A. Misbakh-Soloviov. All rights reserved.
5  * Copyright 2016 Tim Zaman. All rights reserved.
6  *
7  * See LICENSE file in the main project directory for full
8  * terms of use and distribution.
9  *
10  * Contact:
11  * Vadim A. Misbakh-Soloviov <dmtx@mva.name>
12  * Mike Laughton <mike@dragonflylogic.com>
13  *
14  * \file dmtx.h
15  * \brief Main libdmtx header
16  */
17 
18 #ifndef __DMTX_H__
19 #define __DMTX_H__
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 /* Time headers required for DmtxTime struct below */
26 #include <time.h>
27 #ifdef HAVE_SYS_TIME_H
28 #include <sys/time.h>
29 #endif
30 
31 #ifndef M_PI
32 #define M_PI      3.14159265358979323846
33 #endif
34 
35 #ifndef M_PI_2
36 #define M_PI_2    1.57079632679489661923
37 #endif
38 
39 #define DmtxVersion              "0.7.5"
40 
41 #define DmtxUndefined                 -1
42 
43 #define DmtxPassFail        unsigned int
44 #define DmtxPass                       1
45 #define DmtxFail                       0
46 
47 #define DmtxBoolean         unsigned int
48 #define DmtxTrue                       1
49 #define DmtxFalse                      0
50 
51 #define DmtxFormatMatrix               0
52 #define DmtxFormatMosaic               1
53 
54 #define DmtxSymbolSquareCount         24
55 #define DmtxSymbolRectCount            6
56 
57 #define DmtxModuleOff               0x00
58 #define DmtxModuleOnRed             0x01
59 #define DmtxModuleOnGreen           0x02
60 #define DmtxModuleOnBlue            0x04
61 #define DmtxModuleOnRGB             0x07  /* OnRed | OnGreen | OnBlue */
62 #define DmtxModuleOn                0x07
63 #define DmtxModuleUnsure            0x08
64 #define DmtxModuleAssigned          0x10
65 #define DmtxModuleVisited           0x20
66 #define DmtxModuleData              0x40
67 
68 #define DMTX_CHECK_BOUNDS(l,i) (assert((i) >= 0 && (i) < (l)->length && (l)->length <= (l)->capacity))
69 
70 typedef enum {
71    DmtxStatusEncoding, /* Encoding is currently underway */
72    DmtxStatusComplete, /* Encoding is done and everything went well */
73    DmtxStatusInvalid,  /* Something bad happened that sometimes happens */
74    DmtxStatusFatal     /* Something happened that should never happen */
75 } DmtxStatus;
76 
77 typedef enum {
78    DmtxSchemeAutoFast        = -2,
79    DmtxSchemeAutoBest        = -1,
80    DmtxSchemeAscii           =  0,
81    DmtxSchemeC40,
82    DmtxSchemeText,
83    DmtxSchemeX12,
84    DmtxSchemeEdifact,
85    DmtxSchemeBase256
86 } DmtxScheme;
87 
88 typedef enum {
89    DmtxSymbolRectAuto        = -3,
90    DmtxSymbolSquareAuto      = -2,
91    DmtxSymbolShapeAuto       = -1,
92    DmtxSymbol10x10           =  0,
93    DmtxSymbol12x12,
94    DmtxSymbol14x14,
95    DmtxSymbol16x16,
96    DmtxSymbol18x18,
97    DmtxSymbol20x20,
98    DmtxSymbol22x22,
99    DmtxSymbol24x24,
100    DmtxSymbol26x26,
101    DmtxSymbol32x32,
102    DmtxSymbol36x36,
103    DmtxSymbol40x40,
104    DmtxSymbol44x44,
105    DmtxSymbol48x48,
106    DmtxSymbol52x52,
107    DmtxSymbol64x64,
108    DmtxSymbol72x72,
109    DmtxSymbol80x80,
110    DmtxSymbol88x88,
111    DmtxSymbol96x96,
112    DmtxSymbol104x104,
113    DmtxSymbol120x120,
114    DmtxSymbol132x132,
115    DmtxSymbol144x144,
116    DmtxSymbol8x18,
117    DmtxSymbol8x32,
118    DmtxSymbol12x26,
119    DmtxSymbol12x36,
120    DmtxSymbol16x36,
121    DmtxSymbol16x48
122 } DmtxSymbolSize;
123 
124 typedef enum {
125    DmtxDirNone               = 0x00,
126    DmtxDirUp                 = 0x01 << 0,
127    DmtxDirLeft               = 0x01 << 1,
128    DmtxDirDown               = 0x01 << 2,
129    DmtxDirRight              = 0x01 << 3,
130    DmtxDirHorizontal         = DmtxDirLeft  | DmtxDirRight,
131    DmtxDirVertical           = DmtxDirUp    | DmtxDirDown,
132    DmtxDirRightUp            = DmtxDirRight | DmtxDirUp,
133    DmtxDirLeftDown           = DmtxDirLeft  | DmtxDirDown
134 } DmtxDirection;
135 
136 typedef enum {
137    DmtxSymAttribSymbolRows,
138    DmtxSymAttribSymbolCols,
139    DmtxSymAttribDataRegionRows,
140    DmtxSymAttribDataRegionCols,
141    DmtxSymAttribHorizDataRegions,
142    DmtxSymAttribVertDataRegions,
143    DmtxSymAttribMappingMatrixRows,
144    DmtxSymAttribMappingMatrixCols,
145    DmtxSymAttribInterleavedBlocks,
146    DmtxSymAttribBlockErrorWords,
147    DmtxSymAttribBlockMaxCorrectable,
148    DmtxSymAttribSymbolDataWords,
149    DmtxSymAttribSymbolErrorWords,
150    DmtxSymAttribSymbolMaxCorrectable
151 } DmtxSymAttribute;
152 
153 typedef enum {
154    DmtxCorner00              = 0x01 << 0,
155    DmtxCorner10              = 0x01 << 1,
156    DmtxCorner11              = 0x01 << 2,
157    DmtxCorner01              = 0x01 << 3
158 } DmtxCornerLoc;
159 
160 typedef enum {
161    /* Encoding properties */
162    DmtxPropScheme            = 100,
163    DmtxPropSizeRequest,
164    DmtxPropMarginSize,
165    DmtxPropModuleSize,
166    DmtxPropFnc1,
167    /* Decoding properties */
168    DmtxPropEdgeMin           = 200,
169    DmtxPropEdgeMax,
170    DmtxPropScanGap,
171    DmtxPropSquareDevn,
172    DmtxPropSymbolSize,
173    DmtxPropEdgeThresh,
174    /* Image properties */
175    DmtxPropWidth             = 300,
176    DmtxPropHeight,
177    DmtxPropPixelPacking,
178    DmtxPropBitsPerPixel,
179    DmtxPropBytesPerPixel,
180    DmtxPropRowPadBytes,
181    DmtxPropRowSizeBytes,
182    DmtxPropImageFlip,
183    DmtxPropChannelCount,
184    /* Image modifiers */
185    DmtxPropXmin              = 400,
186    DmtxPropXmax,
187    DmtxPropYmin,
188    DmtxPropYmax,
189    DmtxPropScale
190 } DmtxProperty;
191 
192 typedef enum {
193    /* Custom format */
194    DmtxPackCustom            = 100,
195    /* 1 bpp */
196    DmtxPack1bppK             = 200,
197    /* 8 bpp grayscale */
198    DmtxPack8bppK             = 300,
199    /* 16 bpp formats */
200    DmtxPack16bppRGB          = 400,
201    DmtxPack16bppRGBX,
202    DmtxPack16bppXRGB,
203    DmtxPack16bppBGR,
204    DmtxPack16bppBGRX,
205    DmtxPack16bppXBGR,
206    DmtxPack16bppYCbCr,
207    /* 24 bpp formats */
208    DmtxPack24bppRGB          = 500,
209    DmtxPack24bppBGR,
210    DmtxPack24bppYCbCr,
211    /* 32 bpp formats */
212    DmtxPack32bppRGBX         = 600,
213    DmtxPack32bppXRGB,
214    DmtxPack32bppBGRX,
215    DmtxPack32bppXBGR,
216    DmtxPack32bppCMYK
217 } DmtxPackOrder;
218 
219 typedef enum {
220   DmtxFlipNone               = 0x00,
221   DmtxFlipX                  = 0x01 << 0,
222   DmtxFlipY                  = 0x01 << 1
223 } DmtxFlip;
224 
225 typedef double DmtxMatrix3[3][3];
226 
227 /**
228  * @struct DmtxPixelLoc
229  * @brief DmtxPixelLoc
230  */
231 typedef struct DmtxPixelLoc_struct {
232    int X;
233    int Y;
234 } DmtxPixelLoc;
235 
236 /**
237  * @struct DmtxVector2
238  * @brief DmtxVector2
239  */
240 typedef struct DmtxVector2_struct {
241    double          X;
242    double          Y;
243 } DmtxVector2;
244 
245 /**
246  * @struct DmtxRay2
247  * @brief DmtxRay2
248  */
249 typedef struct DmtxRay2_struct {
250    double          tMin;
251    double          tMax;
252    DmtxVector2     p;
253    DmtxVector2     v;
254 } DmtxRay2;
255 
256 typedef unsigned char DmtxByte;
257 
258 /**
259  * @struct DmtxByteList
260  * @brief DmtxByteList
261  * Use signed int for length fields instead of size_t to play nicely with RS
262  * arithmetic
263  */
264 typedef struct DmtxByteList_struct DmtxByteList;
265 struct DmtxByteList_struct
266 {
267    int length;
268    int capacity;
269    DmtxByte *b;
270 };
271 
272 typedef struct DmtxEncodeStream_struct DmtxEncodeStream;
273 struct DmtxEncodeStream_struct
274 {
275    int currentScheme;         /* Current encodation scheme */
276    int inputNext;             /* Index of next unprocessed input word in queue */
277    int outputChainValueCount; /* Count of output values pushed within current scheme chain */
278    int outputChainWordCount;  /* Count of output words pushed within current scheme chain */
279    char *reason;              /* Reason for status */
280    int sizeIdx;               /* Symbol size of completed stream */
281    int fnc1;                  /* Character to represent FNC1, or DmtxUndefined */
282    DmtxStatus status;
283    DmtxByteList *input;
284    DmtxByteList *output;
285 };
286 
287 /**
288  * @struct DmtxImage
289  * @brief DmtxImage
290  */
291 typedef struct DmtxImage_struct {
292    int             width;
293    int             height;
294    int             pixelPacking;
295    int             bitsPerPixel;
296    int             bytesPerPixel;
297    int             rowPadBytes;
298    int             rowSizeBytes;
299    int             imageFlip;
300    int             channelCount;
301    int             channelStart[4];
302    int             bitsPerChannel[4];
303    unsigned char  *pxl;
304 } DmtxImage;
305 
306 /**
307  * @struct DmtxPointFlow
308  * @brief DmtxPointFlow
309  */
310 typedef struct DmtxPointFlow_struct {
311    int             plane;
312    int             arrive;
313    int             depart;
314    int             mag;
315    DmtxPixelLoc    loc;
316 } DmtxPointFlow;
317 
318 /**
319  * @struct DmtxBestLine
320  * @brief DmtxBestLine
321  */
322 typedef struct DmtxBestLine_struct {
323    int             angle;
324    int             hOffset;
325    int             mag;
326    int             stepBeg;
327    int             stepPos;
328    int             stepNeg;
329    int             distSq;
330    double          devn;
331    DmtxPixelLoc    locBeg;
332    DmtxPixelLoc    locPos;
333    DmtxPixelLoc    locNeg;
334 } DmtxBestLine;
335 
336 /**
337  * @struct DmtxRegion
338  * @brief DmtxRegion
339  */
340 typedef struct DmtxRegion_struct {
341 
342    /* Trail blazing values */
343    int             jumpToPos;     /* */
344    int             jumpToNeg;     /* */
345    int             stepsTotal;    /* */
346    DmtxPixelLoc    finalPos;      /* */
347    DmtxPixelLoc    finalNeg;      /* */
348    DmtxPixelLoc    boundMin;      /* */
349    DmtxPixelLoc    boundMax;      /* */
350    DmtxPointFlow   flowBegin;     /* */
351 
352    /* Orientation values */
353    int             polarity;      /* */
354    int             stepR;
355    int             stepT;
356    DmtxPixelLoc    locR;          /* remove if stepR works above */
357    DmtxPixelLoc    locT;          /* remove if stepT works above */
358 
359    /* Region fitting values */
360    int             leftKnown;     /* known == 1; unknown == 0 */
361    int             leftAngle;     /* hough angle of left edge */
362    DmtxPixelLoc    leftLoc;       /* known (arbitrary) location on left edge */
363    DmtxBestLine    leftLine;      /* */
364    int             bottomKnown;   /* known == 1; unknown == 0 */
365    int             bottomAngle;   /* hough angle of bottom edge */
366    DmtxPixelLoc    bottomLoc;     /* known (arbitrary) location on bottom edge */
367    DmtxBestLine    bottomLine;    /* */
368    int             topKnown;      /* known == 1; unknown == 0 */
369    int             topAngle;      /* hough angle of top edge */
370    DmtxPixelLoc    topLoc;        /* known (arbitrary) location on top edge */
371    int             rightKnown;    /* known == 1; unknown == 0 */
372    int             rightAngle;    /* hough angle of right edge */
373    DmtxPixelLoc    rightLoc;      /* known (arbitrary) location on right edge */
374 
375    /* Region calibration values */
376    int             onColor;       /* */
377    int             offColor;      /* */
378    int             sizeIdx;       /* Index of arrays that store Data Matrix constants */
379    int             symbolRows;    /* Number of total rows in symbol including alignment patterns */
380    int             symbolCols;    /* Number of total columns in symbol including alignment patterns */
381    int             mappingRows;   /* Number of data rows in symbol */
382    int             mappingCols;   /* Number of data columns in symbol */
383 
384    /* Transform values */
385    DmtxMatrix3     raw2fit;       /* 3x3 transformation from raw image to fitted barcode grid */
386    DmtxMatrix3     fit2raw;       /* 3x3 transformation from fitted barcode grid to raw image */
387 } DmtxRegion;
388 
389 /**
390  * @struct DmtxMessage
391  * @brief DmtxMessage
392  */
393 typedef struct DmtxMessage_struct {
394    size_t          arraySize;     /* mappingRows * mappingCols */
395    size_t          codeSize;      /* Size of encoded data (data words + error words) */
396    size_t          outputSize;    /* Size of buffer used to hold decoded data */
397    int             outputIdx;     /* Internal index used to store output progress */
398    int             padCount;
399    int             fnc1;          /* Character to represent FNC1, or DmtxUndefined */
400    unsigned char  *array;         /* Pointer to internal representation of Data Matrix modules */
401    unsigned char  *code;          /* Pointer to internal storage of code words (data and error) */
402    unsigned char  *output;        /* Pointer to internal storage of decoded output */
403 } DmtxMessage;
404 
405 /**
406  * @struct DmtxScanGrid
407  * @brief DmtxScanGrid
408  */
409 typedef struct DmtxScanGrid_struct {
410    /* set once */
411    int             minExtent;     /* Smallest cross size used in scan */
412    int             maxExtent;     /* Size of bounding grid region (2^N - 1) */
413    int             xOffset;       /* Offset to obtain image X coordinate */
414    int             yOffset;       /* Offset to obtain image Y coordinate */
415    int             xMin;          /* Minimum X in image coordinate system */
416    int             xMax;          /* Maximum X in image coordinate system */
417    int             yMin;          /* Minimum Y in image coordinate system */
418    int             yMax;          /* Maximum Y in image coordinate system */
419 
420    /* reset for each level */
421    int             total;         /* Total number of crosses at this size */
422    int             extent;        /* Length/width of cross in pixels */
423    int             jumpSize;      /* Distance in pixels between cross centers */
424    int             pixelTotal;    /* Total pixel count within an individual cross path */
425    int             startPos;      /* X and Y coordinate of first cross center in pattern */
426 
427    /* reset for each cross */
428    int             pixelCount;    /* Progress (pixel count) within current cross pattern */
429    int             xCenter;       /* X center of current cross pattern */
430    int             yCenter;       /* Y center of current cross pattern */
431 } DmtxScanGrid;
432 
433 /**
434  * @struct DmtxTime
435  * @brief DmtxTime
436  */
437 typedef struct DmtxTime_struct {
438    time_t          sec;
439    unsigned long   usec;
440 } DmtxTime;
441 
442 /**
443  * @struct DmtxDecode
444  * @brief DmtxDecode
445  */
446 typedef struct DmtxDecode_struct {
447    /* Options */
448    int             edgeMin;
449    int             edgeMax;
450    int             scanGap;
451    int             fnc1;
452    double          squareDevn;
453    int             sizeIdxExpected;
454    int             edgeThresh;
455 
456    /* Image modifiers */
457    int             xMin;
458    int             xMax;
459    int             yMin;
460    int             yMax;
461    int             scale;
462 
463    /* Internals */
464 /* int             cacheComplete; */
465    unsigned char  *cache;
466    DmtxImage      *image;
467    DmtxScanGrid    grid;
468 } DmtxDecode;
469 
470 /**
471  * @struct DmtxEncode
472  * @brief DmtxEncode
473  */
474 typedef struct DmtxEncode_struct {
475    int             method;
476    int             scheme;
477    int             sizeIdxRequest;
478    int             marginSize;
479    int             moduleSize;
480    int             pixelPacking;
481    int             imageFlip;
482    int             rowPadBytes;
483    int             fnc1;
484    DmtxMessage    *message;
485    DmtxImage      *image;
486    DmtxRegion      region;
487    DmtxMatrix3     xfrm;  /* XXX still necessary? */
488    DmtxMatrix3     rxfrm; /* XXX still necessary? */
489 } DmtxEncode;
490 
491 /**
492  * @struct DmtxChannel
493  * @brief DmtxChannel
494  */
495 typedef struct DmtxChannel_struct {
496    int             encScheme;     /* current encodation scheme */
497    int             invalid;       /* channel status (invalid if non-zero) */
498    unsigned char  *inputPtr;      /* pointer to current input character */
499    unsigned char  *inputStop;     /* pointer to position after final input character */
500    int             encodedLength; /* encoded length (units of 2/3 bits) */
501    int             currentLength; /* current length (units of 2/3 bits) */
502    int             firstCodeWord; /* */
503    unsigned char   encodedWords[1558];
504 } DmtxChannel;
505 
506 /* Wrap in a struct for fast copies */
507 /**
508  * @struct DmtxChannelGroup
509  * @brief DmtxChannelGroup
510  */
511 typedef struct DmtxChannelGroup_struct {
512    DmtxChannel channel[6];
513 } DmtxChannelGroup;
514 
515 /**
516  * @struct DmtxTriplet
517  * @brief DmtxTriplet
518  */
519 typedef struct DmtxTriplet_struct {
520    unsigned char   value[3];
521 } DmtxTriplet;
522 
523 /**
524  * @struct DmtxQuadruplet
525  * @brief DmtxQuadruplet
526  */
527 typedef struct DmtxQuadruplet_struct {
528    unsigned char   value[4];
529 } DmtxQuadruplet;
530 
531 /* dmtxtime.c */
532 extern DmtxTime dmtxTimeNow(void);
533 extern DmtxTime dmtxTimeAdd(DmtxTime t, long msec);
534 extern int dmtxTimeExceeded(DmtxTime timeout);
535 
536 /* dmtxencode.c */
537 extern DmtxEncode *dmtxEncodeCreate(void);
538 extern DmtxPassFail dmtxEncodeDestroy(DmtxEncode **enc);
539 extern DmtxPassFail dmtxEncodeSetProp(DmtxEncode *enc, int prop, int value);
540 extern int dmtxEncodeGetProp(DmtxEncode *enc, int prop);
541 extern DmtxPassFail dmtxEncodeDataMatrix(DmtxEncode *enc, int n, unsigned char *s);
542 extern DmtxPassFail dmtxEncodeDataMosaic(DmtxEncode *enc, int n, unsigned char *s);
543 
544 /* dmtxdecode.c */
545 extern DmtxDecode *dmtxDecodeCreate(DmtxImage *img, int scale);
546 extern DmtxPassFail dmtxDecodeDestroy(DmtxDecode **dec);
547 extern DmtxPassFail dmtxDecodeSetProp(DmtxDecode *dec, int prop, int value);
548 extern int dmtxDecodeGetProp(DmtxDecode *dec, int prop);
549 extern /*@exposed@*/ unsigned char *dmtxDecodeGetCache(DmtxDecode *dec, int x, int y);
550 extern DmtxPassFail dmtxDecodeGetPixelValue(DmtxDecode *dec, int x, int y, int channel, /*@out@*/ int *value);
551 extern DmtxMessage *dmtxDecodeMatrixRegion(DmtxDecode *dec, DmtxRegion *reg, int fix);
552 extern DmtxMessage *dmtxDecodePopulatedArray(int sizeIdx, DmtxMessage *msg, int fix);
553 extern DmtxMessage *dmtxDecodeMosaicRegion(DmtxDecode *dec, DmtxRegion *reg, int fix);
554 extern unsigned char *dmtxDecodeCreateDiagnostic(DmtxDecode *dec, /*@out@*/ int *totalBytes, /*@out@*/ int *headerBytes, int style);
555 
556 /* dmtxregion.c */
557 extern DmtxRegion *dmtxRegionCreate(DmtxRegion *reg);
558 extern DmtxPassFail dmtxRegionDestroy(DmtxRegion **reg);
559 extern DmtxRegion *dmtxRegionFindNext(DmtxDecode *dec, DmtxTime *timeout);
560 extern DmtxRegion *dmtxRegionScanPixel(DmtxDecode *dec, int x, int y);
561 extern DmtxPassFail dmtxRegionUpdateCorners(DmtxDecode *dec, DmtxRegion *reg, DmtxVector2 p00,
562       DmtxVector2 p10, DmtxVector2 p11, DmtxVector2 p01);
563 extern DmtxPassFail dmtxRegionUpdateXfrms(DmtxDecode *dec, DmtxRegion *reg);
564 
565 /* dmtxmessage.c */
566 extern DmtxMessage *dmtxMessageCreate(int sizeIdx, int symbolFormat);
567 extern DmtxPassFail dmtxMessageDestroy(DmtxMessage **msg);
568 
569 /* dmtximage.c */
570 extern DmtxImage *dmtxImageCreate(unsigned char *pxl, int width, int height, int pack);
571 extern DmtxPassFail dmtxImageDestroy(DmtxImage **img);
572 extern DmtxPassFail dmtxImageSetChannel(DmtxImage *img, int channelStart, int bitsPerChannel);
573 extern DmtxPassFail dmtxImageSetProp(DmtxImage *img, int prop, int value);
574 extern int dmtxImageGetProp(DmtxImage *img, int prop);
575 extern int dmtxImageGetByteOffset(DmtxImage *img, int x, int y);
576 extern DmtxPassFail dmtxImageGetPixelValue(DmtxImage *img, int x, int y, int channel, /*@out@*/ int *value);
577 extern DmtxPassFail dmtxImageSetPixelValue(DmtxImage *img, int x, int y, int channel, int value);
578 extern DmtxBoolean dmtxImageContainsInt(DmtxImage *img, int margin, int x, int y);
579 extern DmtxBoolean dmtxImageContainsFloat(DmtxImage *img, double x, double y);
580 
581 /* dmtxvector2.c */
582 extern DmtxVector2 *dmtxVector2AddTo(DmtxVector2 *v1, const DmtxVector2 *v2);
583 extern DmtxVector2 *dmtxVector2Add(/*@out@*/ DmtxVector2 *vOut, const DmtxVector2 *v1, const DmtxVector2 *v2);
584 extern DmtxVector2 *dmtxVector2SubFrom(DmtxVector2 *v1, const DmtxVector2 *v2);
585 extern DmtxVector2 *dmtxVector2Sub(/*@out@*/ DmtxVector2 *vOut, const DmtxVector2 *v1, const DmtxVector2 *v2);
586 extern DmtxVector2 *dmtxVector2ScaleBy(DmtxVector2 *v, double s);
587 extern DmtxVector2 *dmtxVector2Scale(/*@out@*/ DmtxVector2 *vOut, const DmtxVector2 *v, double s);
588 extern double dmtxVector2Cross(const DmtxVector2 *v1, const DmtxVector2 *v2);
589 extern double dmtxVector2Norm(DmtxVector2 *v);
590 extern double dmtxVector2Dot(const DmtxVector2 *v1, const DmtxVector2 *v2);
591 extern double dmtxVector2Mag(const DmtxVector2 *v);
592 extern double dmtxDistanceFromRay2(const DmtxRay2 *r, const DmtxVector2 *q);
593 extern double dmtxDistanceAlongRay2(const DmtxRay2 *r, const DmtxVector2 *q);
594 extern DmtxPassFail dmtxRay2Intersect(/*@out@*/ DmtxVector2 *point, const DmtxRay2 *p0, const DmtxRay2 *p1);
595 extern DmtxPassFail dmtxPointAlongRay2(/*@out@*/ DmtxVector2 *point, const DmtxRay2 *r, double t);
596 
597 /* dmtxmatrix3.c */
598 extern void dmtxMatrix3Copy(/*@out@*/ DmtxMatrix3 m0, DmtxMatrix3 m1);
599 extern void dmtxMatrix3Identity(/*@out@*/ DmtxMatrix3 m);
600 extern void dmtxMatrix3Translate(/*@out@*/ DmtxMatrix3 m, double tx, double ty);
601 extern void dmtxMatrix3Rotate(/*@out@*/ DmtxMatrix3 m, double angle);
602 extern void dmtxMatrix3Scale(/*@out@*/ DmtxMatrix3 m, double sx, double sy);
603 extern void dmtxMatrix3Shear(/*@out@*/ DmtxMatrix3 m, double shx, double shy);
604 extern void dmtxMatrix3LineSkewTop(/*@out@*/ DmtxMatrix3 m, double b0, double b1, double sz);
605 extern void dmtxMatrix3LineSkewTopInv(/*@out@*/ DmtxMatrix3 m, double b0, double b1, double sz);
606 extern void dmtxMatrix3LineSkewSide(/*@out@*/ DmtxMatrix3 m, double b0, double b1, double sz);
607 extern void dmtxMatrix3LineSkewSideInv(/*@out@*/ DmtxMatrix3 m, double b0, double b1, double sz);
608 extern void dmtxMatrix3Multiply(/*@out@*/ DmtxMatrix3 mOut, DmtxMatrix3 m0, DmtxMatrix3 m1);
609 extern void dmtxMatrix3MultiplyBy(DmtxMatrix3 m0, DmtxMatrix3 m1);
610 extern int dmtxMatrix3VMultiply(/*@out@*/ DmtxVector2 *vOut, DmtxVector2 *vIn, DmtxMatrix3 m);
611 extern int dmtxMatrix3VMultiplyBy(DmtxVector2 *v, DmtxMatrix3 m);
612 extern void dmtxMatrix3Print(DmtxMatrix3 m);
613 
614 /* dmtxsymbol.c */
615 extern int dmtxSymbolModuleStatus(DmtxMessage *mapping, int sizeIdx, int row, int col);
616 extern int dmtxGetSymbolAttribute(int attribute, int sizeIdx);
617 extern int dmtxGetBlockDataSize(int sizeIdx, int blockIdx);
618 extern int getSizeIdxFromSymbolDimension(int rows, int cols);
619 
620 /* dmtxbytelist.c */
621 extern DmtxByteList dmtxByteListBuild(DmtxByte *storage, int capacity);
622 extern void dmtxByteListInit(DmtxByteList *list, int length, DmtxByte value, DmtxPassFail *passFail);
623 extern void dmtxByteListClear(DmtxByteList *list);
624 extern DmtxBoolean dmtxByteListHasCapacity(DmtxByteList *list);
625 extern void dmtxByteListCopy(DmtxByteList *dst, const DmtxByteList *src, DmtxPassFail *passFail);
626 extern void dmtxByteListPush(DmtxByteList *list, DmtxByte value, DmtxPassFail *passFail);
627 extern DmtxByte dmtxByteListPop(DmtxByteList *list, DmtxPassFail *passFail);
628 extern void dmtxByteListPrint(DmtxByteList *list, char *prefix);
629 
630 extern char *dmtxVersion(void);
631 
632 #ifdef __cplusplus
633 }
634 #endif
635 
636 #endif
637