You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ZXBinaryBitmap.h 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 ZXBinarizer, ZXBitArray, ZXBitMatrix;
  17. /**
  18. * This class is the core bitmap class used by ZXing to represent 1 bit data. Reader objects
  19. * accept a BinaryBitmap and attempt to decode it.
  20. */
  21. @interface ZXBinaryBitmap : NSObject
  22. /**
  23. * @return The width of the bitmap.
  24. */
  25. @property (nonatomic, readonly) int width;
  26. /**
  27. * @return The height of the bitmap.
  28. */
  29. @property (nonatomic, readonly) int height;
  30. /**
  31. * @return Whether this bitmap can be cropped.
  32. */
  33. @property (nonatomic, readonly) BOOL cropSupported;
  34. /**
  35. * @return Whether this bitmap supports counter-clockwise rotation.
  36. */
  37. @property (nonatomic, readonly) BOOL rotateSupported;
  38. - (id)initWithBinarizer:(ZXBinarizer *)binarizer;
  39. + (id)binaryBitmapWithBinarizer:(ZXBinarizer *)binarizer;
  40. /**
  41. * Converts one row of luminance data to 1 bit data. May actually do the conversion, or return
  42. * cached data. Callers should assume this method is expensive and call it as seldom as possible.
  43. * This method is intended for decoding 1D barcodes and may choose to apply sharpening.
  44. *
  45. * @param y The row to fetch, 0 <= y < bitmap height.
  46. * @param row An optional preallocated array. If null or too small, it will be ignored.
  47. * If used, the Binarizer will call BitArray.clear(). Always use the returned object.
  48. * @return The array of bits for this row (true means black).
  49. */
  50. - (ZXBitArray *)blackRow:(int)y row:(ZXBitArray *)row error:(NSError **)error;
  51. /**
  52. * Converts a 2D array of luminance data to 1 bit. As above, assume this method is expensive
  53. * and do not call it repeatedly. This method is intended for decoding 2D barcodes and may or
  54. * may not apply sharpening. Therefore, a row from this matrix may not be identical to one
  55. * fetched using getBlackRow(), so don't mix and match between them.
  56. *
  57. * @return The 2D array of bits for the image (true means black).
  58. */
  59. - (ZXBitMatrix *)blackMatrixWithError:(NSError **)error;
  60. /**
  61. * Returns a new object with cropped image data. Implementations may keep a reference to the
  62. * original data rather than a copy. Only callable if isCropSupported() is true.
  63. *
  64. * @param left The left coordinate, 0 <= left < getWidth().
  65. * @param top The top coordinate, 0 <= top <= getHeight().
  66. * @param width The width of the rectangle to crop.
  67. * @param height The height of the rectangle to crop.
  68. * @return A cropped version of this object.
  69. */
  70. - (ZXBinaryBitmap *)crop:(int)left top:(int)top width:(int)width height:(int)height;
  71. /**
  72. * Returns a new object with rotated image data by 90 degrees counterclockwise.
  73. * Only callable if {@link #isRotateSupported()} is true.
  74. *
  75. * @return A rotated version of this object.
  76. */
  77. - (ZXBinaryBitmap *)rotateCounterClockwise;
  78. /**
  79. * Returns a new object with rotated image data by 45 degrees counterclockwise.
  80. * Only callable if {@link #isRotateSupported()} is true.
  81. *
  82. * @return A rotated version of this object.
  83. */
  84. - (ZXBinaryBitmap *)rotateCounterClockwise45;
  85. @end