dmtx.h | dmtx.h | |||
---|---|---|---|---|
/* | ||||
libdmtx - Data Matrix Encoding/Decoding Library | ||||
Copyright (C) 2008, 2009 Mike Laughton | ||||
This library is free software; you can redistribute it and/or | ||||
modify it under the terms of the GNU Lesser General Public | ||||
License as published by the Free Software Foundation; either | ||||
version 2.1 of the License, or (at your option) any later version. | ||||
This library is distributed in the hope that it will be useful, | ||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
Lesser General Public License for more details. | ||||
You should have received a copy of the GNU Lesser General Public | ||||
License along with this library; if not, write to the Free Software | ||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||||
Contact: mike@dragonflylogic.com | ||||
*/ | ||||
/* $Id: dmtx.h 864 2009-09-03 20:08:29Z mblaughton $ */ | ||||
/** | /** | |||
* @file dmtx.h | * libdmtx - Data Matrix Encoding/Decoding Library | |||
* @brief Main libdmtx header | * Copyright 2008, 2009 Mike Laughton. All rights reserved. | |||
* | ||||
* See LICENSE file in the main project directory for full | ||||
* terms of use and distribution. | ||||
* | ||||
* Contact: Mike Laughton <mike@dragonflylogic.com> | ||||
* | ||||
* \file dmtx.h | ||||
* \brief Main libdmtx header | ||||
*/ | */ | |||
#ifndef __DMTX_H__ | #ifndef __DMTX_H__ | |||
#define __DMTX_H__ | #define __DMTX_H__ | |||
#ifdef __cplusplus | #ifdef __cplusplus | |||
extern "C" { | extern "C" { | |||
#endif | #endif | |||
/* Time headers required for DmtxTime struct below */ | /* Time headers required for DmtxTime struct below */ | |||
skipping to change at line 51 | skipping to change at line 35 | |||
#endif | #endif | |||
#ifndef M_PI | #ifndef M_PI | |||
#define M_PI 3.14159265358979323846 | #define M_PI 3.14159265358979323846 | |||
#endif | #endif | |||
#ifndef M_PI_2 | #ifndef M_PI_2 | |||
#define M_PI_2 1.57079632679489661923 | #define M_PI_2 1.57079632679489661923 | |||
#endif | #endif | |||
#define DmtxVersion "0.7.2" | #define DmtxVersion "0.7.4" | |||
#define DmtxUndefined -1 | #define DmtxUndefined -1 | |||
#define DmtxPassFail unsigned int | #define DmtxPassFail unsigned int | |||
#define DmtxPass 1 | #define DmtxPass 1 | |||
#define DmtxFail 0 | #define DmtxFail 0 | |||
#define DmtxBoolean unsigned int | #define DmtxBoolean unsigned int | |||
#define DmtxTrue 1 | #define DmtxTrue 1 | |||
#define DmtxFalse 0 | #define DmtxFalse 0 | |||
skipping to change at line 80 | skipping to change at line 64 | |||
#define DmtxModuleOnRed 0x01 | #define DmtxModuleOnRed 0x01 | |||
#define DmtxModuleOnGreen 0x02 | #define DmtxModuleOnGreen 0x02 | |||
#define DmtxModuleOnBlue 0x04 | #define DmtxModuleOnBlue 0x04 | |||
#define DmtxModuleOnRGB 0x07 /* OnRed | OnGreen | OnBlue */ | #define DmtxModuleOnRGB 0x07 /* OnRed | OnGreen | OnBlue */ | |||
#define DmtxModuleOn 0x07 | #define DmtxModuleOn 0x07 | |||
#define DmtxModuleUnsure 0x08 | #define DmtxModuleUnsure 0x08 | |||
#define DmtxModuleAssigned 0x10 | #define DmtxModuleAssigned 0x10 | |||
#define DmtxModuleVisited 0x20 | #define DmtxModuleVisited 0x20 | |||
#define DmtxModuleData 0x40 | #define DmtxModuleData 0x40 | |||
#define DMTX_CHECK_BOUNDS(l,i) (assert((i) >= 0 && (i) < (l)->length && (l) | ||||
->length <= (l)->capacity)) | ||||
typedef enum { | ||||
DmtxStatusEncoding, /* Encoding is currently underway */ | ||||
DmtxStatusComplete, /* Encoding is done and everything went well */ | ||||
DmtxStatusInvalid, /* Something bad happened that sometimes happens */ | ||||
DmtxStatusFatal /* Something happened that should never happen */ | ||||
} DmtxStatus; | ||||
typedef enum { | typedef enum { | |||
DmtxSchemeAutoFast = -2, | DmtxSchemeAutoFast = -2, | |||
DmtxSchemeAutoBest = -1, | DmtxSchemeAutoBest = -1, | |||
DmtxSchemeAscii = 0, | DmtxSchemeAscii = 0, | |||
DmtxSchemeC40, | DmtxSchemeC40, | |||
DmtxSchemeText, | DmtxSchemeText, | |||
DmtxSchemeX12, | DmtxSchemeX12, | |||
DmtxSchemeEdifact, | DmtxSchemeEdifact, | |||
DmtxSchemeBase256 | DmtxSchemeBase256 | |||
} DmtxScheme; | } DmtxScheme; | |||
skipping to change at line 258 | skipping to change at line 251 | |||
* @struct DmtxRay2 | * @struct DmtxRay2 | |||
* @brief DmtxRay2 | * @brief DmtxRay2 | |||
*/ | */ | |||
typedef struct DmtxRay2_struct { | typedef struct DmtxRay2_struct { | |||
double tMin; | double tMin; | |||
double tMax; | double tMax; | |||
DmtxVector2 p; | DmtxVector2 p; | |||
DmtxVector2 v; | DmtxVector2 v; | |||
} DmtxRay2; | } DmtxRay2; | |||
typedef unsigned char DmtxByte; | ||||
/** | ||||
* @struct DmtxByteList | ||||
* @brief DmtxByteList | ||||
* Use signed int for length fields instead of size_t to play nicely with R | ||||
S | ||||
* arithmetic | ||||
*/ | ||||
typedef struct DmtxByteList_struct DmtxByteList; | ||||
struct DmtxByteList_struct | ||||
{ | ||||
int length; | ||||
int capacity; | ||||
DmtxByte *b; | ||||
}; | ||||
typedef struct DmtxEncodeStream_struct DmtxEncodeStream; | ||||
struct DmtxEncodeStream_struct | ||||
{ | ||||
int currentScheme; /* Current encodation scheme */ | ||||
int inputNext; /* Index of next unprocessed input word in qu | ||||
eue */ | ||||
int outputChainValueCount; /* Count of output values pushed within curre | ||||
nt scheme chain */ | ||||
int outputChainWordCount; /* Count of output words pushed within curren | ||||
t scheme chain */ | ||||
char *reason; /* Reason for status */ | ||||
int sizeIdx; /* Symbol size of completed stream */ | ||||
DmtxStatus status; | ||||
DmtxByteList *input; | ||||
DmtxByteList *output; | ||||
}; | ||||
/** | /** | |||
* @struct DmtxImage | * @struct DmtxImage | |||
* @brief DmtxImage | * @brief DmtxImage | |||
*/ | */ | |||
typedef struct DmtxImage_struct { | typedef struct DmtxImage_struct { | |||
int width; | int width; | |||
int height; | int height; | |||
int pixelPacking; | int pixelPacking; | |||
int bitsPerPixel; | int bitsPerPixel; | |||
int bytesPerPixel; | int bytesPerPixel; | |||
skipping to change at line 561 | skipping to change at line 584 | |||
extern DmtxVector2 *dmtxVector2SubFrom(DmtxVector2 *v1, const DmtxVector2 * v2); | extern DmtxVector2 *dmtxVector2SubFrom(DmtxVector2 *v1, const DmtxVector2 * v2); | |||
extern DmtxVector2 *dmtxVector2Sub(/*@out@*/ DmtxVector2 *vOut, const DmtxV ector2 *v1, const DmtxVector2 *v2); | extern DmtxVector2 *dmtxVector2Sub(/*@out@*/ DmtxVector2 *vOut, const DmtxV ector2 *v1, const DmtxVector2 *v2); | |||
extern DmtxVector2 *dmtxVector2ScaleBy(DmtxVector2 *v, double s); | extern DmtxVector2 *dmtxVector2ScaleBy(DmtxVector2 *v, double s); | |||
extern DmtxVector2 *dmtxVector2Scale(/*@out@*/ DmtxVector2 *vOut, const Dmt xVector2 *v, double s); | extern DmtxVector2 *dmtxVector2Scale(/*@out@*/ DmtxVector2 *vOut, const Dmt xVector2 *v, double s); | |||
extern double dmtxVector2Cross(const DmtxVector2 *v1, const DmtxVector2 *v2 ); | extern double dmtxVector2Cross(const DmtxVector2 *v1, const DmtxVector2 *v2 ); | |||
extern double dmtxVector2Norm(DmtxVector2 *v); | extern double dmtxVector2Norm(DmtxVector2 *v); | |||
extern double dmtxVector2Dot(const DmtxVector2 *v1, const DmtxVector2 *v2); | extern double dmtxVector2Dot(const DmtxVector2 *v1, const DmtxVector2 *v2); | |||
extern double dmtxVector2Mag(const DmtxVector2 *v); | extern double dmtxVector2Mag(const DmtxVector2 *v); | |||
extern double dmtxDistanceFromRay2(const DmtxRay2 *r, const DmtxVector2 *q) ; | extern double dmtxDistanceFromRay2(const DmtxRay2 *r, const DmtxVector2 *q) ; | |||
extern double dmtxDistanceAlongRay2(const DmtxRay2 *r, const DmtxVector2 *q ); | extern double dmtxDistanceAlongRay2(const DmtxRay2 *r, const DmtxVector2 *q ); | |||
extern int dmtxRay2Intersect(/*@out@*/ DmtxVector2 *point, const DmtxRay2 * p0, const DmtxRay2 *p1); | extern DmtxPassFail dmtxRay2Intersect(/*@out@*/ DmtxVector2 *point, const D mtxRay2 *p0, const DmtxRay2 *p1); | |||
extern DmtxPassFail dmtxPointAlongRay2(/*@out@*/ DmtxVector2 *point, const DmtxRay2 *r, double t); | extern DmtxPassFail dmtxPointAlongRay2(/*@out@*/ DmtxVector2 *point, const DmtxRay2 *r, double t); | |||
/* dmtxmatrix3.c */ | /* dmtxmatrix3.c */ | |||
extern void dmtxMatrix3Copy(/*@out@*/ DmtxMatrix3 m0, DmtxMatrix3 m1); | extern void dmtxMatrix3Copy(/*@out@*/ DmtxMatrix3 m0, DmtxMatrix3 m1); | |||
extern void dmtxMatrix3Identity(/*@out@*/ DmtxMatrix3 m); | extern void dmtxMatrix3Identity(/*@out@*/ DmtxMatrix3 m); | |||
extern void dmtxMatrix3Translate(/*@out@*/ DmtxMatrix3 m, double tx, double ty); | extern void dmtxMatrix3Translate(/*@out@*/ DmtxMatrix3 m, double tx, double ty); | |||
extern void dmtxMatrix3Rotate(/*@out@*/ DmtxMatrix3 m, double angle); | extern void dmtxMatrix3Rotate(/*@out@*/ DmtxMatrix3 m, double angle); | |||
extern void dmtxMatrix3Scale(/*@out@*/ DmtxMatrix3 m, double sx, double sy) ; | extern void dmtxMatrix3Scale(/*@out@*/ DmtxMatrix3 m, double sx, double sy) ; | |||
extern void dmtxMatrix3Shear(/*@out@*/ DmtxMatrix3 m, double shx, double sh y); | extern void dmtxMatrix3Shear(/*@out@*/ DmtxMatrix3 m, double shx, double sh y); | |||
extern void dmtxMatrix3LineSkewTop(/*@out@*/ DmtxMatrix3 m, double b0, doub le b1, double sz); | extern void dmtxMatrix3LineSkewTop(/*@out@*/ DmtxMatrix3 m, double b0, doub le b1, double sz); | |||
skipping to change at line 586 | skipping to change at line 609 | |||
extern void dmtxMatrix3MultiplyBy(DmtxMatrix3 m0, DmtxMatrix3 m1); | extern void dmtxMatrix3MultiplyBy(DmtxMatrix3 m0, DmtxMatrix3 m1); | |||
extern int dmtxMatrix3VMultiply(/*@out@*/ DmtxVector2 *vOut, DmtxVector2 *v In, DmtxMatrix3 m); | extern int dmtxMatrix3VMultiply(/*@out@*/ DmtxVector2 *vOut, DmtxVector2 *v In, DmtxMatrix3 m); | |||
extern int dmtxMatrix3VMultiplyBy(DmtxVector2 *v, DmtxMatrix3 m); | extern int dmtxMatrix3VMultiplyBy(DmtxVector2 *v, DmtxMatrix3 m); | |||
extern void dmtxMatrix3Print(DmtxMatrix3 m); | extern void dmtxMatrix3Print(DmtxMatrix3 m); | |||
/* dmtxsymbol.c */ | /* dmtxsymbol.c */ | |||
extern int dmtxSymbolModuleStatus(DmtxMessage *mapping, int sizeIdx, int ro w, int col); | extern int dmtxSymbolModuleStatus(DmtxMessage *mapping, int sizeIdx, int ro w, int col); | |||
extern int dmtxGetSymbolAttribute(int attribute, int sizeIdx); | extern int dmtxGetSymbolAttribute(int attribute, int sizeIdx); | |||
extern int dmtxGetBlockDataSize(int sizeIdx, int blockIdx); | extern int dmtxGetBlockDataSize(int sizeIdx, int blockIdx); | |||
/* dmtxbytelist.c */ | ||||
extern DmtxByteList dmtxByteListBuild(DmtxByte *storage, int capacity); | ||||
extern void dmtxByteListInit(DmtxByteList *list, int length, DmtxByte value | ||||
, DmtxPassFail *passFail); | ||||
extern void dmtxByteListClear(DmtxByteList *list); | ||||
extern DmtxBoolean dmtxByteListHasCapacity(DmtxByteList *list); | ||||
extern void dmtxByteListCopy(DmtxByteList *dst, const DmtxByteList *src, Dm | ||||
txPassFail *passFail); | ||||
extern void dmtxByteListPush(DmtxByteList *list, DmtxByte value, DmtxPassFa | ||||
il *passFail); | ||||
extern DmtxByte dmtxByteListPop(DmtxByteList *list, DmtxPassFail *passFail) | ||||
; | ||||
extern void dmtxByteListPrint(DmtxByteList *list, char *prefix); | ||||
extern char *dmtxVersion(void); | extern char *dmtxVersion(void); | |||
#ifdef __cplusplus | #ifdef __cplusplus | |||
} | } | |||
#endif | #endif | |||
#endif | #endif | |||
End of changes. 7 change blocks. | ||||
28 lines changed or deleted | 70 lines changed or added | |||