Struct BinaryBitmap

Source
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>

Source

pub fn new(binarizer: B) -> Self

Source

pub fn get_width(&self) -> usize

@return The width of the bitmap.

Source

pub fn get_height(&self) -> usize

@return The height of the bitmap.

Source

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

Source

pub fn get_black_line( &self, l: usize, lt: LineOrientation, ) -> Result<Cow<'_, BitArray>>

Get a row or column of the image

Source

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

Source

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

Source

pub fn is_crop_supported(&self) -> bool

@return Whether this bitmap can be cropped.

Source

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.

Source

pub fn is_rotate_supported(&self) -> bool

@return Whether this bitmap supports counter-clockwise rotation.

Source

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.

Source

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.

Source

pub fn get_source(&self) -> &B::Source

Source

pub fn get_binarizer(&self) -> &B

Source§

impl<B: Binarizer> BinaryBitmap<B>

Source

pub fn close(&mut self) -> Result<()>

Trait Implementations§

Source§

impl<B: Binarizer> Display for BinaryBitmap<B>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V