DrawBarCode.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. ///************************************************************************/
  2. /* Copyright (C), 2016-2020, [IT], 保留所有权利;
  3. /* 模 块 名:;
  4. /* 描 述:;
  5. /*
  6. /* 版 本:[V];
  7. /* 作 者:[IT];
  8. /* 日 期:[4/24/2016];
  9. /*
  10. /*
  11. /* 注 意:;
  12. /*
  13. /* 修改记录:[IT];
  14. /* 修改日期:;
  15. /* 修改版本:;
  16. /* 修改内容:;
  17. /************************************************************************/
  18. #ifndef __DRAW_BAR_CODE__
  19. #define __DRAW_BAR_CODE__
  20. #pragma once
  21. namespace DrawBarCodes
  22. {
  23. struct IntString
  24. {
  25. int ch;
  26. char*psz;
  27. };
  28. class CBarCodeBase
  29. {
  30. protected:
  31. BYTE m_byBuffer[4096];
  32. int m_nBufferLen;
  33. int m_nRatio;
  34. struct _INPUTSTR_
  35. {
  36. int nChCount; // 输入字符数;
  37. CHAR *pInputStr; // 输入的字符串;
  38. };
  39. public:
  40. CBarCodeBase();
  41. ~CBarCodeBase();
  42. void operator=(const CBarCodeBase& bc);
  43. void Clear();
  44. int GetEncodeLength() const;
  45. int GetBufferLength() const;
  46. const BYTE& GetAt(const int& nIndex) const;
  47. int GetRatio() const;
  48. int SetRatio(const int& nRatio);
  49. void DrawBarCode(IN HDC hDC, IN int nStartX, IN int nStartY, IN int nBarHeight, IN int nBarHeight2, IN const COLORREF clrBar, IN const COLORREF clrSpace, IN const int nPenWidth);
  50. };
  51. //////////////////////////////////////////////////////////////////////////
  52. class CBarCode39:public CBarCodeBase
  53. {
  54. public:
  55. CBarCode39();
  56. ~CBarCode39();
  57. BOOL EnCode39(IN LPCTSTR lpszCodeIn);
  58. void Draw39(IN HDC hDC, IN int nStartX, IN int nStartY, IN int nBarHeight, IN int nBarHeight2, IN const COLORREF clrBar, IN const COLORREF clrSpace, IN const int nPenWidth);
  59. protected:
  60. private:
  61. BYTE *GetNarrowWideBarSpace39(IN CHAR ch, IN BYTE* pb);
  62. };
  63. class CBarCode93:public CBarCodeBase
  64. {
  65. public:
  66. CBarCode93();
  67. ~CBarCode93();
  68. BOOL EnCode93(IN LPCTSTR lpszCodeIn);
  69. void Draw93(IN HDC hDC, IN int nStartX, IN int nStartY, IN int nBarHeight, IN int nBarHeight2, IN const COLORREF clrBar, IN const COLORREF clrSpace, IN const int nPenWidth);
  70. protected:
  71. private:
  72. BYTE *GetBarSpace93(IN BYTE* pb, IN int ch);
  73. BYTE *GetCheckDigits(IN BYTE* bp, IN const char *&pszCode);
  74. BOOL AscIItoCode93Sequence(IN int nValue, IN int& nFirst, IN int& nSecond);
  75. };
  76. class CBarCodeI2of5:public CBarCodeBase
  77. {
  78. public:
  79. protected:
  80. private:
  81. };
  82. class CBarCode128:public CBarCodeBase
  83. {
  84. public:
  85. protected:
  86. private:
  87. };
  88. class CBarCodeEan13:public CBarCodeBase
  89. {
  90. public:
  91. protected:
  92. private:
  93. };
  94. };
  95. #endif