⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dmtxsymbol.c

📁 Datamatrix二维码库和测试程序,运行于linux,仔细研究可以很容易转化成VC程序,有这就没必要化钱买个控件了,本人libdmtx-0.3版本转化过,的确可行,现在把找到该版本的libdmtx
💻 C
字号:
/*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: dmtxsymbol.c 514 2008-11-19 17:10:44Z mblaughton $ *//** * @file dmtxsymbol.c * @brief Data Matrix symbol attributes *//** * @brief  Retrieve property based on symbol size * @param  attribute * @param  sizeIdx * @return Attribute value */extern intdmtxGetSymbolAttribute(int attribute, int sizeIdx){   static const int symbolRows[] = { 10, 12, 14, 16, 18, 20,  22,  24,  26,                                                 32, 36, 40,  44,  48,  52,                                                 64, 72, 80,  88,  96, 104,                                                        120, 132, 144,                                                  8,  8, 12,  12,  16,  16 };   static const int symbolCols[] = { 10, 12, 14, 16, 18, 20,  22,  24,  26,                                                 32, 36, 40,  44,  48,  52,                                                 64, 72, 80,  88,  96, 104,                                                        120, 132, 144,                                                 18, 32, 26,  36,  36,  48 };   static const int dataRegionRows[] = { 8, 10, 12, 14, 16, 18, 20, 22, 24,                                                    14, 16, 18, 20, 22, 24,                                                    14, 16, 18, 20, 22, 24,                                                            18, 20, 22,                                                     6,  6, 10, 10, 14, 14 };   static const int dataRegionCols[] = { 8, 10, 12, 14, 16, 18, 20, 22, 24,                                                    14, 16, 18, 20, 22, 24,                                                    14, 16, 18, 20, 22, 24,                                                            18, 20, 22,                                                    16, 14, 24, 16, 16, 22 };   static const int horizDataRegions[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1,                                                    2, 2, 2, 2, 2, 2,                                                    4, 4, 4, 4, 4, 4,                                                          6, 6, 6,                                                    1, 2, 1, 2, 2, 2 };   static const int interleavedBlocks[] = { 1, 1, 1, 1, 1, 1, 1,  1, 1,                                                     1, 1, 1, 1,  1, 2,                                                     2, 4, 4, 4,  4, 6,                                                           6, 8, 10,                                                     1, 1, 1, 1,  1, 1 };   static const int symbolDataWords[] = { 3, 5, 8,  12,   18,   22,   30,   36,  44,                                                    62,   86,  114,  144,  174, 204,                                                   280,  368,  456,  576,  696, 816,                                                              1050, 1304, 1558,                                                     5,   10,   16,   22,   32,  49 };   static const int blockErrorWords[] = { 5, 7, 10, 12, 14, 18, 20, 24, 28,                                                    36, 42, 48, 56, 68, 42,                                                    56, 36, 48, 56, 68, 56,                                                            68, 62, 62,                                                     7, 11, 14, 18, 24, 28 };   static const int blockMaxCorrectable[] = { 2, 3, 5,  6,  7,  9,  10,  12,  14,                                                       18, 21, 24,  28,  34,  21,                                                       28, 18, 24,  28,  34,  28,                                                               34,  31,  31,                                                   3,  5,  7,   9,  12,  14 };   if(sizeIdx < 0 || sizeIdx >= DMTX_SYMBOL_SQUARE_COUNT + DMTX_SYMBOL_RECT_COUNT)      return -1;   switch(attribute) {      case DmtxSymAttribSymbolRows:         return symbolRows[sizeIdx];      case DmtxSymAttribSymbolCols:         return symbolCols[sizeIdx];      case DmtxSymAttribDataRegionRows:         return dataRegionRows[sizeIdx];      case DmtxSymAttribDataRegionCols:         return dataRegionCols[sizeIdx];      case DmtxSymAttribHorizDataRegions:         return horizDataRegions[sizeIdx];      case DmtxSymAttribVertDataRegions:         return (sizeIdx < DMTX_SYMBOL_SQUARE_COUNT) ? horizDataRegions[sizeIdx] : 1;      case DmtxSymAttribMappingMatrixRows:         return dataRegionRows[sizeIdx] * dmtxGetSymbolAttribute(DmtxSymAttribVertDataRegions, sizeIdx);      case DmtxSymAttribMappingMatrixCols:         return dataRegionCols[sizeIdx] * horizDataRegions[sizeIdx];      case DmtxSymAttribInterleavedBlocks:         return interleavedBlocks[sizeIdx];      case DmtxSymAttribBlockErrorWords:         return blockErrorWords[sizeIdx];      case DmtxSymAttribBlockMaxCorrectable:         return blockMaxCorrectable[sizeIdx];      case DmtxSymAttribSymbolDataWords:         return symbolDataWords[sizeIdx];      case DmtxSymAttribSymbolErrorWords:         return blockErrorWords[sizeIdx] * interleavedBlocks[sizeIdx];      case DmtxSymAttribSymbolMaxCorrectable:         return blockMaxCorrectable[sizeIdx] * interleavedBlocks[sizeIdx];   }   return -1;}/** * @brief  Retrieve data size for a specific symbol size and block number * @param  sizeIdx * @param  blockIdx * @return Attribute value */extern intdmtxGetBlockDataSize(int sizeIdx, int blockIdx){   int symbolDataWords;   int interleavedBlocks;   int count;   symbolDataWords = dmtxGetSymbolAttribute(DmtxSymAttribSymbolDataWords, sizeIdx);   interleavedBlocks = dmtxGetSymbolAttribute(DmtxSymAttribInterleavedBlocks, sizeIdx);   count = (int)(symbolDataWords/interleavedBlocks);   if(symbolDataWords < 1 || interleavedBlocks < 1)      return -1;   return (sizeIdx == DmtxSymbol144x144 && blockIdx < 8) ? count + 1 : count;}/** * @brief  Determine symbol size based on data size and requested properties * @param  dataWords * @param  sizeIdxRequest * @return Symbol size index (or -1 if none) */static intFindCorrectSymbolSize(int dataWords, int sizeIdxRequest){   int sizeIdx;   int idxBeg, idxEnd;   if(dataWords <= 0)      return -1;   if(sizeIdxRequest == DmtxSymbolSquareAuto || sizeIdxRequest == DmtxSymbolRectAuto) {      if(sizeIdxRequest == DmtxSymbolSquareAuto) {         idxBeg = 0;         idxEnd = DMTX_SYMBOL_SQUARE_COUNT;      }      else {         idxBeg = DMTX_SYMBOL_SQUARE_COUNT;         idxEnd = DMTX_SYMBOL_SQUARE_COUNT + DMTX_SYMBOL_RECT_COUNT;      }      for(sizeIdx = idxBeg; sizeIdx < idxEnd; sizeIdx++) {         if(dmtxGetSymbolAttribute(DmtxSymAttribSymbolDataWords, sizeIdx) >= dataWords)            break;      }      if(sizeIdx == idxEnd)         return -1;   }   else {      sizeIdx = sizeIdxRequest;   }   if(dataWords > dmtxGetSymbolAttribute(DmtxSymAttribSymbolDataWords, sizeIdx))      return -1;   return sizeIdx;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -