pub struct BinaryBitmap<B: Binarizer> { /* private fields */ }
Expand description
This class is the core bitmap class used by ZXing to represent 1 bit data. Reader objects accept a BinaryBitmap and attempt to decode it.
@author dswitkin@google.com (Daniel Switkin)
Implementations§
Source§impl<B: Binarizer> BinaryBitmap<B>
impl<B: Binarizer> BinaryBitmap<B>
pub fn new(binarizer: B) -> Self
Sourcepub fn get_height(&self) -> usize
pub fn get_height(&self) -> usize
@return The height of the bitmap.
Sourcepub fn get_black_row(&self, y: usize) -> Result<Cow<'_, BitArray>>
pub fn get_black_row(&self, y: usize) -> Result<Cow<'_, BitArray>>
Converts one row of luminance data to 1 bit data. May actually do the conversion, or return cached data. Callers should assume this method is expensive and call it as seldom as possible. This method is intended for decoding 1D barcodes and may choose to apply sharpening.
@param y The row to fetch, which must be in [0, bitmap height) @param row An optional preallocated array. If null or too small, it will be ignored. If used, the Binarizer will call BitArray.clear(). Always use the returned object. @return The array of bits for this row (true means black). @throws NotFoundException if row can’t be binarized
Sourcepub fn get_black_line(
&self,
l: usize,
lt: LineOrientation,
) -> Result<Cow<'_, BitArray>>
pub fn get_black_line( &self, l: usize, lt: LineOrientation, ) -> Result<Cow<'_, BitArray>>
Get a row or column of the image
Sourcepub fn get_black_matrix_mut(&mut self) -> &mut BitMatrix
pub fn get_black_matrix_mut(&mut self) -> &mut BitMatrix
Converts a 2D array of luminance data to 1 bit. As above, assume this method is expensive and do not call it repeatedly. This method is intended for decoding 2D barcodes and may or may not apply sharpening. Therefore, a row from this matrix may not be identical to one fetched using getBlackRow(), so don’t mix and match between them.
Panics if the binarizer cannot be created.
@return The 2D array of bits for the image (true means black). @throws NotFoundException if image can’t be binarized to make a matrix
Sourcepub fn get_black_matrix(&self) -> &BitMatrix
pub fn get_black_matrix(&self) -> &BitMatrix
Converts a 2D array of luminance data to 1 bit. As above, assume this method is expensive and do not call it repeatedly. This method is intended for decoding 2D barcodes and may or may not apply sharpening. Therefore, a row from this matrix may not be identical to one fetched using getBlackRow(), so don’t mix and match between them.
Panics if the binarizer cannot be created.
@return The 2D array of bits for the image (true means black). @throws NotFoundException if image can’t be binarized to make a matrix
Sourcepub fn is_crop_supported(&self) -> bool
pub fn is_crop_supported(&self) -> bool
@return Whether this bitmap can be cropped.
Sourcepub fn crop(
&mut self,
left: usize,
top: usize,
width: usize,
height: usize,
) -> Self
pub fn crop( &mut self, left: usize, top: usize, width: usize, height: usize, ) -> Self
Returns a new object with cropped image data. Implementations may keep a reference to the original data rather than a copy. Only callable if isCropSupported() is true.
Panics if the binarizer cannot be created.
@param left The left coordinate, which must be in [0,getWidth()) @param top The top coordinate, which must be in [0,getHeight()) @param width The width of the rectangle to crop. @param height The height of the rectangle to crop. @return A cropped version of this object.
Sourcepub fn is_rotate_supported(&self) -> bool
pub fn is_rotate_supported(&self) -> bool
@return Whether this bitmap supports counter-clockwise rotation.
Sourcepub fn rotate_counter_clockwise(&mut self) -> Self
pub fn rotate_counter_clockwise(&mut self) -> Self
Returns a new object with rotated image data by 90 degrees counterclockwise. Only callable if {@link #isRotateSupported()} is true.
Panics if the binarizer cannot be created.
@return A rotated version of this object.
Sourcepub fn rotate_counter_clockwise_45(&self) -> Self
pub fn rotate_counter_clockwise_45(&self) -> Self
Returns a new object with rotated image data by 45 degrees counterclockwise. Only callable if {@link #isRotateSupported()} is true.
Panics if the binarizer cannot be created.
@return A rotated version of this object.
pub fn get_source(&self) -> &B::Source
pub fn get_binarizer(&self) -> &B
Trait Implementations§
Auto Trait Implementations§
impl<B> !Freeze for BinaryBitmap<B>
impl<B> RefUnwindSafe for BinaryBitmap<B>where
B: RefUnwindSafe,
impl<B> Send for BinaryBitmap<B>where
B: Send,
impl<B> Sync for BinaryBitmap<B>where
B: Sync,
impl<B> Unpin for BinaryBitmap<B>where
B: Unpin,
impl<B> UnwindSafe for BinaryBitmap<B>where
B: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.