pub struct Bitmap {
pub image: DynamicImage,
pub size: Size,
pub scale: f64,
}
Fields§
§image: DynamicImage
§size: Size
Size of the bitmap in points.
scale: f64
Implementations§
Source§impl Bitmap
impl Bitmap
Sourcepub fn new(image: DynamicImage, scale: Option<f64>) -> Bitmap
pub fn new(image: DynamicImage, scale: Option<f64>) -> Bitmap
Creates a bitmap from the given DynamicImage
, and scale if given
(defaults to 1).
Sourcepub fn copy_to_pasteboard(&self) -> ImageResult<()>
pub fn copy_to_pasteboard(&self) -> ImageResult<()>
Copies image to pasteboard. Currently only supported on macOS.
Sourcepub fn cropped(&mut self, rect: Rect) -> ImageResult<Bitmap>
pub fn cropped(&mut self, rect: Rect) -> ImageResult<Bitmap>
Returns new Bitmap created from a portion of another.
pub fn get_pixel(&self, point: Point) -> Rgba<u8>
Sourcepub fn bitmap_eq(&self, needle: &Bitmap, tolerance: Option<f64>) -> bool
pub fn bitmap_eq(&self, needle: &Bitmap, tolerance: Option<f64>) -> bool
Returns true if bitmap is equal to needle with the given tolerance.
Sourcepub fn find_color(
&self,
needle: Rgba<u8>,
tolerance: Option<f64>,
rect: Option<Rect>,
start_point: Option<Point>,
) -> Option<Point>
pub fn find_color( &self, needle: Rgba<u8>, tolerance: Option<f64>, rect: Option<Rect>, start_point: Option<Point>, ) -> Option<Point>
Attempts to find color
inside rect
in bmp
from the given
start_point
. Returns coordinates if found, or None
if not. If
rect
is None
, bmp.bounds()
is used instead. If start_point
is
None
, the origin of rect
is used.
Tolerance is defined as a float in the range from 0 to 1, where 0 is an exact match and 1 matches anything.
Sourcepub fn find_every_color(
&self,
needle: Rgba<u8>,
tolerance: Option<f64>,
rect: Option<Rect>,
start_point: Option<Point>,
) -> Vec<Point>
pub fn find_every_color( &self, needle: Rgba<u8>, tolerance: Option<f64>, rect: Option<Rect>, start_point: Option<Point>, ) -> Vec<Point>
Returns list of all coordinates inside rect
in bmp
matching
color
from the given start_point
. If rect
is None
,
bmp.bounds()
is used instead. If start_point
is None
, the origin
of rect
is used.
Sourcepub fn count_of_color(
&self,
needle: Rgba<u8>,
tolerance: Option<f64>,
rect: Option<Rect>,
start_point: Option<Point>,
) -> u64
pub fn count_of_color( &self, needle: Rgba<u8>, tolerance: Option<f64>, rect: Option<Rect>, start_point: Option<Point>, ) -> u64
Returns count of color in bitmap. Functionally equivalent to:
find_every_color(color, tolerance, rect, start_point).count()
Sourcepub fn find_bitmap(
&self,
needle: &Bitmap,
tolerance: Option<f64>,
rect: Option<Rect>,
start_point: Option<Point>,
) -> Option<Point>
pub fn find_bitmap( &self, needle: &Bitmap, tolerance: Option<f64>, rect: Option<Rect>, start_point: Option<Point>, ) -> Option<Point>
Attempts to find needle
inside rect
in bmp
from the given
start_point
. Returns coordinates if found, or None
if not. If
rect
is None
, bmp.bounds()
is used instead. If start_point
is
None
, the origin of rect
is used.
Tolerance is defined as a float in the range from 0 to 1, where 0 is an exact match and 1 matches anything.
Sourcepub fn find_every_bitmap(
&self,
needle: &Bitmap,
tolerance: Option<f64>,
rect: Option<Rect>,
start_point: Option<Point>,
) -> Vec<Point>
pub fn find_every_bitmap( &self, needle: &Bitmap, tolerance: Option<f64>, rect: Option<Rect>, start_point: Option<Point>, ) -> Vec<Point>
Returns list of all coordinates inside rect
in bmp
matching
needle
from the given start_point
. If rect
is None
,
bmp.bounds
is used instead. If start_point
is None
, the origin
of rect
is used.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Bitmap
impl RefUnwindSafe for Bitmap
impl Send for Bitmap
impl Sync for Bitmap
impl Unpin for Bitmap
impl UnwindSafe for Bitmap
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more