先看调用,越简单越好。

//画条码 直接贴到主模板图上GenBarCode(memDC, barCodeSn_left, barCodeSn_top, barCodeSn_bottom, sn, iStyle, 0, width - barCodeSn_left * 2);//画第一个二维码,保存到图片int ret = CreateQRCodeBMP((unsigned char *)"chenhao", 0, NULL, DEF_QRCODE_BMP_1);if (ret != 0) { AfxMessageBox("创建二维码失败"); return; }CImage image2; //创建图片类,把二维码图片 贴到主模板图上image2.Load(DEF_QRCODE_BMP_1);if (image2 == NULL) { AfxMessageBox("二维码文件不存在:" + (g_szTemplateName)); return; }HDC memDC2 = image2.GetDC();int xDest = 10;int yDest = 472;int wDest = 500;int hDest = 500;int xSrc = 0;int ySrc = 0;int wSrc = image2.GetWidth();int hSrc = image2.GetHeight();::SetStretchBltMode(memDC, COLORONCOLOR); //删除像素。该模式删除所有消除的像素行,不保留其信息::StretchBlt(memDC, xDest, yDest, wDest, hDest, memDC2, xSrc, ySrc, wSrc, hSrc, SRCCOPY);//拉伸贴图image2.ReleaseDC();

C++处理二维码: 字符串--二维码比特矩阵--保存二维码图片--粘到主图中。

先画条型码会影响二维码,生成的没问题,粘到主图有问题,改成::SetStretchBltMode(memDC, COLORONCOLOR);后正常,不论先后顺序。先画二维码正常,正常情况下也不重叠。

/*
pbText 要生成的二维码文字内容
iTextlen 内容长度 以0结束的字符串长度可以为0
pbCodeTextName 保存二维码数据的文件名 NULL时不存保
pbQRCodeName 二维码图片名
return 0成功  其它失败
*/
int CreateQRCodeBMP(unsigned char *pbText, unsigned int iTextlen, const char *pbCodeTextName, const char *pbQRCodeName)
{FILE *fp;uint8_t qrcode[QR_MAX_BITDATA];//先清空相关文件fp = fopen(pbQRCodeName, "wb+");fclose(fp);int size = qr_encode(QR_LEVEL_L, 0, (const char *)pbText, iTextlen, qrcode); //二维码矩阵 返回单边比特数量if (size == -1){size = 0;return -1;}//实际每行占用字节数,bmp要求行必须4字对齐,每行8个bit因此需要算32bit的余数unsigned int irealSize = (size % 32 > 0)?size + (32 - (size % 32)):size;BYTE *pbQRcode1 = (BYTE *)malloc(irealSize*size);//存二维码字符填充memset(pbQRcode1, '-', irealSize*size);unsigned int ipos = 0;unsigned int ipos2 = 0;BYTE ibit = 8;unsigned int iflag = 1;while (iflag){for (int i = 8; i > 0; i--){if (((qrcode[ipos] >> (i - 1)) & 0x01) > 0){pbQRcode1[ipos2] = '#';}else{pbQRcode1[ipos2] = ' ';}ipos2++;if ((ipos2%irealSize) % size == 0){ipos2 += irealSize - size; //跳过对齐填充的}if (ipos2 >= irealSize * size)//总比特数{iflag = 0;break;}}ipos++;}if (pbCodeTextName != NULL){//先清空相关文件fp = fopen(pbCodeTextName, "wb+");fclose(fp);fp = fopen(pbCodeTextName, "wb+"); //保存到文件ipos = 0;while (ipos < size){fwrite(pbQRcode1 + ipos * (irealSize), 1, irealSize, fp);fprintf(fp, "\r\n"); //加上回车换行ipos++;}fclose(fp); //保存文件完成}BYTE *pbQRcode2 = (BYTE *)malloc((irealSize*size) / 8);//图片memset(pbQRcode2, 0x00, (irealSize*size) / 8);int i = 0;unsigned int ipos4 = 0;int ibit4 = 8;for (i = 0; i < size; i++)//把pbQRcode1解析成pbQRcode2格式 即图片需要的格式{for (int j = 0; j < irealSize; j++){BYTE bT = pbQRcode1[(size - 1 - i)*irealSize + j];pbQRcode2[ipos4] |= (bT == ' ') ? (0x01 << (ibit4 - 1)) : 0x00;ibit4--;if (ibit4 == 0){ipos4++;ibit4 = 8;}}ibit4 = 8;}free(pbQRcode1);BITMAPFILEHEADER FileHeader;BITMAPINFOHEADER BmpHeader;BYTE pbRGBMask[8] = { 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00 };// Fill the FileHeaderFileHeader.bfType = ((WORD)('M' << 8) | 'B');FileHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + sizeof(pbRGBMask);FileHeader.bfSize = FileHeader.bfOffBits + (irealSize * size) / 8;FileHeader.bfReserved1 = 0;FileHeader.bfReserved2 = 0;// Fill the ImgHeaderBmpHeader.biSize = 40;BmpHeader.biWidth = size;BmpHeader.biHeight = size;BmpHeader.biPlanes = 1;BmpHeader.biBitCount = 1;BmpHeader.biCompression = BI_RGB;BmpHeader.biSizeImage = 84;BmpHeader.biXPelsPerMeter = 0;BmpHeader.biYPelsPerMeter = 0;BmpHeader.biClrUsed = 0;BmpHeader.biClrImportant = 0;// fill rgb maskfp = fopen(pbQRCodeName, "wb+");fwrite(&FileHeader, 1, sizeof(BITMAPFILEHEADER), fp);fwrite(&BmpHeader, 1, sizeof(BITMAPINFOHEADER), fp);fwrite(pbRGBMask, 1, sizeof(pbRGBMask), fp);fwrite(pbQRcode2, 1, (irealSize*size) / 8, fp);fclose(fp);free(pbQRcode2);return 0;
}
/** Copyright (c) 2010 Psytec Inc.* Copyright (c) 2012 Alexey Mednyy <swexru@gmail.com>* Copyright (c) 2012-2014 Pavol Rusnak <stick@gk2.sk>** Permission is hereby granted, free of charge, to any person obtaining a copy* of this software and associated documentation files (the "Software"), to deal* in the Software without restriction, including without limitation the rights* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell* copies of the Software, and to permit persons to whom the Software is* furnished to do so, subject to the following conditions:** The above copyright notice and this permission notice shall be included in* all copies or substantial portions of the Software.** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE* SOFTWARE.*/
//#include "stdafx.h"
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include "qr_encode.h"
#include "qr_consts.h"#ifdef __cplusplus
extern "C" {
#endifstatic int m_nLevel;
static int m_nVersion;
static int m_nMaskingNo;
static int m_ncDataCodeWordBit, m_ncAllCodeWord, nEncodeVersion;
static int m_ncDataBlock;
static int m_nSymbleSize;
static int m_nBlockLength[QR_MAX_DATACODEWORD];
static uint8_t m_byModuleData[QR_MAX_MODULESIZE][QR_MAX_MODULESIZE]; // [x][y]
static uint8_t m_byAllCodeWord[QR_MAX_ALLCODEWORD];
static uint8_t m_byBlockMode[QR_MAX_DATACODEWORD];
static uint8_t m_byDataCodeWord[QR_MAX_DATACODEWORD];
static uint8_t m_byRSWork[QR_MAX_CODEBLOCK];static int IsNumeralData(uint8_t c)
{if (c >= '0' && c <= '9') return 1;return 0;
}static int IsAlphabetData(uint8_t c)
{if (c >= '0' && c <= '9') return 1;if (c >= 'A' && c <= 'Z') return 1;if (c == ' ' || c == '$' || c == '%' || c == '*' || c == '+' || c == '-' || c == '.' || c == '/' || c == ':') return 1;return 0;
}static uint8_t AlphabetToBinary(uint8_t c)
{if (c >= '0' && c <= '9') return (uint8_t)(c - '0');if (c >= 'A' && c <= 'Z') return (uint8_t)(c - 'A' + 10);if (c == ' ') return 36;if (c == '$') return 37;if (c == '%') return 38;if (c == '*') return 39;if (c == '+') return 40;if (c == '-') return 41;if (c == '.') return 42;if (c == '/') return 43;return 44; // c == ':'
}static int SetBitStream(int nIndex, uint16_t wData, int ncData)
{int i;if (nIndex == -1 || nIndex + ncData > QR_MAX_DATACODEWORD * 8) return -1;for (i = 0; i < ncData; i++) {if (wData & (1 << (ncData - i - 1))) {m_byDataCodeWord[(nIndex + i) / 8] |= 1 << (7 - ((nIndex + i) % 8));}}return nIndex + ncData;
}static int GetBitLength(uint8_t nMode, int ncData, int nVerGroup)
{int ncBits = 0;switch (nMode) {case QR_MODE_NUMERAL:ncBits = 4 + nIndicatorLenNumeral[nVerGroup] + (10 * (ncData / 3));switch (ncData % 3) {case 1:ncBits += 4;break;case 2:ncBits += 7;break;default: // case 0:break;}break;case QR_MODE_ALPHABET:ncBits = 4 + nIndicatorLenAlphabet[nVerGroup] + (11 * (ncData / 2)) + (6 * (ncData % 2));break;default: // case QR_MODE_8BIT:ncBits = 4 + nIndicatorLen8Bit[nVerGroup] + (8 * ncData);break;}return ncBits;
}static int EncodeSourceData(const char* lpsSource, int ncLength, int nVerGroup)
{memset(m_nBlockLength, 0, sizeof(m_nBlockLength));int i, j;// Investigate whether continuing characters (bytes) which mode is whatfor (m_ncDataBlock = i = 0; i < ncLength; i++) {uint8_t byMode;if (IsNumeralData(lpsSource[i])) {byMode = QR_MODE_NUMERAL;} else if (IsAlphabetData(lpsSource[i])) {byMode = QR_MODE_ALPHABET;} else {byMode = QR_MODE_8BIT;}if (i == 0) {m_byBlockMode[0] = byMode;}if (m_byBlockMode[m_ncDataBlock] != byMode) {m_byBlockMode[++m_ncDataBlock] = byMode;}m_nBlockLength[m_ncDataBlock]++;}m_ncDataBlock++;// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // /// Linked by a sequence of conditional block alphanumeric mode and numeric mode block adjacentint ncSrcBits, ncDstBits; // The bit length of the block mode if you have over the original bit length and a single alphanumericint nBlock = 0;while (nBlock < m_ncDataBlock - 1) {int ncJoinFront, ncJoinBehind;        // Bit length when combined with 8-bit byte block mode before and afterint nJoinPosition = 0;      // Block the binding of 8-bit byte mode: combined with the previous -1 = 0 = do not bind, bind behind a =// Sort of - "digit alphanumeric" - "or alphanumeric numbers"if ((m_byBlockMode[nBlock] == QR_MODE_NUMERAL && m_byBlockMode[nBlock + 1] == QR_MODE_ALPHABET) ||(m_byBlockMode[nBlock] == QR_MODE_ALPHABET && m_byBlockMode[nBlock + 1] == QR_MODE_NUMERAL)) {// If you compare the bit length of alphanumeric characters and a single block mode over the original bit lengthncSrcBits = GetBitLength(m_byBlockMode[nBlock], m_nBlockLength[nBlock], nVerGroup) +GetBitLength(m_byBlockMode[nBlock + 1], m_nBlockLength[nBlock + 1], nVerGroup);ncDstBits = GetBitLength(QR_MODE_ALPHABET, m_nBlockLength[nBlock] + m_nBlockLength[nBlock + 1], nVerGroup);if (ncSrcBits > ncDstBits) {// If there is an 8-bit byte block mode back and forth, check whether they favor the binding ofif (nBlock >= 1 && m_byBlockMode[nBlock - 1] == QR_MODE_8BIT) {// There are 8-bit byte block mode beforencJoinFront = GetBitLength(QR_MODE_8BIT, m_nBlockLength[nBlock - 1] + m_nBlockLength[nBlock], nVerGroup) +GetBitLength(m_byBlockMode[nBlock + 1], m_nBlockLength[nBlock + 1], nVerGroup);if (ncJoinFront > ncDstBits + GetBitLength(QR_MODE_8BIT, m_nBlockLength[nBlock - 1], nVerGroup)) {ncJoinFront = 0; // 8-bit byte and block mode does not bind}} else {ncJoinFront = 0;}if (nBlock < m_ncDataBlock - 2 && m_byBlockMode[nBlock + 2] == QR_MODE_8BIT) {// There are 8-bit byte mode block behindncJoinBehind = GetBitLength(m_byBlockMode[nBlock], m_nBlockLength[nBlock], nVerGroup) +GetBitLength(QR_MODE_8BIT, m_nBlockLength[nBlock + 1] + m_nBlockLength[nBlock + 2], nVerGroup);if (ncJoinBehind > ncDstBits + GetBitLength(QR_MODE_8BIT, m_nBlockLength[nBlock + 2], nVerGroup)) {ncJoinBehind = 0; // 8-bit byte and block mode does not bind}} else {ncJoinBehind = 0;}if (ncJoinFront != 0 && ncJoinBehind != 0) {// If there is a 8-bit byte block mode has priority both before and after the way the data length is shorternJoinPosition = (ncJoinFront < ncJoinBehind) ? -1 : 1;} else {nJoinPosition = (ncJoinFront != 0) ? -1 : ((ncJoinBehind != 0) ? 1 : 0);}if (nJoinPosition != 0) {// Block the binding of 8-bit byte modeif (nJoinPosition == -1) {m_nBlockLength[nBlock - 1] += m_nBlockLength[nBlock];// The subsequent shiftfor (i = nBlock; i < m_ncDataBlock - 1; i++) {m_byBlockMode[i] = m_byBlockMode[i + 1];m_nBlockLength[i] = m_nBlockLength[i + 1];}} else {m_byBlockMode[nBlock + 1] = QR_MODE_8BIT;m_nBlockLength[nBlock + 1] += m_nBlockLength[nBlock + 2];// The subsequent shiftfor (i = nBlock + 2; i < m_ncDataBlock - 1; i++) {m_byBlockMode[i] = m_byBlockMode[i + 1];m_nBlockLength[i] = m_nBlockLength[i + 1];}}m_ncDataBlock--;} else {// Block mode integrated into a single alphanumeric string of numbers and alphanumericif (nBlock < m_ncDataBlock - 2 && m_byBlockMode[nBlock + 2] == QR_MODE_ALPHABET) {// Binding mode of the block followed by alphanumeric block attempts to joinm_nBlockLength[nBlock + 1] += m_nBlockLength[nBlock + 2];// The subsequent shiftfor (i = nBlock + 2; i < m_ncDataBlock - 1; i++) {m_byBlockMode[i] = m_byBlockMode[i + 1];m_nBlockLength[i] = m_nBlockLength[i + 1];}m_ncDataBlock--;}m_byBlockMode[nBlock] = QR_MODE_ALPHABET;m_nBlockLength[nBlock] += m_nBlockLength[nBlock + 1];// The subsequent shiftfor (i = nBlock + 1; i < m_ncDataBlock - 1; i++) {m_byBlockMode[i] = m_byBlockMode[i + 1];m_nBlockLength[i] = m_nBlockLength[i + 1];}m_ncDataBlock--;if (nBlock >= 1 && m_byBlockMode[nBlock - 1] == QR_MODE_ALPHABET) {// Combined mode of alphanumeric block before the block boundm_nBlockLength[nBlock - 1] += m_nBlockLength[nBlock];// The subsequent shiftfor (i = nBlock; i < m_ncDataBlock - 1; i++) {m_byBlockMode[i] = m_byBlockMode[i + 1];m_nBlockLength[i] = m_nBlockLength[i + 1];}m_ncDataBlock--;}}continue;// Re-examine the block of the current position}}nBlock++; // Investigate the next block}// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // /// 8-bit byte block mode over the short block mode to continuousnBlock = 0;while (nBlock < m_ncDataBlock - 1) {ncSrcBits = GetBitLength(m_byBlockMode[nBlock], m_nBlockLength[nBlock], nVerGroup)+ GetBitLength(m_byBlockMode[nBlock + 1], m_nBlockLength[nBlock + 1], nVerGroup);ncDstBits = GetBitLength(QR_MODE_8BIT, m_nBlockLength[nBlock] + m_nBlockLength[nBlock + 1], nVerGroup);// If there is a 8-bit byte block mode before, subtract the duplicate indicator minuteif (nBlock >= 1 && m_byBlockMode[nBlock - 1] == QR_MODE_8BIT) {ncDstBits -= (4 + nIndicatorLen8Bit[nVerGroup]);}// If there is a block behind the 8-bit byte mode, subtract the duplicate indicator minuteif (nBlock < m_ncDataBlock - 2 && m_byBlockMode[nBlock + 2] == QR_MODE_8BIT) {ncDstBits -= (4 + nIndicatorLen8Bit[nVerGroup]);}if (ncSrcBits > ncDstBits) {if (nBlock >= 1 && m_byBlockMode[nBlock - 1] == QR_MODE_8BIT) {// 8-bit byte mode coupling block in front of the block to joinm_nBlockLength[nBlock - 1] += m_nBlockLength[nBlock];// The subsequent shiftfor (i = nBlock; i < m_ncDataBlock - 1; i++) {m_byBlockMode[i] = m_byBlockMode[i + 1];m_nBlockLength[i] = m_nBlockLength[i + 1];}m_ncDataBlock--;nBlock--;}if (nBlock < m_ncDataBlock - 2 && m_byBlockMode[nBlock + 2] == QR_MODE_8BIT) {// 8-bit byte mode coupling block at the back of the block to joinm_nBlockLength[nBlock + 1] += m_nBlockLength[nBlock + 2];// The subsequent shiftfor (i = nBlock + 2; i < m_ncDataBlock - 1; i++) {m_byBlockMode[i] = m_byBlockMode[i + 1];m_nBlockLength[i] = m_nBlockLength[i + 1];}m_ncDataBlock--;}m_byBlockMode[nBlock] = QR_MODE_8BIT;m_nBlockLength[nBlock] += m_nBlockLength[nBlock + 1];// The subsequent shiftfor (i = nBlock + 1; i < m_ncDataBlock - 1; i++) {m_byBlockMode[i] = m_byBlockMode[i + 1];m_nBlockLength[i] = m_nBlockLength[i + 1];}m_ncDataBlock--;// Re-examination in front of the block boundif (nBlock >= 1) {nBlock--;}continue;}nBlock++;// Investigate the next block}// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // /// Mosquito bit arrayint ncComplete = 0; // Data pre-processing counteruint16_t wBinCode;m_ncDataCodeWordBit = 0;// Bit counter processing unitmemset(m_byDataCodeWord, 0, sizeof(m_byDataCodeWord));for (i = 0; i < m_ncDataBlock && m_ncDataCodeWordBit != -1; i++) {if (m_byBlockMode[i] == QR_MODE_NUMERAL) {// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // /// Numeric mode// Indicator (0001b)m_ncDataCodeWordBit = SetBitStream(m_ncDataCodeWordBit, 1, 4);// Set number of charactersm_ncDataCodeWordBit = SetBitStream(m_ncDataCodeWordBit, (uint16_t)m_nBlockLength[i], nIndicatorLenNumeral[nVerGroup]);// Save the bit stringfor (j = 0; j < m_nBlockLength[i]; j += 3) {if (j < m_nBlockLength[i] - 2) {wBinCode = (uint16_t)(((lpsSource[ncComplete + j] - '0') * 100) +((lpsSource[ncComplete + j + 1] - '0') * 10) +(lpsSource[ncComplete + j + 2] - '0'));m_ncDataCodeWordBit = SetBitStream(m_ncDataCodeWordBit, wBinCode, 10);} elseif (j == m_nBlockLength[i] - 2) {// 2 bytes fractionwBinCode = (uint16_t)(((lpsSource[ncComplete + j] - '0') * 10) +(lpsSource[ncComplete + j + 1] - '0'));m_ncDataCodeWordBit = SetBitStream(m_ncDataCodeWordBit, wBinCode, 7);} elseif (j == m_nBlockLength[i] - 1) {// A fraction of byteswBinCode = (uint16_t)(lpsSource[ncComplete + j] - '0');m_ncDataCodeWordBit = SetBitStream(m_ncDataCodeWordBit, wBinCode, 4);}}ncComplete += m_nBlockLength[i];}elseif (m_byBlockMode[i] == QR_MODE_ALPHABET) {// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // /// Alphanumeric mode// Mode indicator (0010b)m_ncDataCodeWordBit = SetBitStream(m_ncDataCodeWordBit, 2, 4);// Set number of charactersm_ncDataCodeWordBit = SetBitStream(m_ncDataCodeWordBit, (uint16_t)m_nBlockLength[i], nIndicatorLenAlphabet[nVerGroup]);// Save the bit stringfor (j = 0; j < m_nBlockLength[i]; j += 2) {if (j < m_nBlockLength[i] - 1) {wBinCode = (uint16_t)((AlphabetToBinary(lpsSource[ncComplete + j]) * 45) +AlphabetToBinary(lpsSource[ncComplete + j + 1]));m_ncDataCodeWordBit = SetBitStream(m_ncDataCodeWordBit, wBinCode, 11);} else {// A fraction of byteswBinCode = (uint16_t)AlphabetToBinary(lpsSource[ncComplete + j]);m_ncDataCodeWordBit = SetBitStream(m_ncDataCodeWordBit, wBinCode, 6);}}ncComplete += m_nBlockLength[i];}else { // (m_byBlockMode[i] == QR_MODE_8BIT)// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // /// 8-bit byte mode// Mode indicator (0100b)m_ncDataCodeWordBit = SetBitStream(m_ncDataCodeWordBit, 4, 4);// Set number of charactersm_ncDataCodeWordBit = SetBitStream(m_ncDataCodeWordBit, (uint16_t)m_nBlockLength[i], nIndicatorLen8Bit[nVerGroup]);// Save the bit stringfor (j = 0; j < m_nBlockLength[i]; j++) {m_ncDataCodeWordBit = SetBitStream(m_ncDataCodeWordBit, (uint16_t)lpsSource[ncComplete + j], 8);}ncComplete += m_nBlockLength[i];}}return (m_ncDataCodeWordBit != -1);
}// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // /
// APPLICATIONS: To get the bit length
// Args: data mode type, data length, group version (model number)
// Returns: data bit lengthstatic int GetEncodeVersion(int nVersion, const char* lpsSource, int ncLength)
{int nVerGroup = nVersion >= 27 ? QR_VERSION_L : (nVersion >= 10 ? QR_VERSION_M : QR_VERSION_S);int i, j;for (i = nVerGroup; i <= QR_VERSION_L; i++) {if (EncodeSourceData(lpsSource, ncLength, i)) {if (i == QR_VERSION_S) {for (j = 1; j <= 9; j++) {if ((m_ncDataCodeWordBit + 7) / 8 <= QR_VersonInfo[j].ncDataCodeWord[m_nLevel]) {return j;}}}
#if QR_MAX_VERSION >= QR_VERSION_Melseif (i == QR_VERSION_M) {for (j = 10; j <= 26; j++) {if ((m_ncDataCodeWordBit + 7) / 8 <= QR_VersonInfo[j].ncDataCodeWord[m_nLevel]) {return j;}}}
#endif
#if QR_MAX_VERSION >= QR_VERSION_Lelseif (i == QR_VERSION_L) {for (j = 27; j <= 40; j++) {if ((m_ncDataCodeWordBit + 7) / 8 <= QR_VersonInfo[j].ncDataCodeWord[m_nLevel]) {return j;}}}
#endif}}return 0;
}static void GetRSCodeWord(uint8_t* lpbyRSWork, int ncDataCodeWord, int ncRSCodeWord)
{int i, j;for (i = 0; i < ncDataCodeWord ; i++) {if (lpbyRSWork[0] != 0) {uint8_t nExpFirst = byIntToExp[lpbyRSWork[0]]; // Multiplier coefficient is calculated from the first termfor (j = 0; j < ncRSCodeWord; j++) {// Add (% 255 ^ 255 = 1) the first term multiplier to multiplier sectionsuint8_t nExpElement = (uint8_t)(((int)(byRSExp[ncRSCodeWord][j] + nExpFirst)) % 255);// Surplus calculated by the exclusivelpbyRSWork[j] = (uint8_t)(lpbyRSWork[j + 1] ^ byExpToInt[nExpElement]);}// Shift the remaining digitsfor (j = ncRSCodeWord; j < ncDataCodeWord + ncRSCodeWord - 1; j++) {lpbyRSWork[j] = lpbyRSWork[j + 1];}} else {// Shift the remaining digitsfor (j = 0; j < ncDataCodeWord + ncRSCodeWord - 1; j++) {lpbyRSWork[j] = lpbyRSWork[j + 1];}}}
}static void SetFinderPattern(int x, int y)
{static const uint8_t byPattern[] = {  0x7f,   // 1111111b0x41,    // 1000001b0x5d,    // 1011101b0x5d,    // 1011101b0x5d,    // 1011101b0x41,    // 1000001b0x7f};   // 1111111bint i, j;for (i = 0; i < 7; i++) {for (j = 0; j < 7; j++) {m_byModuleData[x + j][y + i] = (byPattern[i] & (1 << (6 - j))) ? '\x30' : '\x20';}}
}static void SetVersionPattern(void)
{int i, j;if (m_nVersion <= 6) {return;}int nVerData = m_nVersion << 12;// Calculated bit remainderfor (i = 0; i < 6; i++) {if (nVerData & (1 << (17 - i))) {nVerData ^= (0x1f25 << (5 - i));}}nVerData += m_nVersion << 12;for (i = 0; i < 6; i++) {for (j = 0; j < 3; j++) {m_byModuleData[m_nSymbleSize - 11 + j][i] = m_byModuleData[i][m_nSymbleSize - 11 + j] =(nVerData & (1 << (i * 3 + j))) ? '\x30' : '\x20';}}
}static void SetAlignmentPattern(int x, int y)
{static const uint8_t byPattern[] = {  0x1f,   // 11111b0x11,  // 10001b0x15,  // 10101b0x11,  // 10001b0x1f}; // 11111bint i, j;if (m_byModuleData[x][y] & 0x20) {return;         // Excluded due to overlap with the functional module}x -= 2; y -= 2;     // Convert the coordinates to the upper left cornerfor (i = 0; i < 5; i++) {for (j = 0; j < 5; j++) {m_byModuleData[x + j][y + i] = (byPattern[i] & (1 << (4 - j))) ? '\x30' : '\x20';}}
}static void SetFunctionModule(void)
{int i, j;// Position detection patternSetFinderPattern(0, 0);SetFinderPattern(m_nSymbleSize - 7, 0);SetFinderPattern(0, m_nSymbleSize - 7);// Separator pattern position detectionfor (i = 0; i < 8; i++) {m_byModuleData[i][7] = m_byModuleData[7][i] = '\x20';m_byModuleData[m_nSymbleSize - 8][i] = m_byModuleData[m_nSymbleSize - 8 + i][7] = '\x20';m_byModuleData[i][m_nSymbleSize - 8] = m_byModuleData[7][m_nSymbleSize - 8 + i] = '\x20';}// Registration as part of a functional module position description format informationfor (i = 0; i < 9; i++) {m_byModuleData[i][8] = m_byModuleData[8][i] = '\x20';}for (i = 0; i < 8; i++) {m_byModuleData[m_nSymbleSize - 8 + i][8] = m_byModuleData[8][m_nSymbleSize - 8 + i] = '\x20';}// Version information patternSetVersionPattern();// Pattern alignmentfor (i = 0; i < QR_VersonInfo[m_nVersion].ncAlignPoint; i++) {SetAlignmentPattern(QR_VersonInfo[m_nVersion].nAlignPoint[i], 6);SetAlignmentPattern(6, QR_VersonInfo[m_nVersion].nAlignPoint[i]);for (j = 0; j < QR_VersonInfo[m_nVersion].ncAlignPoint; j++) {SetAlignmentPattern(QR_VersonInfo[m_nVersion].nAlignPoint[i], QR_VersonInfo[m_nVersion].nAlignPoint[j]);}}// Timing patternfor (i = 8; i <= m_nSymbleSize - 9; i++) {m_byModuleData[i][6] = (i % 2) == 0 ? '\x30' : '\x20';m_byModuleData[6][i] = (i % 2) == 0 ? '\x30' : '\x20';}
}static void SetCodeWordPattern(void)
{int x = m_nSymbleSize;int y = m_nSymbleSize - 1;int nCoef_x = 1;    // placement orientation axis xint nCoef_y = 1;    // placement orientation axis yint i, j;for (i = 0; i < m_ncAllCodeWord; i++) {for (j = 0; j < 8; j++) {do {x += nCoef_x;nCoef_x *= -1;if (nCoef_x < 0) {y += nCoef_y;if (y < 0 || y == m_nSymbleSize) {y = (y < 0) ? 0 : m_nSymbleSize - 1;nCoef_y *= -1;x -= 2;if (x == 6) { // Timing patternx--;}}}} while (m_byModuleData[x][y] & 0x20); // Exclude a functional modulem_byModuleData[x][y] = (m_byAllCodeWord[i] & (1 << (7 - j))) ? '\x02' : '\x00';}}
}static void SetMaskingPattern(int nPatternNo)
{int i, j;for (i = 0; i < m_nSymbleSize; i++) {for (j = 0; j < m_nSymbleSize; j++) {if (! (m_byModuleData[j][i] & 0x20)) { // Exclude a functional moduleint bMask;switch (nPatternNo) {case 0:bMask = ((i + j) % 2 == 0);break;case 1:bMask = (i % 2 == 0);break;case 2:bMask = (j % 3 == 0);break;case 3:bMask = ((i + j) % 3 == 0);break;case 4:bMask = (((i / 2) + (j / 3)) % 2 == 0);break;case 5:bMask = (((i * j) % 2) + ((i * j) % 3) == 0);break;case 6:bMask = ((((i * j) % 2) + ((i * j) % 3)) % 2 == 0);break;default: // case 7:bMask = ((((i * j) % 3) + ((i + j) % 2)) % 2 == 0);break;}m_byModuleData[j][i] = (uint8_t)((m_byModuleData[j][i] & 0xfe) | (((m_byModuleData[j][i] & 0x02) > 1) ^ bMask));}}}
}static void SetFormatInfoPattern(int nPatternNo)
{int nFormatInfo;int i;switch (m_nLevel) {case QR_LEVEL_L:nFormatInfo = 0x08; // 01nnnbbreak;case QR_LEVEL_M:nFormatInfo = 0x00; // 00nnnbbreak;case QR_LEVEL_Q:nFormatInfo = 0x18; // 11nnnbbreak;default: // case QR_LEVEL_H:nFormatInfo = 0x10; // 10nnnbbreak;}nFormatInfo += nPatternNo;int nFormatData = nFormatInfo << 10;// Calculated bit remainderfor (i = 0; i < 5; i++) {if (nFormatData & (1 << (14 - i))) {nFormatData ^= (0x0537 << (4 - i)); // 10100110111b}}nFormatData += nFormatInfo << 10;// MaskingnFormatData ^= 0x5412; // 101010000010010b// Position detection patterns located around the upper leftfor (i = 0; i <= 5; i++) {m_byModuleData[8][i] = (nFormatData & (1 << i)) ? '\x30' : '\x20';}m_byModuleData[8][7] = (nFormatData & (1 << 6)) ? '\x30' : '\x20';m_byModuleData[8][8] = (nFormatData & (1 << 7)) ? '\x30' : '\x20';m_byModuleData[7][8] = (nFormatData & (1 << 8)) ? '\x30' : '\x20';for (i = 9; i <= 14; i++) {m_byModuleData[14 - i][8] = (nFormatData & (1 << i)) ? '\x30' : '\x20';}// Position detection patterns located under the upper right cornerfor (i = 0; i <= 7; i++) {m_byModuleData[m_nSymbleSize - 1 - i][8] = (nFormatData & (1 << i)) ? '\x30' : '\x20';}// Right lower left position detection patterns locatedm_byModuleData[8][m_nSymbleSize - 8] = '\x30';   // Module fixed darkfor (i = 8; i <= 14; i++) {m_byModuleData[8][m_nSymbleSize - 15 + i] = (nFormatData & (1 << i)) ? '\x30' : '\x20';}
}static int CountPenalty(void)
{int nPenalty = 0;int i, j, k;// Column of the same color adjacent modulefor (i = 0; i < m_nSymbleSize; i++) {for (j = 0; j < m_nSymbleSize - 4; j++) {int nCount = 1;for (k = j + 1; k < m_nSymbleSize; k++) {if (((m_byModuleData[i][j] & 0x11) == 0) == ((m_byModuleData[i][k] & 0x11) == 0)) {nCount++;} else {break;}}if (nCount >= 5) {nPenalty += 3 + (nCount - 5);}j = k - 1;}}// Adjacent module line of the same colorfor (i = 0; i < m_nSymbleSize; i++) {for (j = 0; j < m_nSymbleSize - 4; j++) {int nCount = 1;for (k = j + 1; k < m_nSymbleSize; k++) {if (((m_byModuleData[j][i] & 0x11) == 0) == ((m_byModuleData[k][i] & 0x11) == 0)) {nCount++;} else {break;}}if (nCount >= 5) {nPenalty += 3 + (nCount - 5);}j = k - 1;}}// Modules of the same color block (2 ~ 2)for (i = 0; i < m_nSymbleSize - 1; i++) {for (j = 0; j < m_nSymbleSize - 1; j++) {if ((((m_byModuleData[i][j] & 0x11) == 0) == ((m_byModuleData[i + 1][j]     & 0x11) == 0)) &&(((m_byModuleData[i][j] & 0x11) == 0) == ((m_byModuleData[i] [j + 1] & 0x11) == 0)) &&(((m_byModuleData[i][j] & 0x11) == 0) == ((m_byModuleData[i + 1][j + 1] & 0x11) == 0))) {nPenalty += 3;}}}// Pattern (dark dark: light: dark: light) ratio 1:1:3:1:1 in the same columnfor (i = 0; i < m_nSymbleSize; i++) {for (j = 0; j < m_nSymbleSize - 6; j++) {if (((j == 0) ||                (! (m_byModuleData[i][j - 1] & 0x11))) &&(   m_byModuleData[i][j    ] & 0x11) &&(! (m_byModuleData[i][j + 1] & 0x11)) &&(   m_byModuleData[i][j + 2] & 0x11) &&(   m_byModuleData[i][j + 3] & 0x11) &&(   m_byModuleData[i][j + 4] & 0x11) &&(! (m_byModuleData[i][j + 5] & 0x11)) &&(   m_byModuleData[i][j + 6] & 0x11) &&((j == m_nSymbleSize - 7) || (! (m_byModuleData[i][j + 7] & 0x11)))) {// Clear pattern of four or more before or afterif (((j < 2 || ! (m_byModuleData[i][j - 2] & 0x11)) &&(j < 3 || ! (m_byModuleData[i][j - 3] & 0x11)) &&(j < 4 || ! (m_byModuleData[i][j - 4] & 0x11))) ||((j >= m_nSymbleSize - 8 || ! (m_byModuleData[i][j + 8] & 0x11)) &&(j >= m_nSymbleSize - 9 || ! (m_byModuleData[i][j + 9] & 0x11)) &&(j >= m_nSymbleSize - 10 || ! (m_byModuleData[i][j + 10] & 0x11)))) {nPenalty += 40;}}}}// Pattern (dark dark: light: dark: light) in the same line ratio 1:1:3:1:1for (i = 0; i < m_nSymbleSize; i++) {for (j = 0; j < m_nSymbleSize - 6; j++) {if (((j == 0) ||              (! (m_byModuleData[j - 1][i] & 0x11))) &&(   m_byModuleData[j   ] [i] & 0x11) &&(! (m_byModuleData[j + 1][i] & 0x11)) &&(   m_byModuleData[j + 2][i] & 0x11) &&(   m_byModuleData[j + 3][i] & 0x11) &&(   m_byModuleData[j + 4][i] & 0x11) &&(! (m_byModuleData[j + 5][i] & 0x11)) &&(   m_byModuleData[j + 6][i] & 0x11) &&((j == m_nSymbleSize - 7) || (! (m_byModuleData[j + 7][i] & 0x11)))) {// Clear pattern of four or more before or afterif (((j < 2 || ! (m_byModuleData[j - 2][i] & 0x11)) &&(j < 3 || ! (m_byModuleData[j - 3][i] & 0x11)) &&(j < 4 || ! (m_byModuleData[j - 4][i] & 0x11))) ||((j >= m_nSymbleSize - 8 || ! (m_byModuleData[j + 8][i] & 0x11)) &&(j >= m_nSymbleSize - 9 || ! (m_byModuleData[j + 9][i] & 0x11)) &&(j >= m_nSymbleSize - 10 || ! (m_byModuleData[j + 10][i] & 0x11)))) {nPenalty += 40;}}}}// The proportion of modules for the entire darkint nCount = 0;for (i = 0; i < m_nSymbleSize; i++) {for (j = 0; j < m_nSymbleSize; j++) {if (! (m_byModuleData[i][j] & 0x11)) {nCount++;}}}nPenalty += (abs(50 - ((nCount * 100) / (m_nSymbleSize * m_nSymbleSize))) / 5) * 10;return nPenalty;
}static void FormatModule(void)
{int i, j;memset(m_byModuleData, 0, sizeof(m_byModuleData));// Function module placementSetFunctionModule();// Data placementSetCodeWordPattern();if (m_nMaskingNo == -1) {// Select the best pattern maskingm_nMaskingNo = 0;SetMaskingPattern(m_nMaskingNo);       // MaskingSetFormatInfoPattern(m_nMaskingNo);   // Placement pattern format informationint nMinPenalty = CountPenalty();for (i = 1; i <= 7; i++) {SetMaskingPattern(i);             // MaskingSetFormatInfoPattern(i);      // Placement pattern format informationint nPenalty = CountPenalty();if (nPenalty < nMinPenalty) {nMinPenalty = nPenalty;m_nMaskingNo = i;}}}SetMaskingPattern(m_nMaskingNo);     // MaskingSetFormatInfoPattern(m_nMaskingNo); // Placement pattern format information// The module pattern converted to a Boolean valuefor (i = 0; i < m_nSymbleSize; i++) {for (j = 0; j < m_nSymbleSize; j++) {m_byModuleData[i][j] = (uint8_t)((m_byModuleData[i][j] & 0x11) != 0);}}
}static void putBitToPos(uint32_t pos, int bw, uint8_t *bits)
{if (bw == 0) return;uint32_t tmp;uint32_t bitpos[8] = {128, 64, 32, 16, 8, 4, 2, 1};if (pos % 8 == 0) {tmp = (pos / 8) - 1;bits[tmp] = bits[tmp] ^ bitpos[7];} else {tmp = pos / 8;bits[tmp] = bits[tmp] ^ bitpos[pos % 8 - 1];}
}int qr_encode(int level, int version, const char *source, size_t source_len, uint8_t *result)
{int i, j;const bool auto_extent = 0;m_nLevel = level;m_nMaskingNo = -1;memset(result, 0, QR_MAX_BITDATA);// If the data length is not specified, acquired by lstrlensize_t ncLength = source_len > 0 ? source_len : strlen(source);if (ncLength == 0) {return -1; // No data}// Check version (model number)nEncodeVersion = GetEncodeVersion(version, source, ncLength);if (nEncodeVersion == 0) {return -1; // Over-capacity}if (version == 0) {// Auto Partm_nVersion = nEncodeVersion;} else {if (nEncodeVersion <= version) {m_nVersion = version;} else {if (auto_extent) {m_nVersion = nEncodeVersion; // Automatic extended version (model number)} else {return -1; // Over-capacity}}}// Terminator addition code "0000"int ncDataCodeWord = QR_VersonInfo[m_nVersion].ncDataCodeWord[level];int ncTerminator = (ncDataCodeWord * 8) - m_ncDataCodeWordBit;if (ncTerminator > 4) {ncTerminator = 4;}if (ncTerminator > 0) {m_ncDataCodeWordBit = SetBitStream(m_ncDataCodeWordBit, 0, ncTerminator);}// Additional padding code "11101100, 00010001"uint8_t byPaddingCode = 0xec;for (i = (m_ncDataCodeWordBit + 7) / 8; i < ncDataCodeWord; i++) {m_byDataCodeWord[i] = byPaddingCode;byPaddingCode = (uint8_t)(byPaddingCode == 0xec ? 0x11 : 0xec);}// Calculated the total clear area code wordm_ncAllCodeWord = QR_VersonInfo[m_nVersion].ncAllCodeWord;memset(m_byAllCodeWord, 0, sizeof(m_byAllCodeWord));int nDataCwIndex = 0;  // Position data processing code word// Division number data blockint ncBlock1 = QR_VersonInfo[m_nVersion].RS_BlockInfo1[level].ncRSBlock;int ncBlock2 = QR_VersonInfo[m_nVersion].RS_BlockInfo2[level].ncRSBlock;int ncBlockSum = ncBlock1 + ncBlock2;int nBlockNo = 0; // Block number in the process// The number of data code words by blockint ncDataCw1 = QR_VersonInfo[m_nVersion].RS_BlockInfo1[level].ncDataCodeWord;int ncDataCw2 = QR_VersonInfo[m_nVersion].RS_BlockInfo2[level].ncDataCodeWord;// Code word interleaving data placementfor (i = 0; i < ncBlock1; i++) {for (j = 0; j < ncDataCw1; j++) {m_byAllCodeWord[(ncBlockSum * j) + nBlockNo] = m_byDataCodeWord[nDataCwIndex++];}nBlockNo++;}for (i = 0; i < ncBlock2; i++) {for (j = 0; j < ncDataCw2; j++) {if (j < ncDataCw1) {m_byAllCodeWord[(ncBlockSum * j) + nBlockNo] = m_byDataCodeWord[nDataCwIndex++];} else {// 2 minute fraction block placement eventm_byAllCodeWord[(ncBlockSum * ncDataCw1) + i] = m_byDataCodeWord[nDataCwIndex++];}}nBlockNo++;}// RS code words by block number (currently the same number)int ncRSCw1 = QR_VersonInfo[m_nVersion].RS_BlockInfo1[level].ncAllCodeWord - ncDataCw1;int ncRSCw2 = QR_VersonInfo[m_nVersion].RS_BlockInfo2[level].ncAllCodeWord - ncDataCw2;// RS code word is calculatednDataCwIndex = 0;nBlockNo = 0;for (i = 0; i < ncBlock1; i++) {memset(m_byRSWork, 0, sizeof(m_byRSWork));memmove(m_byRSWork, m_byDataCodeWord + nDataCwIndex, ncDataCw1);GetRSCodeWord(m_byRSWork, ncDataCw1, ncRSCw1);// RS code word placementfor (j = 0; j < ncRSCw1; j++) {m_byAllCodeWord[ncDataCodeWord + (ncBlockSum * j) + nBlockNo] = m_byRSWork[j];}nDataCwIndex += ncDataCw1;nBlockNo++;}for (i = 0; i < ncBlock2; i++) {memset(m_byRSWork, 0, sizeof(m_byRSWork));memmove(m_byRSWork, m_byDataCodeWord + nDataCwIndex, ncDataCw2);GetRSCodeWord(m_byRSWork, ncDataCw2, ncRSCw2);// RS code word placementfor (j = 0; j < ncRSCw2; j++) {m_byAllCodeWord[ncDataCodeWord + (ncBlockSum * j) + nBlockNo] = m_byRSWork[j];}nDataCwIndex += ncDataCw2;nBlockNo++;}m_nSymbleSize = m_nVersion * 4 + 17;// Module placementFormatModule();for (i = 0; i < m_nSymbleSize; i++) {for (j = 0; j < m_nSymbleSize; j++) {if (!m_byModuleData[i][j]) {putBitToPos((j * m_nSymbleSize) + i + 1, 0, result);} else {putBitToPos((j * m_nSymbleSize) + i + 1, 1, result);}}}return m_nSymbleSize;
}
#ifdef __cplusplus
}
#endif
/** Copyright (c) 2010 Psytec Inc.* Copyright (c) 2012 Alexey Mednyy <swexru@gmail.com>* Copyright (c) 2012 Pavol Rusnak <stick@gk2.sk>** Permission is hereby granted, free of charge, to any person obtaining a copy* of this software and associated documentation files (the "Software"), to deal* in the Software without restriction, including without limitation the rights* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell* copies of the Software, and to permit persons to whom the Software is* furnished to do so, subject to the following conditions:** The above copyright notice and this permission notice shall be included in* all copies or substantial portions of the Software.** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE* SOFTWARE.*/#ifndef __QR_ENCODE_H__
#define __QR_ENCODE_H__#include <stdlib.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif#define QR_MAX_VERSION QR_VERSION_L// Constants// Error correction level
#define QR_LEVEL_L         0    //  7% of codewords can be restored
#define QR_LEVEL_M         1    // 15% of codewords can be restored
#define QR_LEVEL_Q         2    // 25% of codewords can be restored
#define QR_LEVEL_H         3    // 30% of codewords can be restored// Data Mode
#define QR_MODE_NUMERAL    0    // numbers
#define QR_MODE_ALPHABET   1    // alphanumberic
#define QR_MODE_8BIT       2    // rest// Group version (Model number)
#define QR_VERSION_S       0    //  1 -  9 (module  21 -  53)
#define QR_VERSION_M       1    // 10 - 26 (module  57 - 121)
#define QR_VERSION_L       2    // 27 - 40 (module 125 - 177)#ifndef QR_MAX_VERSION
#define QR_MAX_VERSION QR_VERSION_L
#endif// Length constants#if QR_MAX_VERSION == QR_VERSION_S
#define QR_MAX_MODULESIZE     (9 * 4 + 17)                                       // Maximum number of modules in a side
#define QR_MAX_ALLCODEWORD    292                                                // Maximum total number of code words
#define QR_MAX_DATACODEWORD   232                                                // Maximum data word code
#endif#if QR_MAX_VERSION == QR_VERSION_M
#define QR_MAX_MODULESIZE     (26 * 4 + 17)                                      // Maximum number of modules in a side
#define QR_MAX_ALLCODEWORD    1706                                               // Maximum total number of code words
#define QR_MAX_DATACODEWORD   1370                                               // Maximum data word code
#endif#if QR_MAX_VERSION == QR_VERSION_L
#define QR_MAX_MODULESIZE     (40 * 4 + 17)                                      // Maximum number of modules in a side
#define QR_MAX_ALLCODEWORD    3706                                               // Maximum total number of code words
#define QR_MAX_DATACODEWORD   2956                                               // Maximum data word code
#endif#define QR_MAX_BITDATA        ((QR_MAX_MODULESIZE * QR_MAX_MODULESIZE + 7) / 8)  // Maximum size of bit data
#define QR_MAX_CODEBLOCK      153                                                // Maximum number of block data code word (including RS code word)//
// * level - error correction level, use QR_LEVEL_? macros
// * version - version of the code (1-40), use 0 for autodetection
// * source - source data
// * source_len - length of the source data, use 0 when passing zero-terminated string
// * result - array to write, writes to bits
//
// * function returns the size of the square side
//
int qr_encode(int level, int version, const char *source, size_t source_len, uint8_t *result);
#ifdef __cplusplus
}
#endif
#endif
/** Copyright (c) 2010 Psytec Inc.* Copyright (c) 2012 Alexey Mednyy <swexru@gmail.com>* Copyright (c) 2012-2014 Pavol Rusnak <stick@gk2.sk>** Permission is hereby granted, free of charge, to any person obtaining a copy* of this software and associated documentation files (the "Software"), to deal* in the Software without restriction, including without limitation the rights* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell* copies of the Software, and to permit persons to whom the Software is* furnished to do so, subject to the following conditions:** The above copyright notice and this permission notice shall be included in* all copies or substantial portions of the Software.** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE* SOFTWARE.*/#ifndef __QR_CONSTS_H__
#define __QR_CONSTS_H__typedef struct
{uint8_t ncRSBlock;     // RS block numberuint8_t ncAllCodeWord;    // The number of codewords in the blockuint8_t ncDataCodeWord;  // The number of data code words (the number of code words - the number of RS code word)
} RS_BLOCKINFO;typedef struct
{uint8_t nVersionNo;uint16_t ncAllCodeWord;// Error correction levels (0 = L, 1 = M, 2 = Q, 3 = H)uint16_t ncDataCodeWord[4];       // data lenuint8_t ncAlignPoint;            // positionuint8_t nAlignPoint[6];          // numberofRS_BLOCKINFO RS_BlockInfo1[4];   // EC posRS_BLOCKINFO RS_BlockInfo2[4]; // EC pos
} QR_VERSIONINFO;static const QR_VERSIONINFO QR_VersonInfo[] = {{0, 0, {0, 0, 0, 0}, 0, {0, 0, 0, 0, 0, 0}, {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}},{1, 26, {19, 16, 13, 9}, 0, {0, 0, 0, 0, 0, 0}, {{1, 26, 19}, {1, 26, 16}, {1, 26, 13}, {1, 26, 9}}, {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}},{2, 44, {34, 28, 22, 16}, 1, {18, 0, 0, 0, 0, 0}, {{1, 44, 34}, {1, 44, 28}, {1, 44, 22}, {1, 44, 16}}, {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}},{3, 70, {55, 44, 34, 26}, 1, {22, 0, 0, 0, 0, 0}, {{1, 70, 55}, {1, 70, 44}, {2, 35, 17}, {2, 35, 13}}, {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}},{4, 100, {80, 64, 48, 36}, 1, {26, 0, 0, 0, 0, 0}, {{1, 100, 80}, {2, 50, 32}, {2, 50, 24}, {4, 25, 9}}, {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}},{5, 134, {108, 86, 62, 46}, 1, {30, 0, 0, 0, 0, 0}, {{1, 134, 108}, {2, 67, 43}, {2, 33, 15}, {2, 33, 11}}, {{0, 0, 0}, {0, 0, 0}, {2, 34, 16}, {2, 34, 12}}},{6, 172, {136, 108, 76, 60}, 1, {34, 0, 0, 0, 0, 0}, {{2, 86, 68}, {4, 43, 27}, {4, 43, 19}, {4, 43, 15}}, {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}},{7, 196, {156, 124, 88, 66}, 2, {22, 38, 0, 0, 0, 0}, {{2, 98, 78}, {4, 49, 31}, {2, 32, 14}, {4, 39, 13}}, {{0, 0, 0}, {0, 0, 0}, {4, 33, 15}, {1, 40, 14}}},{8, 242, {194, 154, 110, 86}, 2, {24, 42, 0, 0, 0, 0}, {{2, 121, 97}, {2, 60, 38}, {4, 40, 18}, {4, 40, 14}}, {{0, 0, 0}, {2, 61, 39}, {2, 41, 19}, {2, 41, 15}}},{9, 292, {232, 182, 132, 100}, 2, {26, 46, 0, 0, 0, 0}, {{2, 146, 116}, {3, 58, 36}, {4, 36, 16}, {4, 36, 12}}, {{0, 0, 0}, {2, 59, 37}, {4, 37, 17}, {4, 37, 13}}},
#if QR_MAX_VERSION >= QR_VERSION_M{10, 346, {274, 216, 154, 122}, 2, {28, 50, 0, 0, 0, 0}, {{2, 86, 68}, {4, 69, 43}, {6, 43, 19}, {6, 43, 15}}, {{2, 87, 69}, {1, 70, 44}, {2, 44, 20}, {2, 44, 16}}},{11, 404, {324, 254, 180, 140}, 2, {30, 54, 0, 0, 0, 0}, {{4, 101, 81}, {1, 80, 50}, {4, 50, 22}, {3, 36, 12}}, {{0, 0, 0}, {4, 81, 51}, {4, 51, 23}, {8, 37, 13}}},{12, 466, {370, 290, 206, 158}, 2, {32, 58, 0, 0, 0, 0}, {{2, 116, 92}, {6, 58, 36}, {4, 46, 20}, {7, 42, 14}}, {{2, 117, 93}, {2, 59, 37}, {6, 47, 21}, {4, 43, 15}}},{13, 532, {428, 334, 244, 180}, 2, {34, 62, 0, 0, 0, 0}, {{4, 133, 107}, {8, 59, 37}, {8, 44, 20}, {12, 33, 11}}, {{0, 0, 0}, {1, 60, 38}, {4, 45, 21}, {4, 34, 12}}},{14, 581, {461, 365, 261, 197}, 3, {26, 46, 66, 0, 0, 0}, {{3, 145, 115}, {4, 64, 40}, {11, 36, 16}, {11, 36, 12}}, {{1, 146, 116}, {5, 65, 41}, {5, 37, 17}, {5, 37, 13}}},{15, 655, {523, 415, 295, 223}, 3, {26, 48, 70, 0, 0, 0}, {{5, 109, 87}, {5, 65, 41}, {5, 54, 24}, {11, 36, 12}}, {{1, 110, 88}, {5, 66, 42}, {7, 55, 25}, {7, 37, 13}}},{16, 733, {589, 453, 325, 253}, 3, {26, 50, 74, 0, 0, 0}, {{5, 122, 98}, {7, 73, 45}, {15, 43, 19}, {3, 45, 15}}, {{1, 123, 99}, {3, 74, 46}, {2, 44, 20}, {13, 46, 16}}},{17, 815, {647, 507, 367, 283}, 3, {30, 54, 78, 0, 0, 0}, {{1, 135, 107}, {10, 74, 46}, {1, 50, 22}, {2, 42, 14}}, {{5, 136, 108}, {1, 75, 47}, {15, 51, 23}, {17, 43, 15}}},{18, 901, {721, 563, 397, 313}, 3, {30, 56, 82, 0, 0, 0}, {{5, 150, 120}, {9, 69, 43}, {17, 50, 22}, {2, 42, 14}}, {{1, 151, 121}, {4, 70, 44}, {1, 51, 23}, {19, 43, 15}}},{19, 991, {795, 627, 445, 341}, 3, {30, 58, 86, 0, 0, 0}, {{3, 141, 113}, {3, 70, 44}, {17, 47, 21}, {9, 39, 13}}, {{4, 142, 114}, {11, 71, 45}, {4, 48, 22}, {16, 40, 14}}},{20, 1085, {861, 669, 485, 385}, 3, {34, 62, 90, 0, 0, 0}, {{3, 135, 107}, {3, 67, 41}, {15, 54, 24}, {15, 43, 15}}, {{5, 136, 108}, {13, 68, 42}, {5, 55, 25}, {10, 44, 16}}},{21, 1156, {932, 714, 512, 406}, 4, {28, 50, 72, 94, 0, 0}, {{4, 144, 116}, {17, 68, 42}, {17, 50, 22}, {19, 46, 16}}, {{4, 145, 117}, {0, 0, 0}, {6, 51, 23}, {6, 47, 17}}},{22, 1258, {1006, 782, 568, 442}, 4, {26, 50, 74, 98, 0, 0}, {{2, 139, 111}, {17, 74, 46}, {7, 54, 24}, {34, 37, 13}}, {{7, 140, 112}, {0, 0, 0}, {16, 55, 25}, {0, 0, 0}}},{23, 1364, {1094, 860, 614, 464}, 4, {30, 54, 78, 102, 0, 0}, {{4, 151, 121}, {4, 75, 47}, {11, 54, 24}, {16, 45, 15}}, {{5, 152, 122}, {14, 76, 48}, {14, 55, 25}, {14, 46, 16}}},{24, 1474, {1174, 914, 664, 514}, 4, {28, 54, 80, 106, 0, 0}, {{6, 147, 117}, {6, 73, 45}, {11, 54, 24}, {30, 46, 16}}, {{4, 148, 118}, {14, 74, 46}, {16, 55, 25}, {2, 47, 17}}},{25, 1588, {1276, 1000, 718, 538}, 4, {32, 58, 84, 110, 0, 0}, {{8, 132, 106}, {8, 75, 47}, {7, 54, 24}, {22, 45, 15}}, {{4, 133, 107}, {13, 76, 48}, {22, 55, 25}, {13, 46, 16}}},{26, 1706, {1370, 1062, 754, 596}, 4, {30, 58, 86, 114, 0, 0}, {{10, 142, 114}, {19, 74, 46}, {28, 50, 22}, {33, 46, 16}}, {{2, 143, 115}, {4, 75, 47}, {6, 51, 23}, {4, 47, 17}}},
#endif
#if QR_MAX_VERSION >= QR_VERSION_L{27, 1828, {1468, 1128, 808, 628}, 4, {34, 62, 90, 118, 0, 0}, {{8, 152, 122}, {22, 73, 45}, {8, 53, 23}, {12, 45, 15}}, {{4, 153, 123}, {3, 74, 46}, {26, 54, 24}, {28, 46, 16}}},{28, 1921, {1531, 1193, 871, 661}, 5, {26, 50, 74, 98, 122, 0}, {{3, 147, 117}, {3, 73, 45}, {4, 54, 24}, {11, 45, 15}}, {{10, 148, 118}, {23, 74, 46}, {31, 55, 25}, {31, 46, 16}}},{29, 2051, {1631, 1267, 911, 701}, 5, {30, 54, 78, 102, 126, 0}, {{7, 146, 116}, {21, 73, 45}, {1, 53, 23}, {19, 45, 15}}, {{7, 147, 117}, {7, 74, 46}, {37, 54, 24}, {26, 46, 16}}},{30, 2185, {1735, 1373, 985, 745}, 5, {26, 52, 78, 104, 130, 0}, {{5, 145, 115}, {19, 75, 47}, {15, 54, 24}, {23, 45, 15}}, {{10, 146, 116}, {10, 76, 48}, {25, 55, 25}, {25, 46, 16}}},{31, 2323, {1843, 1455, 1033, 793}, 5, {30, 56, 82, 108, 134, 0}, {{13, 145, 115}, {2, 74, 46}, {42, 54, 24}, {23, 45, 15}}, {{3, 146, 116}, {29, 75, 47}, {1, 55, 25}, {28, 46, 16}}},{32, 2465, {1955, 1541, 1115, 845}, 5, {34, 60, 86, 112, 138, 0}, {{17, 145, 115}, {10, 74, 46}, {10, 54, 24}, {19, 45, 15}}, {{0, 0, 0}, {23, 75, 47}, {35, 55, 25}, {35, 46, 16}}},{33, 2611, {2071, 1631, 1171, 901}, 5, {30, 58, 86, 114, 142, 0}, {{17, 145, 115}, {14, 74, 46}, {29, 54, 24}, {11, 45, 15}}, {{1, 146, 116}, {21, 75, 47}, {19, 55, 25}, {46, 46, 16}}},{34, 2761, {2191, 1725, 1231, 961}, 5, {34, 62, 90, 118, 146, 0}, {{13, 145, 115}, {14, 74, 46}, {44, 54, 24}, {59, 46, 16}}, {{6, 146, 116}, {23, 75, 47}, {7, 55, 25}, {1, 47, 17}}},{35, 2876, {2306, 1812, 1286, 986}, 6, {30, 54, 78, 102, 126, 150}, {{12, 151, 121}, {12, 75, 47}, {39, 54, 24}, {22, 45, 15}}, {{7, 152, 122}, {26, 76, 48}, {14, 55, 25}, {41, 46, 16}}},{36, 3034, {2434, 1914, 1354, 1054}, 6, {24, 50, 76, 102, 128, 154}, {{6, 151, 121}, {6, 75, 47}, {46, 54, 24}, {2, 45, 15}}, {{14, 152, 122}, {34, 76, 48}, {10, 55, 25}, {64, 46, 16}}},{37, 3196, {2566, 1992, 1426, 1096}, 6, {28, 54, 80, 106, 132, 158}, {{17, 152, 122}, {29, 74, 46}, {49, 54, 24}, {24, 45, 15}}, {{4, 153, 123}, {14, 75, 47}, {10, 55, 25}, {46, 46, 16}}},{38, 3362, {2702, 2102, 1502, 1142}, 6, {32, 58, 84, 110, 136, 162}, {{4, 152, 122}, {13, 74, 46}, {48, 54, 24}, {42, 45, 15}}, {{18, 153, 123}, {32, 75, 47}, {14, 55, 25}, {32, 46, 16}}},{39, 3532, {2812, 2216, 1582, 1222}, 6, {26, 54, 82, 110, 138, 166}, {{20, 147, 117}, {40, 75, 47}, {43, 54, 24}, {10, 45, 15}}, {{4, 148, 118}, {7, 76, 48}, {22, 55, 25}, {67, 46, 16}}},{40, 3706, {2956, 2334, 1666, 1276}, 6, {30, 58, 86, 114, 142, 170}, {{19, 148, 118}, {18, 75, 47}, {34, 54, 24}, {20, 45, 15}}, {{6, 149, 119}, {31, 76, 48}, {34, 55, 25}, {61, 46, 16}}},
#endif
};static const uint8_t byExpToInt[] = {1, 2, 4, 8, 16, 32, 64, 128, 29, 58, 116, 232, 205, 135, 19, 38, 76, 152, 45, 90, 180, 117, 234, 201, 143, 3, 6, 12, 24, 48, 96, 192, 157, 39, 78, 156, 37, 74, 148, 53, 106, 212, 181, 119, 238, 193, 159, 35, 70, 140, 5, 10, 20, 40, 80, 160, 93, 186, 105, 210, 185, 111, 222, 161, 95, 190, 97, 194, 153, 47, 94, 188, 101, 202, 137, 15, 30, 60, 120, 240, 253, 231, 211, 187, 107, 214, 177, 127, 254, 225, 223, 163, 91, 182, 113, 226, 217, 175, 67, 134, 17, 34, 68, 136, 13, 26, 52, 104, 208, 189, 103, 206, 129, 31, 62, 124, 248, 237, 199, 147, 59, 118, 236, 197, 151, 51, 102, 204, 133, 23, 46, 92, 184, 109, 218, 169, 79, 158, 33, 66, 132, 21, 42, 84, 168, 77, 154, 41, 82, 164, 85, 170, 73, 146, 57, 114, 228, 213, 183, 115, 230, 209, 191, 99, 198, 145, 63, 126, 252, 229, 215, 179, 123, 246, 241, 255, 227, 219, 171, 75, 150, 49, 98, 196, 149, 55, 110, 220, 165, 87, 174, 65, 130, 25, 50, 100, 200, 141, 7, 14, 28, 56, 112, 224, 221, 167, 83, 166, 81, 162, 89, 178, 121, 242, 249, 239, 195, 155, 43, 86, 172, 69, 138, 9, 18, 36, 72, 144, 61, 122, 244, 245, 247, 243, 251, 235, 203, 139, 11, 22, 44, 88, 176, 125, 250, 233, 207, 131, 27, 54, 108, 216, 173, 71, 142, 1};
static const uint8_t byIntToExp[] = {0, 0, 1, 25, 2, 50, 26, 198, 3, 223, 51, 238, 27, 104, 199, 75, 4, 100, 224, 14, 52, 141, 239, 129, 28, 193, 105, 248, 200, 8, 76, 113, 5, 138, 101, 47, 225, 36, 15, 33, 53, 147, 142, 218, 240, 18, 130, 69, 29, 181, 194, 125, 106, 39, 249, 185, 201, 154, 9, 120, 77, 228, 114, 166, 6, 191, 139, 98, 102, 221, 48, 253, 226, 152, 37, 179, 16, 145, 34, 136, 54, 208, 148, 206, 143, 150, 219, 189, 241, 210, 19, 92, 131, 56, 70, 64, 30, 66, 182, 163, 195, 72, 126, 110, 107, 58, 40, 84, 250, 133, 186, 61, 202, 94, 155, 159, 10, 21, 121, 43, 78, 212, 229, 172, 115, 243, 167, 87, 7, 112, 192, 247, 140, 128, 99, 13, 103, 74, 222, 237, 49, 197, 254, 24, 227, 165, 153, 119, 38, 184, 180, 124, 17, 68, 146, 217, 35, 32, 137, 46, 55, 63, 209, 91, 149, 188, 207, 205, 144, 135, 151, 178, 220, 252, 190, 97, 242, 86, 211, 171, 20, 42, 93, 158, 132, 60, 57, 83, 71, 109, 65, 162, 31, 45, 67, 216, 183, 123, 164, 118, 196, 23, 73, 236, 127, 12, 111, 246, 108, 161, 59, 82, 41, 157, 85, 170, 251, 96, 134, 177, 187, 204, 62, 90, 203, 89, 95, 176, 156, 169, 160, 81, 11, 245, 22, 235, 122, 117, 44, 215, 79, 174, 213, 233, 230, 231, 173, 232, 116, 214, 244, 234, 168, 80, 88, 175};static const uint8_t byRSExp7[] = {87, 229, 146, 149, 238, 102, 21};
static const uint8_t byRSExp10[] = {251, 67, 46, 61, 118, 70, 64, 94, 32, 45};
static const uint8_t byRSExp13[] = {74, 152, 176, 100, 86, 100, 106, 104, 130, 218, 206, 140, 78};
static const uint8_t byRSExp15[] = {8, 183, 61, 91, 202, 37, 51, 58, 58, 237, 140, 124, 5, 99, 105};
static const uint8_t byRSExp16[] = {120, 104, 107, 109, 102, 161, 76, 3, 91, 191, 147, 169, 182, 194, 225, 120};
static const uint8_t byRSExp17[] = {43, 139, 206, 78, 43, 239, 123, 206, 214, 147, 24, 99, 150, 39, 243, 163, 136};
static const uint8_t byRSExp18[] = {215, 234, 158, 94, 184, 97, 118, 170, 79, 187, 152, 148, 252, 179, 5, 98, 96, 153};
static const uint8_t byRSExp20[] = {17, 60, 79, 50, 61, 163, 26, 187, 202, 180, 221, 225, 83, 239, 156, 164, 212, 212, 188, 190};
static const uint8_t byRSExp22[] = {210, 171, 247, 242, 93, 230, 14, 109, 221, 53, 200, 74, 8, 172, 98, 80, 219, 134, 160, 105, 165, 231};
static const uint8_t byRSExp24[] = {229, 121, 135, 48, 211, 117, 251, 126, 159, 180, 169, 152, 192, 226, 228, 218, 111, 0, 117, 232, 87, 96, 227, 21};
static const uint8_t byRSExp26[] = {173, 125, 158, 2, 103, 182, 118, 17, 145, 201, 111, 28, 165, 53, 161, 21, 245, 142, 13, 102, 48, 227, 153, 145, 218, 70};
static const uint8_t byRSExp28[] = {168, 223, 200, 104, 224, 234, 108, 180, 110, 190, 195, 147, 205, 27, 232, 201, 21, 43, 245, 87, 42, 195, 212, 119, 242, 37, 9, 123};
static const uint8_t byRSExp30[] = {41, 173, 145, 152, 216, 31, 179, 182, 50, 48, 110, 86, 239, 96, 222, 125, 42, 173, 226, 193, 224, 130, 156, 37, 251, 216, 238, 40, 192, 180};
static const uint8_t byRSExp32[] = {10, 6, 106, 190, 249, 167, 4, 67, 209, 138, 138, 32, 242, 123, 89, 27, 120, 185, 80, 156, 38, 69, 171, 60, 28, 222, 80, 52, 254, 185, 220, 241};
static const uint8_t byRSExp34[] = {111, 77, 146, 94, 26, 21, 108, 19, 105, 94, 113, 193, 86, 140, 163, 125, 58, 158, 229, 239, 218, 103, 56, 70, 114, 61, 183, 129, 167, 13, 98, 62, 129, 51};
static const uint8_t byRSExp36[] = {200, 183, 98, 16, 172, 31, 246, 234, 60, 152, 115, 0, 167, 152, 113, 248, 238, 107, 18, 63, 218, 37, 87, 210, 105, 177, 120, 74, 121, 196, 117, 251, 113, 233, 30, 120};
static const uint8_t byRSExp38[] = {159, 34, 38, 228, 230, 59, 243, 95, 49, 218, 176, 164, 20, 65, 45, 111, 39, 81, 49, 118, 113, 222, 193, 250, 242, 168, 217, 41, 164, 247, 177, 30, 238, 18, 120, 153, 60, 193};
static const uint8_t byRSExp40[] = {59, 116, 79, 161, 252, 98, 128, 205, 128, 161, 247, 57, 163, 56, 235, 106, 53, 26, 187, 174, 226, 104, 170, 7, 175, 35, 181, 114, 88, 41, 47, 163, 125, 134, 72, 20, 232, 53, 35, 15};
static const uint8_t byRSExp42[] = {250, 103, 221, 230, 25, 18, 137, 231, 0, 3, 58, 242, 221, 191, 110, 84, 230, 8, 188, 106, 96, 147, 15, 131, 139, 34, 101, 223, 39, 101, 213, 199, 237, 254, 201, 123, 171, 162, 194, 117, 50, 96};
static const uint8_t byRSExp44[] = {190, 7, 61, 121, 71, 246, 69, 55, 168, 188, 89, 243, 191, 25, 72, 123, 9, 145, 14, 247, 1, 238, 44, 78, 143, 62, 224, 126, 118, 114, 68, 163, 52, 194, 217, 147, 204, 169, 37, 130, 113, 102, 73, 181};
static const uint8_t byRSExp46[] = {112, 94, 88, 112, 253, 224, 202, 115, 187, 99, 89, 5, 54, 113, 129, 44, 58, 16, 135, 216, 169, 211, 36, 1, 4, 96, 60, 241, 73, 104, 234, 8, 249, 245, 119, 174, 52, 25, 157, 224, 43, 202, 223, 19, 82, 15};
static const uint8_t byRSExp48[] = {228, 25, 196, 130, 211, 146, 60, 24, 251, 90, 39, 102, 240, 61, 178, 63, 46, 123, 115, 18, 221, 111, 135, 160, 182, 205, 107, 206, 95, 150, 120, 184, 91, 21, 247, 156, 140, 238, 191, 11, 94, 227, 84, 50, 163, 39, 34, 108};
static const uint8_t byRSExp50[] = {232, 125, 157, 161, 164, 9, 118, 46, 209, 99, 203, 193, 35, 3, 209, 111, 195, 242, 203, 225, 46, 13, 32, 160, 126, 209, 130, 160, 242, 215, 242, 75, 77, 42, 189, 32, 113, 65, 124, 69, 228, 114, 235, 175, 124, 170, 215, 232, 133, 205};
static const uint8_t byRSExp52[] = {116, 50, 86, 186, 50, 220, 251, 89, 192, 46, 86, 127, 124, 19, 184, 233, 151, 215, 22, 14, 59, 145, 37, 242, 203, 134, 254, 89, 190, 94, 59, 65, 124, 113, 100, 233, 235, 121, 22, 76, 86, 97, 39, 242, 200, 220, 101, 33, 239, 254, 116, 51};
static const uint8_t byRSExp54[] = {183, 26, 201, 87, 210, 221, 113, 21, 46, 65, 45, 50, 238, 184, 249, 225, 102, 58, 209, 218, 109, 165, 26, 95, 184, 192, 52, 245, 35, 254, 238, 175, 172, 79, 123, 25, 122, 43, 120, 108, 215, 80, 128, 201, 235, 8, 153, 59, 101, 31, 198, 76, 31, 156};
static const uint8_t byRSExp56[] = {106, 120, 107, 157, 164, 216, 112, 116, 2, 91, 248, 163, 36, 201, 202, 229, 6, 144, 254, 155, 135, 208, 170, 209, 12, 139, 127, 142, 182, 249, 177, 174, 190, 28, 10, 85, 239, 184, 101, 124, 152, 206, 96, 23, 163, 61, 27, 196, 247, 151, 154, 202, 207, 20, 61, 10};
static const uint8_t byRSExp58[] = {82, 116, 26, 247, 66, 27, 62, 107, 252, 182, 200, 185, 235, 55, 251, 242, 210, 144, 154, 237, 176, 141, 192, 248, 152, 249, 206, 85, 253, 142, 65, 165, 125, 23, 24, 30, 122, 240, 214, 6, 129, 218, 29, 145, 127, 134, 206, 245, 117, 29, 41, 63, 159, 142, 233, 125, 148, 123};
static const uint8_t byRSExp60[] = {107, 140, 26, 12, 9, 141, 243, 197, 226, 197, 219, 45, 211, 101, 219, 120, 28, 181, 127, 6, 100, 247, 2, 205, 198, 57, 115, 219, 101, 109, 160, 82, 37, 38, 238, 49, 160, 209, 121, 86, 11, 124, 30, 181, 84, 25, 194, 87, 65, 102, 190, 220, 70, 27, 209, 16, 89, 7, 33, 240};
static const uint8_t byRSExp62[] = {65, 202, 113, 98, 71, 223, 248, 118, 214, 94, 0, 122, 37, 23, 2, 228, 58, 121, 7, 105, 135, 78, 243, 118, 70, 76, 223, 89, 72, 50, 70, 111, 194, 17, 212, 126, 181, 35, 221, 117, 235, 11, 229, 149, 147, 123, 213, 40, 115, 6, 200, 100, 26, 246, 182, 218, 127, 215, 36, 186, 110, 106};
static const uint8_t byRSExp64[] = {45, 51, 175, 9, 7, 158, 159, 49, 68, 119, 92, 123, 177, 204, 187, 254, 200, 78, 141, 149, 119, 26, 127, 53, 160, 93, 199, 212, 29, 24, 145, 156, 208, 150, 218, 209, 4, 216, 91, 47, 184, 146, 47, 140, 195, 195, 125, 242, 238, 63, 99, 108, 140, 230, 242, 31, 204, 11, 178, 243, 217, 156, 213, 231};
static const uint8_t byRSExp66[] = {5, 118, 222, 180, 136, 136, 162, 51, 46, 117, 13, 215, 81, 17, 139, 247, 197, 171, 95, 173, 65, 137, 178, 68, 111, 95, 101, 41, 72, 214, 169, 197, 95, 7, 44, 154, 77, 111, 236, 40, 121, 143, 63, 87, 80, 253, 240, 126, 217, 77, 34, 232, 106, 50, 168, 82, 76, 146, 67, 106, 171, 25, 132, 93, 45, 105};
static const uint8_t byRSExp68[] = {247, 159, 223, 33, 224, 93, 77, 70, 90, 160, 32, 254, 43, 150, 84, 101, 190, 205, 133, 52, 60, 202, 165, 220, 203, 151, 93, 84, 15, 84, 253, 173, 160, 89, 227, 52, 199, 97, 95, 231, 52, 177, 41, 125, 137, 241, 166, 225, 118, 2, 54, 32, 82, 215, 175, 198, 43, 238, 235, 27, 101, 184, 127, 3, 5, 8, 163, 238};
static const uint8_t* byRSExp[] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, byRSExp7, NULL, NULL, byRSExp10, NULL, NULL, byRSExp13, NULL, byRSExp15, byRSExp16, byRSExp17, byRSExp18, NULL, byRSExp20, NULL, byRSExp22, NULL, byRSExp24, NULL, byRSExp26, NULL, byRSExp28, NULL, byRSExp30, NULL, byRSExp32, NULL, byRSExp34, NULL, byRSExp36, NULL, byRSExp38, NULL, byRSExp40, NULL, byRSExp42, NULL, byRSExp44, NULL, byRSExp46, NULL, byRSExp48, NULL, byRSExp50, NULL, byRSExp52, NULL, byRSExp54, NULL, byRSExp56, NULL, byRSExp58, NULL, byRSExp60, NULL, byRSExp62, NULL, byRSExp64, NULL, byRSExp66, NULL, byRSExp68};static const int nIndicatorLenNumeral[] = {10, 12, 14};
static const int nIndicatorLenAlphabet[] = {9, 11, 13};
static const int nIndicatorLen8Bit[] = {8, 16, 16};#endif
/**********************************************************************
* 函数名:void GenBarCode(HDC hDC, int iL, int iT, int iB, CString csCode, int iStyle, int iMap);
* 参  数:
*   hDC:画布句柄
*   iL:左上角 X坐标
*   iT:左上角 Y坐标
*   iB:条码高度
*   csCode:条码内容
*   iStyle:条码格式
*   iMap:
* 返回值:无
* 描  述:画条码到指定HDC
**********************************************************************/
void GenBarCode(HDC hDC, int iL, int iT, int iB, CString csCode, int iStyle, int iMap, int iWidth)
{COLORREF clrBar = RGB(0, 0, 0);COLORREF clrSpace = RGB(255, 255, 255);int iPenW = 2;switch (iStyle){case 0:{Barcode39 code;code.Encode39(csCode);code.DrawBarcodeWidth(hDC, iL, iT, iB - 10, iB, clrBar, clrSpace, iPenW, iWidth);}break;case 1:{Barcode93 code;code.Encode93(csCode);code.DrawBarcodeWidth(hDC, iL, iT, iB - 10, iB, clrBar, clrSpace, iPenW, iWidth);}break;case 2: //自动 包含小写 就是128B{Barcode128 code;if (isContainLowercaseletters(csCode)) {code.Encode128B(csCode);}else{code.Encode128A(csCode);}code.DrawBarcodeWidth(hDC, iL, iT, iB - 10, iB, clrBar, clrSpace, iPenW, iWidth);}break;case 3: {Barcode128 code;code.Encode128B(csCode);code.DrawBarcodeWidth(hDC, iL, iT, iB - 10, iB, clrBar, clrSpace, iPenW, iWidth);}break;case 4: {Barcode128 code;code.Encode128C(csCode);code.DrawBarcodeWidth(hDC, iL, iT, iB - 10, iB, clrBar, clrSpace, iPenW, iWidth);}break;case 5: {BarcodeI2of5 code;code.EncodeI2of5(csCode);code.DrawBarcodeWidth(hDC, iL, iT, iB - 10, iB, clrBar, clrSpace, iPenW, iWidth);}break;case 6: {BarcodeEan13 code;code.EncodeEan13(csCode);code.DrawBarcodeWidth(hDC, iL, iT, iB - 10, iB, clrBar, clrSpace, iPenW, iWidth);}break;default:break;}
}
#ifndef Barcode_h_djdfkjdjkfgjgjghdhdhdgdgfgfgfgeue
#define Barcode_h_djdfkjdjkfgjgjghdhdhdgdgfgfgfgeueclass Barcode39;
class Barcode93;
class BarcodeIof5;
class Barcode128;const int ga2_Code128[2][207]=
{{64,  65,  66,  67,  68,  69,  70,  71,  72,  73,  74,  75,  76,  77,  78,  79,80,  81,  82,  83,  84,  85,  86,  87,  88,  89,  90,  91,  92,  93,  94,  95,0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,  15,16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31,32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,  45,  46,  47,48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,  60,  61,  62,  63,-1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,-1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,-1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,-1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,-1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,-1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,-1,  -1,  -1,  95,  96,  97,  98,  99, 100, 101, 102, 103, 104, 105, 106,},{-1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,-1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,  15,16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31,32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,  45,  46,  47,48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,  60,  61,  62,  63,64,  65,  66,  67,  68,  69,  70,  71,  72,  73,  74,  75,  76,  77,  78,  79,80,  81,  82,  83,  84,  85,  86,  87,  88,  89,  90,  91,  92,  93,  94,  -1,-1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,-1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,-1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,-1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,-1,  -1,  -1,  95,  96,  97,  98,  99, 100, 101, 102, 103, 104, 105, 106,},
};class BarcodeBase
{
public:BarcodeBase(){Clear();i_Ratio=3;}void operator=(const BarcodeBase&bc){i_LenBuf=bc.i_LenBuf;i_Ratio    =bc.i_Ratio;memcpy(ia_Buf,bc.ia_Buf,sizeof(ia_Buf));}void Clear(){memset(ia_Buf,0,sizeof(ia_Buf));i_LenBuf=0;}int GetEncodeLength()   const{BYTE*pb=(BYTE*)ia_Buf;int i,iLen=0;for(i=0;i<i_LenBuf;i++){//wide is 3if(*pb&2)   iLen+=(i_Ratio-1);pb++;}return iLen+i_LenBuf;}int GetBufferLength()    const{return i_LenBuf;}const BYTE&GetAt(int i)  const {return ia_Buf[i];}int GetRatio() const{return i_Ratio;}int SetRatio(int iRatio){i_Ratio=iRatio;if(i_Ratio<=0)   i_Ratio=1;}int DrawBarcode(HDC hDC2,int iX2,int iY02,int iY102,int iY112,const COLORREF clrBar,const COLORREF clrSpace,const int iPenW){HPEN hPenBar = ::CreatePen(PS_SOLID, iPenW, clrBar);HPEN hPenSpace = ::CreatePen(PS_SOLID, iPenW, clrSpace);int iR = 0;HPEN hPenOld;HDC hDC;HDC memDC;HBITMAP hBitmap;hDC = CreateCompatibleDC(NULL);//创建兼容内存memDC = CreateCompatibleDC(hDC);SetBkColor(memDC, RGB(255, 255, 255));//白色背景hBitmap = CreateCompatibleBitmap(hDC, 1024, 800);SelectObject(memDC, hBitmap);hPenOld = (HPEN)::SelectObject(memDC, hPenBar);BYTE*pb = ia_Buf;int i0, iNum0 = i_LenBuf;BYTE bBar;int i1, iNum1;int iY;int iX = 0;int iY0 = 0;int iY10 = iY102;int iY11 = iY112;for (i0 = 0;i0<iNum0;i0++){bBar = *pb & 0x01;iNum1 = (*pb & 0x02) ? i_Ratio : 1;iY = (*pb & 0x04) ? iY11 : iY10;for (i1 = 0;i1<iNum1;i1++){if (bBar)   ::SelectObject(memDC, hPenBar);else     ::SelectObject(memDC, hPenSpace);::MoveToEx(memDC, iX, iY0, 0);::LineTo(memDC, iX, iY);iX += iPenW;}pb++;}iR = iX;::SelectObject(memDC, hPenOld);::SetStretchBltMode(hDC2,HALFTONE);//::SetStretchBltMode(memDC, HALFTONE);POINT point;::SetBrushOrgEx(hDC2, 0, 0, &point);::StretchBlt(hDC2, iX2, iY02, 1256, iY112 - iY02, memDC, 0, 0, iR, iY112 - iY02, SRCCOPY);::DeleteObject(hPenBar);::DeleteObject(hPenSpace);return iR;}int DrawBarcodeWidth(HDC hDC2,int iX2,int iY02,int iY102,int iY112,const COLORREF clrBar,const COLORREF clrSpace,const int iPenW, int iWidth){HPEN hPenBar = ::CreatePen(PS_SOLID, iPenW, clrBar);HPEN hPenSpace = ::CreatePen(PS_SOLID, iPenW, clrSpace);int iR = 0;HPEN hPenOld;HDC hDC;HDC memDC;HBITMAP hBitmap;hDC = CreateCompatibleDC(NULL);//创建兼容内存memDC = CreateCompatibleDC(hDC);SetBkColor(memDC, RGB(255, 255, 255));//白色背景hBitmap = CreateCompatibleBitmap(hDC, 1024, 800);SelectObject(memDC, hBitmap);hPenOld = (HPEN)::SelectObject(memDC, hPenBar);BYTE*pb = ia_Buf;int i0, iNum0 = i_LenBuf;BYTE bBar;int i1, iNum1;int iY;int iX = 0;int iY0 = 0;int iY10 = iY102;int iY11 = iY112;for (i0 = 0;i0<iNum0;i0++){bBar = *pb & 0x01;iNum1 = (*pb & 0x02) ? i_Ratio : 1;iY = (*pb & 0x04) ? iY11 : iY10;for (i1 = 0;i1<iNum1;i1++){if (bBar)   ::SelectObject(memDC, hPenBar);else     ::SelectObject(memDC, hPenSpace);::MoveToEx(memDC, iX, iY0, 0);::LineTo(memDC, iX, iY);iX += iPenW;}pb++;}iR = iX;::SelectObject(memDC, hPenOld);::SetStretchBltMode(hDC2,HALFTONE);//::SetStretchBltMode(memDC, HALFTONE);POINT point;::SetBrushOrgEx(hDC2, 0, 0, &point);::StretchBlt(hDC2, iX2, iY02, iWidth, iY112 - iY02, memDC, 0, 0, iR, iY112 - iY02, SRCCOPY);::DeleteObject(hPenBar);::DeleteObject(hPenSpace);return iR;}protected:BYTE ia_Buf[4096];int        i_LenBuf;int        i_Ratio;struct IntString{int ch;char*psz;};};class Barcode39:public BarcodeBase
{//[n/a][n/a][n/a][n/a][n/a][n/a][w-n][b-s]
public:Barcode39(){}~Barcode39(){}BOOL Encode39(const char*pszCodeIn){int iLen=strlen(pszCodeIn);char*pszCode=new char[iLen+3];sprintf_s(pszCode, iLen + 3, "*%s*",pszCodeIn);_strupr_s(pszCode, iLen + 3);BYTE*pFst=ia_Buf;BYTE*p0=pFst,*p1=NULL;iLen+=2;int i;for(i=0;i<iLen;i++){p1=P_GetNarrowWideBarSpace39(pszCode[i],p0);if(p1==0)  return 0;p0=p1;}i_LenBuf=p1-pFst;delete []pszCode;return 1;}void Draw39(HDC hDC,int iX,int iY0,int iY1,const COLORREF clrBar,const COLORREF clrSpace,const int iPenW){DrawBarcode(hDC,iX,iY0,iY1,iY1,clrBar,clrSpace,iPenW);}private:BYTE*P_GetNarrowWideBarSpace39(char ch,BYTE*pb){IntString infs[]={{'1',   "wnnwnnnnwn"},{'2', "nnwwnnnnwn"},{'3', "wnwwnnnnnn"},{'4', "nnnwwnnnwn"},{'5', "wnnwwnnnnn"},{'6', "nnwwwnnnnn"},{'7', "nnnwnnwnwn"},{'8', "wnnwnnwnnn"},{'9', "nnwwnnwnnn"},{'0', "nnnwwnwnnn"},{'A', "wnnnnwnnwn"},{'B', "nnwnnwnnwn"},{'C', "wnwnnwnnnn"},{'D', "nnnnwwnnwn"},{'E', "wnnnwwnnnn"},{'F', "nnwnwwnnnn"},{'G', "nnnnnwwnwn"},{'H', "wnnnnwwnnn"},{'I', "nnwnnwwnnn"},{'J', "nnnnwwwnnn"},{'K', "wnnnnnnwwn"},{'L', "nnwnnnnwwn"},{'M', "wnwnnnnwnn"},{'N', "nnnnwnnwwn"},{'O', "wnnnwnnwnn"},{'P', "nnwnwnnwnn"},{'Q', "nnnnnnwwwn"},{'R', "wnnnnnwwnn"},{'S', "nnwnnnwwnn"},{'T', "nnnnwnwwnn"},{'U', "wwnnnnnnwn"},{'V', "nwwnnnnnwn"},{'W', "wwwnnnnnnn"},{'X', "nwnnwnnnwn"},{'Y', "wwnnwnnnnn"},{'Z', "nwwnwnnnnn"},{'-', "nwnnnnwnwn"},{'.', "wwnnnnwnnn"},{' ', "nwwnnnwnnn"},{'*', "nwnnwnwnnn"},{'$', "nwnwnwnnnn"},{'/', "nwnwnnnwnn"},{'+',    "nwnnnwnwnn"},{'%', "nnnwnwnwnn"},};int i0,iNum0=sizeof(infs)/sizeof(infs[0]);int i1;for(i0=0;i0<iNum0;i0++){IntString&inf=infs[i0];if(inf.ch==ch){for(i1=0;i1<10;i1++){if(inf.psz[i1]=='w')  *pb+=2;if(i1%2==0)          *pb+=1;pb++;}return pb;}}return 0;}
};class BarcodeI2of5:public BarcodeBase
{//[n/a][n/a][n/a][n/a][n/a][n/a][w-n][b-s]
public:BarcodeI2of5(){}~BarcodeI2of5(){}BOOL EncodeI2of5(const char*pszCode){Clear();BYTE*pFst=ia_Buf;BYTE*pb=pFst;const int iNum=strlen(pszCode);int i;//"nnnn"for(i=0;i<4;i++){if(i%2==0)    *pb+=1;pb++;}int iV;for(i=0;i<iNum;i+=2){iV=pszCode[i]-'0';iV=iV*10;iV+=pszCode[i+1]-'0';pb=P_GetNarrorWideBarSpaceI2of5(pb,iV);if(pb==0) return 0;}//"wnn"*pb+=3;    pb++;*pb+=0;    pb++;*pb+=1;    pb++;i_LenBuf=pb-pFst;return 1;}void DrawI2of5(HDC hDC,int iX,int iY0,int iY1,const COLORREF clrBar,const COLORREF clrSpace,const int iPenW){DrawBarcode(hDC,iX,iY0,iY1,iY1,clrBar,clrSpace,iPenW);}private:BYTE*P_GetNarrorWideBarSpaceI2of5(BYTE*pb,int ch){if(ch<0)    return 0;if(ch>99)   return 0;IntString infs[]={{0,     "nnnnwwwwnn"},{1,     "nwnnwnwnnw"},{2,     "nnnwwnwnnw"},{3,     "nwnwwnwnnn"},{4,     "nnnnwwwnnw"},{5,     "nwnnwwwnnn"},{6,     "nnnwwwwnnn"},{7,     "nnnnwnwwnw"},{8,     "nwnnwnwwnn"},{9,     "nnnwwnwwnn"},{10,    "wnnnnwnwwn"},{11,    "wwnnnnnnww"},{12,    "wnnwnnnnww"},{13,    "wwnwnnnnwn"},{14,    "wnnnnwnnww"},{15,    "wwnnnwnnwn"},{16,    "wnnwnwnnwn"},{17,    "wnnnnnnwww"},{18,    "wwnnnnnwwn"},{19,    "wnnwnnnwwn"},{20,    "nnwnnwnwwn"},{21,    "nwwnnnnnww"},{22,    "nnwwnnnnww"},{23,    "nwwwnnnnwn"},{24,    "nnwnnwnnww"},{25,    "nwwnnwnnwn"},{26,    "nnwwnwnnwn"},{27,    "nnwnnnnwww"},{28,    "nwwnnnnwwn"},{29,    "nnwwnnnwwn"},{30,    "wnwnnwnwnn"},{31,    "wwwnnnnnnw"},{32,    "wnwwnnnnnw"},{33,    "wwwwnnnnnn"},{34,    "wnwnnwnnnw"},{35,    "wwwnnwnnnn"},{36,    "wnwwnwnnnn"},{37,    "wnwnnnnwnw"},{38,    "wwwnnnnwnn"},{39,    "wnwwnnnwnn"},{40,    "nnnnwwnwwn"},{41,    "nwnnwnnnww"},{42,    "nnnwwnnnww"},{43,    "nwnwwnnnwn"},{44,    "nnnnwwnnww"},{45,    "nwnnwwnnwn"},{46,    "nnnwwwnnwn"},{47,    "nnnnwnnwww"},{48,    "nwnnwnnwwn"},{49,    "nnnwwnnwwn"},{50,    "wnnnwwnwnn"},{51,    "wwnnwnnnnw"},{52,    "wnnwwnnnnw"},{53,    "wwnwwnnnnn"},{54,    "wnnnwwnnnw"},{55,    "wwnnwwnnnn"},{56,    "wnnwwwnnnn"},{57,    "wnnnwnnwnw"},{58,    "wwnnwnnwnn"},{59,    "wnnwwnnwnn"},{60,    "nnwnwwnwnn"},{61,    "nwwnwnnnnw"},{62,    "nnwwwnnnnw"},{63,    "nwwwwnnnnn"},{64,    "nnwnwwnnnw"},{65,    "nwwnwwnnnn"},{66,    "nnwwwwnnnn"},{67,    "nnwnwnnwnw"},{68,    "nwwnwnnwnn"},{69,    "nnwwwnnwnn"},{70,    "nnnnnwwwwn"},{71,    "nwnnnnwnww"},{72,    "nnnwnnwnww"},{73,    "nwnwnnwnwn"},{74,    "nnnnnwwnww"},{75,    "nwnnnwwnwn"},{76,    "nnnwnwwnwn"},{77,    "nnnnnnwwww"},{78,    "nwnnnnwwwn"},{79,    "nnnwnnwwwn"},{80,    "wnnnnwwwnn"},{81,    "wwnnnnwnnw"},{82,    "wnnwnnwnnw"},{83,    "wwnwnnwnnn"},{84,    "wnnnnwwnnw"},{85,    "wwnnnwwnnn"},{86,    "wnnwnwwnnn"},{87,    "wnnnnnwwnw"},{88,    "wwnnnnwwnn"},{89,    "wnnwnnwwnn"},{90,    "nnwnnwwwnn"},{91,    "nwwnnnwnnw"},{92,    "nnwwnnwnnw"},{93,    "nwwwnnwnnn"},{94,    "nnwnnwwnnw"},{95,    "nwwnnwwnnn"},{96,    "nnwwnwwnnn"},{97,    "nnwnnnwwnw"},{98,    "nwwnnnwwnn"},{99,    "nnwwnnwwnn"},};IntString&inf=infs[ch];int i;for(i=0;i<10;i++){if(inf.psz[i]=='w') *pb+=2;if(i%2==0)           *pb+=1;pb++;}return pb;}
};class Barcode93:public BarcodeBase
{//[n/a][n/a][n/a][n/a][n/a][n/a][n/a][b-s]
public:Barcode93(){}~Barcode93(){}BOOL Encode93(const char* pszCode){Clear();const int iNum=strlen(pszCode);BYTE*pFst=ia_Buf;BYTE*pb=pFst;pb=P_GetBarSpace93(pb,47);if(pb==0) return 0;BOOL b;int i,iFirst,iSecond;for(i=0;i<iNum;i++){b=P_AscIItoCode93Sequence((int)pszCode[i],iFirst,iSecond);if(b==0)    return 0;pb=P_GetBarSpace93(pb,iFirst);if(pb==0) return 0;if(iSecond!=-1){pb=P_GetBarSpace93(pb,iSecond);if(pb==0)   return 0;}}pb=P_GetCheckDigits(pb,pszCode);if(pb==0) return 0;pb=P_GetBarSpace93(pb,48);if(pb==0) return 0;i_LenBuf=pb-pFst;return 1;}void Draw93(HDC hDC,int iX,int iY0,int iY1,const COLORREF clrBar,const COLORREF clrSpace,const int iPenW){DrawBarcode(hDC,iX,iY0,iY1,iY1,clrBar,clrSpace,iPenW);}private:BYTE*P_GetBarSpace93(BYTE*pb,int ch){if(ch<0)  return 0;if(ch>48)   return 0;IntString infs[]={{0,     "bsssbsbss"},{1,      "bsbssbsss"},{2,      "bsbsssbss"},{3,      "bsbssssbs"},{4,      "bssbsbsss"},{5,      "bssbssbss"},{6,      "bssbsssbs"},{7,      "bsbsbssss"},{8,      "bsssbssbs"},{9,      "bssssbsbs"},{10, "bbsbsbsss"},{11, "bbsbssbss"},{12, "bbsbsssbs"},{13, "bbssbsbss"},{14, "bbssbssbs"},{15, "bbsssbsbs"},{16, "bsbbsbsss"},{17, "bsbbssbss"},{18, "bsbbsssbs"},{19, "bssbbsbss"},{20, "bsssbbsbs"},{21, "bsbsbbsss"},{22, "bsbssbbss"},{23, "bsbsssbbs"},{24, "bssbsbbss"},{25, "bsssbsbbs"},{26, "bbsbbsbss"},{27, "bbsbbssbs"},{28, "bbsbsbbss"},{29, "bbsbssbbs"},{30, "bbssbsbbs"},{31, "bbssbbsbs"},{32, "bsbbsbbss"},{33, "bsbbssbbs"},{34, "bssbbsbbs"},{35, "bssbbbsbs"},{36, "bssbsbbbs"},{37, "bbbsbsbss"},{38, "bbbsbssbs"},{39, "bbbssbsbs"},{40, "bsbbsbbbs"},{41, "bsbbbsbbs"},{42, "bbsbsbbbs"},{43, "bssbssbbs"},{44, "bbbsbbsbs"},{45, "bbbsbsbbs"},{46, "bssbbssbs"},{47, "bsbsbbbbs"},{48, "bsbsbbbbsb"},};IntString&inf=infs[ch];int i;for(i=0;i<9;i++){if(inf.psz[i]=='b')  *pb+=1;pb++;}if(ch==48){*pb+=1;pb++;}return pb;}private:BYTE*P_GetCheckDigits(BYTE*pb,const char*&pszCode){int i,iSum,iWeight,iFirst,iSecond;// "C" check digit characteriWeight=1;iSum=0;const int iNum=strlen(pszCode);for(i=iNum-1;i>-1;i--){P_AscIItoCode93Sequence((int)pszCode[i],iFirst,iSecond);iSum+=(iWeight*iFirst);iWeight++;if(iWeight>20)   iWeight=1;if(iSecond!=-1){iSum+=(iWeight*iSecond);iWeight++;if(iWeight>20) iWeight=1;}}pb=P_GetBarSpace93(pb,iSum%47);if(pb==0)    return 0;iWeight=2;iSum=iSum%47;for(i=iNum-1;i>-1;i--){P_AscIItoCode93Sequence((int)pszCode[i],iFirst,iSecond);iSum +=(iWeight * iFirst);iWeight++;if(iWeight>15)  iWeight=1;if(iSecond!=-1){iSum +=(iWeight * iSecond);iWeight++;if(iWeight>15)  iWeight=1;}}pb=P_GetBarSpace93(pb,iSum%47);if(pb==0)    return 0;return pb;}BOOL P_AscIItoCode93Sequence(int iValue,int&iFirst,int&iSecond){if(iValue<0) return 0;if(iValue>127)  return 0;struct I3{int iV,iFirst,iSecond;};I3 i3s[]={{0,   44, 30},{1, 43, 10},{2, 43, 11},{3, 43, 12},{4, 43, 13},{5, 43, 14},{6, 43, 15},{7, 43, 16},{8, 43, 17},{9, 43, 18},{10,43, 19},{11,43, 20},{12,43, 21},{13,43, 22},{14,43, 23},{15,43, 24},{16,43, 25},{17,43, 26},{18,43, 27},{19,43, 28},{20,43, 29},{21,43, 30},{22,43, 31},{23,43, 32},{24,43, 33},{25,43, 34},{26,43, 35},{27,44, 10},{28,44, 11},{29,44, 12},{30,44, 13},{31,44, 14},{32,38, -1},{33,45, 10},{34,45, 11},{35,45, 12},{36,39, -1},{37,42, -1},{38,45, 15},{39,45, 16},{40,45, 17},{41,45, 18},{42,45, 19},{43,41, -1},{44,45, 21},{45,36, -1},{46,37, -1},{47,40, -1},{48,0,  -1},{49,1,  -1},{50,2,  -1},{51,3,  -1},{52,4,  -1},{53,5,  -1},{54,6,  -1},{55,7,  -1},{56,8,  -1},{57,9,  -1},{58,45, 35},{59,44, 15},{60,44, 16},{61,44, 17},{62,44, 18},{63,44, 19},{64,44, 31},{65,10, -1},{66,11, -1},{67,12, -1},{68,13, -1},{69,14, -1},{70,15, -1},{71,16, -1},{72,17, -1},{73,18, -1},{74,19, -1},{75,20, -1},{76,21, -1},{77,22, -1},{78,23, -1},{79,24, -1},{80,25, -1},{81,26, -1},{82,27, -1},{83,28, -1},{84,29, -1},{85,30, -1},{86,31, -1},{87,32, -1},{88,33, -1},{89,34, -1},{90,35, -1},{91,44, 20},{92,44, 21},{93,44, 22},{94,44, 23},{95,44, 24},{96,44, 32},{97,46, 10},{98,46, 11},{99,46, 12},{100,46,13},{101,46,14},{102,46,15},{103,46,16},{104,46,17},{105,46,18},{106,46,19},{107,46,20},{108,46,21},{109,46,22},{110,46,23},{111,46,24},{112,46,25},{113,46,26},{114,46,27},{115,46,28},{116,46,29},{117,46,30},{118,46,31},{119,46,32},{120,46,33},{121,46,34},{122,46,35},{123,44,25},{124,44,26},{125,44,27},{126,44,28},{127,44,29},};I3&i3=i3s[iValue];iFirst =i3.iFirst;iSecond =i3.iSecond;return 1;}
};class Barcode128:public BarcodeBase
{
public:Barcode128(){}~Barcode128(){}BOOL Encode128A(const char* pszCode)    {return P_Encode128((char*)pszCode,SUB::SETA);}BOOL Encode128B(const char* pszCode) {return P_Encode128((char*)pszCode,SUB::SETB);}BOOL Encode128C(const char* pszCode) {return P_Encode128((char*)pszCode,SUB::SETC);}void Draw128(HDC hDC,int iX,int iY0,int iY1,const COLORREF clrBar,const COLORREF clrSpace,const int iPenW){DrawBarcode(hDC,iX,iY0,iY1,iY1,clrBar,clrSpace,iPenW);}private:struct SUB{enum{SETA=0,SETB=1,SETC=2,};};BOOL P_Encode128(char*pszCode,const int iSetIn){Clear();BYTE*pFst=ia_Buf;BYTE*pb=pFst;if(iSetIn==SUB::SETA)    pb=P_GetBarSpace128(pb,103);elseif(iSetIn==SUB::SETB)    pb=P_GetBarSpace128(pb,104);else                   pb=P_GetBarSpace128(pb,105);if(pb==0)    return 0;const int iCheckDigit=GetCheckDigit(iSetIn,pszCode);const int iNum=strlen(pszCode);int iChar,iCharNext;int iPosition=0;int iSet=iSetIn;while(iPosition<iNum){if(iSet==SUB::SETC){if(ga2_Code128[SUB::SETA][pszCode[iPosition]]==101){pb=P_GetBarSpace128(pb,101);iPosition++;iSet=SUB::SETA;}else if(ga2_Code128[SUB::SETA][pszCode[iPosition]]==100){pb=P_GetBarSpace128(pb,100);iPosition++;iSet=SUB::SETB;}else if(ga2_Code128[SUB::SETA][pszCode[iPosition]]==102){pb=P_GetBarSpace128(pb,100);iPosition++;}else{char chT=pszCode[iPosition+2];pszCode[iPosition+2]=0;iChar=atoi(&pszCode[iPosition]);pszCode[iPosition+2]=chT;pb=P_GetBarSpace128(pb,iChar);if(pb==0) return 0;iPosition +=2;}}else{int iTemp2=pszCode[iPosition];if(iTemp2<-1) iTemp2=iTemp2&255;iChar=ga2_Code128[iSet][iTemp2];pb=P_GetBarSpace128(pb,iChar);if(pb==0)  return 0;iPosition++;if(iSet==SUB::SETA){if(iChar==100)   iSet=SUB::SETB;else if(iChar==99)    iSet=SUB::SETC;}else if(iSet==SUB::SETB){if(iChar==101)    iSet=SUB::SETA;else if(iChar==99)    iSet=SUB::SETC;}else if(iChar==98){if(iSet==SUB::SETA)iCharNext=ga2_Code128[SUB::SETB][pszCode[iPosition]];elseiCharNext=ga2_Code128[SUB::SETA][pszCode[iPosition]];pb=P_GetBarSpace128(pb,iChar);if(pb==0)   return 0;iPosition++;}}}pb=P_GetBarSpace128(pb,iCheckDigit);if(pb==0)  return 0;pb=P_GetBarSpace128(pb,106);i_LenBuf=pb-pFst;return 1;}BYTE*P_GetBarSpace128(BYTE*pb,int iV){if(iV<0) return 0;if(iV>106)  return 0;IntString infs[]={{0,     "bbsbbssbbss"},{1,        "bbssbbsbbss"},{2,        "bbssbbssbbs"},{3,        "bssbssbbsss"},{4,        "bssbsssbbss"},{5,        "bsssbssbbss"},{6,        "bssbbssbsss"},{7,        "bssbbsssbss"},{8,        "bsssbbssbss"},{9,        "bbssbssbsss"},{10,   "bbssbsssbss"},{11,   "bbsssbssbss"},{12,   "bsbbssbbbss"},{13,   "bssbbsbbbss"},{14,   "bssbbssbbbs"},{15,   "bsbbbssbbss"},{16,   "bssbbbsbbss"},{17,   "bssbbbssbbs"},{18,   "bbssbbbssbs"},{19,   "bbssbsbbbss"},{20,   "bbssbssbbbs"},{21,   "bbsbbbssbss"},{22,   "bbssbbbsbss"},{23,   "bbbsbbsbbbs"},{24,   "bbbsbssbbss"},{25,   "bbbssbsbbss"},{26,   "bbbssbssbbs"},{27,   "bbbsbbssbss"},{28,   "bbbssbbsbss"},{29,   "bbbssbbssbs"},{30,   "bbsbbsbbsss"},{31,   "bbsbbsssbbs"},{32,   "bbsssbbsbbs"},{33,   "bsbsssbbsss"},{34,   "bsssbsbbsss"},{35,   "bsssbsssbbs"},{36,   "bsbbsssbsss"},{37,   "bsssbbsbsss"},{38,   "bsssbbsssbs"},{39,   "bbsbsssbsss"},{40,   "bbsssbsbsss"},{41,   "bbsssbsssbs"},{42,   "bsbbsbbbsss"},{43,   "bsbbsssbbbs"},{44,   "bsssbbsbbbs"},{45,   "bsbbbsbbsss"},{46,   "bsbbbsssbbs"},{47,   "bsssbbbsbbs"},{48,   "bbbsbbbsbbs"},{49,   "bbsbsssbbbs"},{50,   "bbsssbsbbbs"},{51,   "bbsbbbsbsss"},{52,   "bbsbbbsssbs"},{53,   "bbsbbbsbbbs"},{54,   "bbbsbsbbsss"},{55,   "bbbsbsssbbs"},{56,   "bbbsssbsbbs"},{57,   "bbbsbbsbsss"},{58,   "bbbsbbsssbs"},{59,   "bbbsssbbsbs"},{60,   "bbbsbbbbsbs"},{61,   "bbssbssssbs"},{62,   "bbbbsssbsbs"},{63,   "bsbssbbssss"},{64,   "bsbssssbbss"},{65,   "bssbsbbssss"},{66,   "bssbssssbbs"},{67,   "bssssbsbbss"},{68,   "bssssbssbbs"},{69,   "bsbbssbssss"},{70,   "bsbbssssbss"},{71,   "bssbbsbssss"},{72,   "bssbbssssbs"},{73,   "bssssbbsbss"},{74,   "bssssbbssbs"},{75,   "bbssssbssbs"},{76,   "bbssbsbssss"},{77,   "bbbbsbbbsbs"},{78,   "bbssssbsbss"},{79,   "bsssbbbbsbs"},{80,   "bsbssbbbbss"},{81,   "bssbsbbbbss"},{82,   "bssbssbbbbs"},{83,   "bsbbbbssbss"},{84,   "bssbbbbsbss"},{85,   "bssbbbbssbs"},{86,   "bbbbsbssbss"},{87,   "bbbbssbsbss"},{88,   "bbbbssbssbs"},{89,   "bbsbbsbbbbs"},{90,   "bbsbbbbsbbs"},{91,   "bbbbsbbsbbs"},{92,   "bsbsbbbbsss"},{93,   "bsbsssbbbbs"},{94,   "bsssbsbbbbs"},{95,   "bsbbbbsbsss"},{96,   "bsbbbbsssbs"},{97,   "bbbbsbsbsss"},{98,   "bbbbsbsssbs"},{99,   "bsbbbsbbbbs"},{100,  "bsbbbbsbbbs"},{101,  "bbbsbsbbbbs"},{102,  "bbbbsbsbbbs"},
//          {103,   "bbsbsbbbbss"},{103,  "bbsbssssbss"},{104,  "bbsbssbssss"},{105,  "bbsbssbbbss"},{106,  "bbsssbbbsbsbb"},};   int i;IntString&inf=infs[iV];for(i=0;i<11;i++){if(inf.psz[i]=='b')   *pb+=1;pb++;}if(iV==106)  {*pb+=1;  pb++;*pb+=1;    pb++;}return pb;}private:int GetCheckDigit(const int iSet,char*pszCode){int   iSum=0,iCurSet=0,iChar128,iCharNext,iWeight,iPosition;iCurSet=iSet;if(iSet==SUB::SETA){iSum=103;}else if(iSet==SUB::SETB){iSum=104;}else if(iSet==SUB::SETC){iSum=105;}iPosition=0;iWeight=1;const int iNum=strlen(pszCode);while(iPosition<iNum){if(iCurSet==SUB::SETC){if(ga2_Code128[SUB::SETA][pszCode[iPosition]]==101){iChar128=101;iSum+=(iWeight*iChar128);iPosition++;iWeight++;iCurSet=SUB::SETA;}else if(ga2_Code128[SUB::SETA][pszCode[iPosition]]==100){iChar128=100;iSum+=(iWeight*iChar128);iPosition++;iWeight++;iCurSet=SUB::SETB;}else if(ga2_Code128[SUB::SETA][pszCode[iPosition]]==102){iChar128=102;iSum+=(iWeight*iChar128);iPosition++;iWeight++;}else{char chT=pszCode[iPosition+2];pszCode[iPosition+2]=0;iChar128=atol(&pszCode[iPosition]);pszCode[iPosition+2]=chT;iSum +=(iWeight*iChar128);iPosition +=2;iWeight++;}}else {int iTemp2=pszCode[iPosition];if(iTemp2<-1) iTemp2=iTemp2&255;iChar128=ga2_Code128[iCurSet][iTemp2];iSum+=(iWeight*iChar128);iPosition++;iWeight++;if(iCurSet==SUB::SETA){if(iChar128==100)iCurSet=SUB::SETB;else if(iChar128==99)iCurSet=SUB::SETC;}else if(iCurSet==SUB::SETB){if(iChar128==101)      iCurSet=SUB::SETA;else if(iChar128==99)  iCurSet=SUB::SETC;}else if(iChar128==98){if(iCurSet==SUB::SETA)iCharNext=ga2_Code128[SUB::SETB][pszCode[iPosition]];elseiCharNext=ga2_Code128[SUB::SETA][pszCode[iPosition]];iSum+=(iWeight*iCharNext);iPosition++;iWeight++;}}}return iSum%103;}
};//=============================================
class BarcodeEan13:public BarcodeBase
{
public:BarcodeEan13(){}~BarcodeEan13(){}BOOL EncodeEan13(const char*pszCodeIn){Clear();//only allow 12 characters as inputchar szCode[14];const int iLen=strlen(pszCodeIn);if(iLen>12){strncpy_s(szCode,pszCodeIn,12);}else{strcpy_s(szCode,pszCodeIn);while(strlen(szCode)<12)  strcat_s(szCode,"0");}BYTE*pFst=ia_Buf;BYTE*pb=pFst;//"bsb"-long*pb+=5; pb++;*pb+=4;    pb++;*pb+=5;    pb++;BYTE iaCountryCode[6];BOOL b=P_GetCountryCode(szCode[0],iaCountryCode);if(b==0)   return 0;pb=P_GetLeftOddParity(pb,szCode[1]);int i;for(i=2;i<7;i++){if(iaCountryCode[i-2]=='O'){pb=P_GetLeftOddParity(pb,szCode[i]);}elseif(iaCountryCode[i-2]=='E'){pb=P_GetLeftEvenParity(pb,szCode[i]);}}//"sbsbs"-long*pb+=4;  pb++;*pb+=5;    pb++;*pb+=4;    pb++;*pb+=5;    pb++;*pb+=4;    pb++;for(i=7;i<12;i++){pb=P_GetRightPattern(pb,szCode[i]);}i=P_GetCheckSumDigit(szCode);pb=P_GetRightPattern(pb,(char)i);//"bsb"-long*pb+=5; pb++;*pb+=4;    pb++;*pb+=5;    pb++;i_LenBuf=pb-pFst;return 1;}void DrawEan13(HDC hDC,int iX,int iY0,int iY10,int iY11,const COLORREF clrBar,const COLORREF clrSpace,const int iPenW){DrawBarcode(hDC,iX,iY0,iY10,iY11,clrBar,clrSpace,iPenW);}private:BOOL P_GetCountryCode(char ch,BYTE*pbCountryCode){const int iV=ch-'0';if(iV<0) return 0;if(iV>9)    return 0;IntString infs[]={{0, "OOOOO"},{1,  "OEOEE"},{2,  "OEEOE"},{3,  "OEEEO"},{4,  "EOOEE"},{5,  "EEOOE"},{6,  "EEEOO"},{7,  "EOEOE"},{8,  "EOEEO"},{9,  "EEOEO"},};memcpy(pbCountryCode,infs[iV].psz,5);return 1;}BYTE*P_GetLeftOddParity(BYTE*pb,char ch){const int iV=ch-'0';if(iV<0) return 0;if(iV>9)    return 0;IntString infs[]={{0, "sssbbsb"},{1,    "ssbbssb"},{2,    "ssbssbb"},{3,    "sbbbbsb"},{4,    "sbsssbb"},{5,    "sbbsssb"},{6,    "sbsbbbb"},{7,    "sbbbsbb"},{8,    "sbbsbbb"},{9,    "sssbsbb"},};IntString&inf=infs[iV];int i;for(i=0;i<7;i++){if(inf.psz[i]=='b') *pb+=1;pb++;}return pb;}BYTE*P_GetLeftEvenParity(BYTE*pb,char ch){const int iV=ch-'0';if(iV<0)    return 0;if(iV>9)    return 0;IntString infs[]={{0, "sbssbbb"},{1,    "sbbssbb"},{2,    "ssbbsbb"},{3,    "sbssssb"},{4,    "ssbbbsb"},{5,    "sbbbssb"},{6,    "ssssbsb"},{7,    "ssbsssb"},{8,    "sssbssb"},{9,    "ssbsbbb"},};char*psz=infs[iV].psz;int i;for(i=0;i<7;i++){if(psz[i]=='b')  *pb+=1;pb++;}return pb;}BYTE*P_GetRightPattern(BYTE*pb,char ch){const int iV=ch-'0';if(iV<0)  return 0;if(iV>9)    return 0;IntString infs[]={{0, "bbbssbs"},{1,    "bbssbbs"},{2,    "bbsbbss"},{3,    "bssssbs"},{4,    "bsbbbss"},{5,    "bssbbbs"},{6,    "bsbssss"},{7,    "bsssbss"},{8,    "bssbsss"},{9,    "bbbsbss"},};char*psz=infs[iV].psz;int i;for(i=0;i<7;i++){if(psz[i]=='b')  *pb+=1;pb++;}return pb;}char P_GetCheckSumDigit(const char*pszCode){const int iLen=strlen(pszCode);int i,iSum=0,iItem;for(i=iLen;i >=1;i--){iItem=i%2?(pszCode[i-1]-'0')*1:(pszCode[i-1]-'0')*3;iSum+=iItem;}iSum%=10;return '0'+(10-iSum)%10;}};#endif

C++生成条型码和二维码源码及调用示例 还是C#方便相关推荐

  1. QR二维码生成器源码(中间可插入小图片)

    二维码终于火了,现在大街小巷大小商品广告上的二维码标签都随处可见,而且大都不是简单的纯二维码,而是中间有个性图标的二维码. 我之前做了一个使用google开源项目zxing实现二维码.一维码编码解码的 ...

  2. android企业级商城源码、360°全景图VR源码、全民直播源码等

    Android精选源码 [新版]Android技术博客精华汇总 开源了:乐乐音乐5.0-Android音乐播放器 android实现仿真水波纹效果源码 360°全景图VR,这是一个值得把玩的APP a ...

  3. ZBar条型码、二维码

    今天对ZBar进行了研究,做了个ipad版实例,ZBar可以对条型码.二维码进行扫描并可得到显示后的结果. ZBar网站: http://zbar.sourceforge.net/iphone/sdk ...

  4. java生成、识别条形码和二维码

    一.概述 使用 zxing 开源库 Zxing主要是Google出品的,用于识别一维码和二维码的第三方库 主要类: BitMatrix 位图矩阵 MultiFormatWriter 位图编写器 Mat ...

  5. 微信生成专属海报(专属二维码)

    通过get请求获取专属海报 /*** 获取专属海报** @param mid 会议编号* @param openId 邀请人唯一码* @return*/@SneakyThrows@ApiOperati ...

  6. 微信公众号开发----生成带参数的临时二维码

    本文只提供代码实现,具体参数含义请先仔细阅读微信公众号技术文档之生成带参数的二维码 临时二维码请求说明: 一.常量类 public class WechartConst {//生成带参数的二维码pub ...

  7. 移动互联网的入口-二维码(二维码生成原理及流程)

    目录 1 引入 2 历史 2.1 一维码 2.2 二维码 3 分类 3.1 线性堆叠式二维码 3.2 矩阵式二维码 3.3 邮政码 4 QR code二维码结构 5 QR code二维码生成流程及原理 ...

  8. 飞鹅小票打印机嵌入生成指定小程序页面二维码的解决方案 | 扫普通链接二维码打开小程序示例 | 生成正方形小程序码

    部分朋友不需要打印机的业务,则 忽略有关打印机的部分 即可. 其他有关 微信小程序配置的介绍是通用的!通用的! 生成正方形小程序码,请看 标题一. 扫普通链接生成的二维码打开小程序,请看 标题二. 目 ...

  9. asp.net 生成、解析条形码和二维码

    asp.net 生成.解析条形码和二维码 原文 asp.net 生成.解析条形码和二维码 一.条形码 一维码,俗称条形码,广泛的用于电子工业等行业.比如我们常见的书籍背面就会有条形码,通过扫描枪等设备 ...

最新文章

  1. 整个宇宙可能是个巨大的神经网络?看科学家们是这样解释的
  2. Leetcode 101. 对称二叉树 解题思路及C++实现
  3. iOS安装CocoaPods的详细步骤
  4. 2020年中国服务机器人行业研究报告
  5. P1422 小玉家的电费--2022.03.15
  6. 拳王虚拟项目公社:人人可操作的轻松简单的虚拟资源课程虚拟项目
  7. docker搭建lnmp环境
  8. mask rcnn算法分析_实例分割综述(单阶段/两阶段/实时分割算法汇总)
  9. NSRunLoop中Autorelease pool 管理
  10. 基于matlab的锁相环频率合成器,基于simulink的电荷泵锁相环频率合成器建模与仿真.pdf...
  11. Html5开发工具介绍
  12. java 斜杠常量_Java基础之常量
  13. java 立体几何体中心点_高中数学知识点大全,立体几何核心考点及解题技巧
  14. apache性能调优(转)
  15. matlab归一程序,Matlab三种归一化方法
  16. 几个简单的论文下载方法
  17. excel空白单元格自动下下填充上一个单元格的值
  18. 电气火灾监控探测器安装在哪里?
  19. oracle 添加索引
  20. Entity Framework 6三层架构入门:创建数据访问层DAL

热门文章

  1. matlab索引奇数,将列表分为偶数索引部分和奇数索引部分
  2. 大道至简 知易行难 JAVA 完成WebSocket demo 用GoEasy实现Hello world
  3. TexStudio论文写作小白入门
  4. 【数值计算】数值解析--二阶偏微分方程的3种基本形
  5. 『征文精选』技术翻译与术语管理技术:专业人说专业话
  6. vue2+node实现全栈多人视频会议
  7. 插入mysql数据库时间相差14个小时
  8. 局域网内知道Mac地址查询对应IP
  9. Adobe Photoshop Lightroom Classic 中文版
  10. ios高德地图提醒打开定位功能