mqrspec.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * qrencode - QR Code encoder
  3. *
  4. * Micro QR Code specification in convenient format.
  5. * Copyright (C) 2006-2017 Kentaro Fukuchi <kentaro@fukuchi.org>
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #ifndef MQRSPEC_H
  22. #define MQRSPEC_H
  23. #include "qrencode.h"
  24. /******************************************************************************
  25. * Version and capacity
  26. *****************************************************************************/
  27. /**
  28. * Maximum width of a symbol
  29. */
  30. #define MQRSPEC_WIDTH_MAX 17
  31. /**
  32. * Return maximum data code length (bits) for the version.
  33. * @param version version of the symbol
  34. * @param level error correction level
  35. * @return maximum size (bits)
  36. */
  37. extern int MQRspec_getDataLengthBit(int version, QRecLevel level);
  38. /**
  39. * Return maximum data code length (bytes) for the version.
  40. * @param version version of the symbol
  41. * @param level error correction level
  42. * @return maximum size (bytes)
  43. */
  44. extern int MQRspec_getDataLength(int version, QRecLevel level);
  45. /**
  46. * Return maximum error correction code length (bytes) for the version.
  47. * @param version version of the symbol
  48. * @param level error correction level
  49. * @return ECC size (bytes)
  50. */
  51. extern int MQRspec_getECCLength(int version, QRecLevel level);
  52. /**
  53. * Return a version number that satisfies the input code length.
  54. * @param size input code length (byte)
  55. * @param level error correction level
  56. * @return version number
  57. */
  58. extern int MQRspec_getMinimumVersion(int size, QRecLevel level);
  59. /**
  60. * Return the width of the symbol for the version.
  61. * @param version version of the symbol
  62. * @return width
  63. */
  64. extern int MQRspec_getWidth(int version);
  65. /**
  66. * Return the numer of remainder bits.
  67. * @param version version of the symbol
  68. * @return number of remainder bits
  69. */
  70. extern int MQRspec_getRemainder(int version);
  71. /******************************************************************************
  72. * Length indicator
  73. *****************************************************************************/
  74. /**
  75. * Return the size of length indicator for the mode and version.
  76. * @param mode encode mode
  77. * @param version vesion of the symbol
  78. * @return the size of the appropriate length indicator (bits).
  79. */
  80. extern int MQRspec_lengthIndicator(QRencodeMode mode, int version);
  81. /**
  82. * Return the maximum length for the mode and version.
  83. * @param mode encode mode
  84. * @param version vesion of the symbol
  85. * @return the maximum length (bytes)
  86. */
  87. extern int MQRspec_maximumWords(QRencodeMode mode, int version);
  88. /******************************************************************************
  89. * Version information pattern
  90. *****************************************************************************/
  91. /**
  92. * Return BCH encoded version information pattern that is used for the symbol
  93. * of version 7 or greater. Use lower 18 bits.
  94. * @param version vesion of the symbol
  95. * @return BCH encoded version information pattern
  96. */
  97. extern unsigned int MQRspec_getVersionPattern(int version);
  98. /******************************************************************************
  99. * Format information
  100. *****************************************************************************/
  101. /**
  102. * Return BCH encoded format information pattern.
  103. * @param mask mask number
  104. * @param version version of the symbol
  105. * @param level error correction level
  106. * @return BCH encoded format information pattern
  107. */
  108. extern unsigned int MQRspec_getFormatInfo(int mask, int version, QRecLevel level);
  109. /******************************************************************************
  110. * Frame
  111. *****************************************************************************/
  112. /**
  113. * Return a copy of initialized frame.
  114. * @param version version of the symbol
  115. * @return Array of unsigned char. You can free it by free().
  116. */
  117. extern unsigned char *MQRspec_newFrame(int version);
  118. /******************************************************************************
  119. * Mode indicator
  120. *****************************************************************************/
  121. /**
  122. * Mode indicator. See Table 2 in Appendix 1 of JIS X0510:2004, pp.107.
  123. */
  124. #define MQRSPEC_MODEID_NUM 0
  125. #define MQRSPEC_MODEID_AN 1
  126. #define MQRSPEC_MODEID_8 2
  127. #define MQRSPEC_MODEID_KANJI 3
  128. #endif /* MQRSPEC_H */