📄 dmtxstatic.h
字号:
/*libdmtx - Data Matrix Encoding/Decoding LibraryCopyright (c) 2008 Mike LaughtonThis library is free software; you can redistribute it and/ormodify it under the terms of the GNU Lesser General PublicLicense as published by the Free Software Foundation; eitherversion 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 ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNULesser General Public License for more details.You should have received a copy of the GNU Lesser General PublicLicense along with this library; if not, write to the Free SoftwareFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USAContact: mike@dragonflylogic.com*//* $Id: dmtxstatic.h 514 2008-11-19 17:10:44Z mblaughton $ *//** * @file dmtxstatic.h * @brief Static header */#ifndef __DMTXSTATIC_H__#define __DMTXSTATIC_H__#define DMTX_ALMOST_ZERO 0.000001#define DMTX_ALMOST_INFINITY -1#define DMTX_RANGE_GOOD 0#define DMTX_RANGE_BAD 1#define DMTX_RANGE_EOF 2#undef min#define min(X,Y) (((X) < (Y)) ? (X) : (Y))#undef max#define max(X,Y) (((X) > (Y)) ? (X) : (Y))typedef enum { DmtxEdgeTop = 0x01 << 0, DmtxEdgeBottom = 0x01 << 1, DmtxEdgeLeft = 0x01 << 2, DmtxEdgeRight = 0x01 << 3} DmtxEdgeLoc;typedef enum { DmtxMaskBit1 = 0x01 << 7, DmtxMaskBit2 = 0x01 << 6, DmtxMaskBit3 = 0x01 << 5, DmtxMaskBit4 = 0x01 << 4, DmtxMaskBit5 = 0x01 << 3, DmtxMaskBit6 = 0x01 << 2, DmtxMaskBit7 = 0x01 << 1, DmtxMaskBit8 = 0x01 << 0} DmtxBitMask;/** * @struct DmtxFollow * @brief DmtxFollow */typedef struct DmtxFollow_struct { unsigned char *ptr; unsigned char neighbor; int step; DmtxPixelLoc loc;} DmtxFollow;/** * @struct DmtxBresLine * @brief DmtxBresLine */typedef struct DmtxBresLine_struct { int xStep; int yStep; int xDelta; int yDelta; int steep; int xOut; int yOut; int travel; int outward; int error; DmtxPixelLoc loc; DmtxPixelLoc loc0; DmtxPixelLoc loc1;} DmtxBresLine;/* dmtxregion.c */static double RightAngleTrueness(DmtxVector2 c0, DmtxVector2 c1, DmtxVector2 c2, double angle);static DmtxPointFlow MatrixRegionSeekEdge(DmtxDecode *dec, DmtxPixelLoc loc0);static int MatrixRegionOrientation(DmtxDecode *dec, DmtxRegion *reg, DmtxPointFlow flowBegin);static long DistanceSquared(DmtxPixelLoc a, DmtxPixelLoc b);static unsigned char *GetCacheAddress(DmtxDecode *dec, int x, int y);static int ReadModuleColor(DmtxImage *image, DmtxRegion *region, int symbolRow, int symbolCol, int sizeIdx);static int MatrixRegionFindSize(DmtxDecode *dec, DmtxRegion *reg);static int CountJumpTally(DmtxImage *img, DmtxRegion *reg, int xStart, int yStart, DmtxDirection dir);static DmtxPointFlow GetPointFlow(DmtxDecode *dec, int colorPlane, DmtxPixelLoc loc, int arrive);static DmtxPointFlow FindStrongestNeighbor(DmtxDecode *dec, DmtxPointFlow center, int sign);static DmtxFollow FollowSeek(DmtxDecode *dec, DmtxRegion *reg, int seek);static DmtxFollow FollowSeekLoc(DmtxDecode *dec, DmtxPixelLoc loc);static DmtxFollow FollowStep(DmtxDecode *dec, DmtxRegion *reg, DmtxFollow followBeg, int sign);static DmtxFollow FollowStep2(DmtxDecode *dec, DmtxRegion *reg, DmtxFollow followBeg, int sign);static int TrailBlazeContinuous(DmtxDecode *dec, DmtxRegion *reg, DmtxPointFlow flowBegin, int maxDiagonal);static int TrailBlazeGapped(DmtxDecode *dec, DmtxRegion *reg, DmtxBresLine line, int streamDir);static int TrailClear(DmtxDecode *dec, DmtxRegion *reg, int clearMask);static DmtxBestLine FindBestSolidLine(DmtxDecode *dec, DmtxRegion *reg, int step0, int step1, int streamDir, int houghAvoid);static DmtxBestLine FindBestSolidLine2(DmtxDecode *dec, DmtxRegion *reg, DmtxPixelLoc loc0, int tripSteps, int sign, int houghAvoid);static int FindTravelLimits(DmtxDecode *dec, DmtxRegion *reg, DmtxBestLine *line);static int MatrixRegionAlignCalibEdge(DmtxDecode *dec, DmtxRegion *reg, int whichEdge);static DmtxBresLine BresLineInit(DmtxPixelLoc loc0, DmtxPixelLoc loc1, DmtxPixelLoc locInside);static int BresLineGetStep(DmtxBresLine line, DmtxPixelLoc target, int *travel, int *outward);static int BresLineStep(DmtxBresLine *line, int travel, int outward);/*static void WriteDiagnosticImage(DmtxDecode *dec, DmtxRegion *reg, char *imagePath);*//* dmtxdecode.c */static void DecodeDataStream(DmtxMessage *message, int sizeIdx, unsigned char *outputStart);static unsigned char *NextEncodationScheme(DmtxSchemeDecode *encScheme, unsigned char *ptr);static unsigned char *DecodeSchemeAsciiStd(DmtxMessage *message, unsigned char *ptr, unsigned char *dataEnd);static unsigned char *DecodeSchemeAsciiExt(DmtxMessage *message, unsigned char *ptr, unsigned char *dataEnd);static unsigned char *DecodeSchemeC40Text(DmtxMessage *message, unsigned char *ptr, unsigned char *dataEnd, DmtxSchemeDecode encScheme);static unsigned char *DecodeSchemeX12(DmtxMessage *message, unsigned char *ptr, unsigned char *dataEnd);static unsigned char *DecodeSchemeEdifact(DmtxMessage *message, unsigned char *ptr, unsigned char *dataEnd);static unsigned char *DecodeSchemeBase256(DmtxMessage *message, unsigned char *ptr, unsigned char *dataEnd);/* static unsigned char UnRandomize253State(unsigned char codewordValue, int codewordPosition); */static unsigned char UnRandomize255State(unsigned char value, int idx);static int PopulateArrayFromMatrix(DmtxMessage *message, DmtxImage *image, DmtxRegion *region);static void TallyModuleJumps(DmtxImage *image, DmtxRegion *region, int tally[][24], int xOrigin, int yOrigin, int mapWidth, int mapHeight, DmtxDirection dir);static int PopulateArrayFromMosaic(DmtxMessage *message, DmtxImage *image, DmtxRegion *region);/* dmtxencode.c */static void AddPadChars(unsigned char *buf, int *bufSize, int paddedSize);static unsigned char Randomize253State(unsigned char codewordValue, int codewordPosition);static unsigned char Randomize255State(unsigned char codewordValue, int codewordPosition);static void PrintPattern(DmtxEncode *encode);static void InitChannel(DmtxChannel *channel, unsigned char *codewords, int length);static int EncodeDataCodewords(unsigned char *buf, unsigned char *inputString, int inputSize, DmtxSchemeEncode scheme, int *sizeIdx);static int EncodeSingleScheme(unsigned char *buf, unsigned char *codewords, int length, DmtxSchemeEncode scheme);static int EncodeAutoBest(unsigned char *buf, unsigned char *codewords, int length);/*static int EncodeAutoFast(unsigned char *buf, unsigned char *codewords, int length); */static DmtxChannel FindBestChannel(DmtxChannelGroup group, DmtxSchemeEncode targetScheme);static void EncodeNextWord(DmtxChannel *channel, DmtxSchemeEncode targetScheme);static void EncodeAsciiCodeword(DmtxChannel *channel);static void EncodeTripletCodeword(DmtxChannel *channel);static void EncodeEdifactCodeword(DmtxChannel *channel);static void EncodeBase256Codeword(DmtxChannel *channel);static void ChangeEncScheme(DmtxChannel *channel, DmtxSchemeEncode targetScheme, int unlatchType);static void PushInputWord(DmtxChannel *channel, unsigned char codeword);static void PushTriplet(DmtxChannel *channel, DmtxTriplet *triplet);static void IncrementProgress(DmtxChannel *channel, int encodedUnits);static void ProcessEndOfSymbolTriplet(DmtxChannel *channel, DmtxTriplet *triplet, int tripletCount, int inputCount);static void TestForEndOfSymbolEdifact(DmtxChannel *channel);static int GetC40TextX12Words(int *outputWords, int inputWord, DmtxSchemeEncode encScheme);static DmtxTriplet GetTripletValues(unsigned char cw1, unsigned char cw2);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -