Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright 2012 ZXing authors
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. @class ZXBitArray, ZXByteMatrix, ZXQRCodeErrorCorrectionLevel, ZXQRCodeVersion;
  17. @interface ZXQRCodeMatrixUtil : NSObject
  18. // Set all cells to -1. -1 means that the cell is empty (not set yet).
  19. + (void)clearMatrix:(ZXByteMatrix *)matrix;
  20. // Build 2D matrix of QR Code from "dataBits" with "ecLevel", "version" and "getMaskPattern". On
  21. // success, store the result in "matrix" and return true.
  22. + (BOOL)buildMatrix:(ZXBitArray *)dataBits ecLevel:(ZXQRCodeErrorCorrectionLevel *)ecLevel version:(ZXQRCodeVersion *)version maskPattern:(int)maskPattern matrix:(ZXByteMatrix *)matrix error:(NSError **)error;
  23. // Embed basic patterns. On success, modify the matrix and return true.
  24. // The basic patterns are:
  25. // - Position detection patterns
  26. // - Timing patterns
  27. // - Dark dot at the left bottom corner
  28. // - Position adjustment patterns, if need be
  29. + (BOOL)embedBasicPatterns:(ZXQRCodeVersion *)version matrix:(ZXByteMatrix *)matrix error:(NSError **)error;
  30. // Embed type information. On success, modify the matrix.
  31. + (BOOL)embedTypeInfo:(ZXQRCodeErrorCorrectionLevel *)ecLevel maskPattern:(int)maskPattern matrix:(ZXByteMatrix *)matrix error:(NSError **)error;
  32. // Embed version information if need be. On success, modify the matrix and return true.
  33. // See 8.10 of JISX0510:2004 (p.47) for how to embed version information.
  34. + (BOOL)maybeEmbedVersionInfo:(ZXQRCodeVersion *)version matrix:(ZXByteMatrix *)matrix error:(NSError **)error;
  35. // Embed "dataBits" using "getMaskPattern". On success, modify the matrix and return true.
  36. // For debugging purposes, it skips masking process if "getMaskPattern" is -1.
  37. // See 8.7 of JISX0510:2004 (p.38) for how to embed data bits.
  38. + (BOOL)embedDataBits:(ZXBitArray *)dataBits maskPattern:(int)maskPattern matrix:(ZXByteMatrix *)matrix error:(NSError **)error;
  39. // Return the position of the most significant bit set (to one) in the "value". The most
  40. // significant bit is position 32. If there is no bit set, return 0. Examples:
  41. // - findMSBSet(0) => 0
  42. // - findMSBSet(1) => 1
  43. // - findMSBSet(255) => 8
  44. + (int)findMSBSet:(int)value;
  45. // Calculate BCH (Bose-Chaudhuri-Hocquenghem) code for "value" using polynomial "poly". The BCH
  46. // code is used for encoding type information and version information.
  47. // Example: Calculation of version information of 7.
  48. // f(x) is created from 7.
  49. // - 7 = 000111 in 6 bits
  50. // - f(x) = x^2 + x^1 + x^0
  51. // g(x) is given by the standard (p. 67)
  52. // - g(x) = x^12 + x^11 + x^10 + x^9 + x^8 + x^5 + x^2 + 1
  53. // Multiply f(x) by x^(18 - 6)
  54. // - f'(x) = f(x) * x^(18 - 6)
  55. // - f'(x) = x^14 + x^13 + x^12
  56. // Calculate the remainder of f'(x) / g(x)
  57. // x^2
  58. // __________________________________________________
  59. // g(x) )x^14 + x^13 + x^12
  60. // x^14 + x^13 + x^12 + x^11 + x^10 + x^7 + x^4 + x^2
  61. // --------------------------------------------------
  62. // x^11 + x^10 + x^7 + x^4 + x^2
  63. //
  64. // The remainder is x^11 + x^10 + x^7 + x^4 + x^2
  65. // Encode it in binary: 110010010100
  66. // The return value is 0xc94 (1100 1001 0100)
  67. //
  68. // Since all coefficients in the polynomials are 1 or 0, we can do the calculation by bit
  69. // operations. We don't care if cofficients are positive or negative.
  70. + (int)calculateBCHCode:(int)value poly:(int)poly;
  71. // Make bit vector of type information. On success, store the result in "bits" and return true.
  72. // Encode error correction level and mask pattern. See 8.9 of
  73. // JISX0510:2004 (p.45) for details.
  74. + (BOOL)makeTypeInfoBits:(ZXQRCodeErrorCorrectionLevel *)ecLevel maskPattern:(int)maskPattern bits:(ZXBitArray *)bits error:(NSError **)error;
  75. // Make bit vector of version information. On success, store the result in "bits" and return true.
  76. // See 8.10 of JISX0510:2004 (p.45) for details.
  77. + (BOOL)makeVersionInfoBits:(ZXQRCodeVersion *)version bits:(ZXBitArray *)bits error:(NSError **)error;
  78. @end