BinaryBitmap.d.ts 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /**
  2. * This class is the core bitmap class used by ZXing to represent 1 bit data. Reader objects
  3. * accept a BinaryBitmap and attempt to decode it.
  4. *
  5. * @author dswitkin@google.com (Daniel Switkin)
  6. */
  7. import Binarizer from './Binarizer';
  8. import BitArray from './common/BitArray';
  9. import BitMatrix from './common/BitMatrix';
  10. export default class BinaryBitmap {
  11. private binarizer;
  12. private matrix;
  13. constructor(binarizer: Binarizer);
  14. /**
  15. * @return The width of the bitmap.
  16. */
  17. getWidth(): number;
  18. /**
  19. * @return The height of the bitmap.
  20. */
  21. getHeight(): number;
  22. /**
  23. * Converts one row of luminance data to 1 bit data. May actually do the conversion, or return
  24. * cached data. Callers should assume this method is expensive and call it as seldom as possible.
  25. * This method is intended for decoding 1D barcodes and may choose to apply sharpening.
  26. *
  27. * @param y The row to fetch, which must be in [0, bitmap height)
  28. * @param row An optional preallocated array. If null or too small, it will be ignored.
  29. * If used, the Binarizer will call BitArray.clear(). Always use the returned object.
  30. * @return The array of bits for this row (true means black).
  31. * @throws NotFoundException if row can't be binarized
  32. */
  33. getBlackRow(y: number, row: BitArray): BitArray;
  34. /**
  35. * Converts a 2D array of luminance data to 1 bit. As above, assume this method is expensive
  36. * and do not call it repeatedly. This method is intended for decoding 2D barcodes and may or
  37. * may not apply sharpening. Therefore, a row from this matrix may not be identical to one
  38. * fetched using getBlackRow(), so don't mix and match between them.
  39. *
  40. * @return The 2D array of bits for the image (true means black).
  41. * @throws NotFoundException if image can't be binarized to make a matrix
  42. */
  43. getBlackMatrix(): BitMatrix;
  44. /**
  45. * @return Whether this bitmap can be cropped.
  46. */
  47. isCropSupported(): boolean;
  48. /**
  49. * Returns a new object with cropped image data. Implementations may keep a reference to the
  50. * original data rather than a copy. Only callable if isCropSupported() is true.
  51. *
  52. * @param left The left coordinate, which must be in [0,getWidth())
  53. * @param top The top coordinate, which must be in [0,getHeight())
  54. * @param width The width of the rectangle to crop.
  55. * @param height The height of the rectangle to crop.
  56. * @return A cropped version of this object.
  57. */
  58. crop(left: number, top: number, width: number, height: number): BinaryBitmap;
  59. /**
  60. * @return Whether this bitmap supports counter-clockwise rotation.
  61. */
  62. isRotateSupported(): boolean;
  63. /**
  64. * Returns a new object with rotated image data by 90 degrees counterclockwise.
  65. * Only callable if {@link #isRotateSupported()} is true.
  66. *
  67. * @return A rotated version of this object.
  68. */
  69. rotateCounterClockwise(): BinaryBitmap;
  70. /**
  71. * Returns a new object with rotated image data by 45 degrees counterclockwise.
  72. * Only callable if {@link #isRotateSupported()} is true.
  73. *
  74. * @return A rotated version of this object.
  75. */
  76. rotateCounterClockwise45(): BinaryBitmap;
  77. toString(): string;
  78. }