pub struct Image {
pub width: u32,
pub height: u32,
pub data: Vec<u8>,
}Expand description
Image data for snapshot comparison.
Fields§
§width: u32Width in pixels
height: u32Height in pixels
data: Vec<u8>RGBA pixel data (4 bytes per pixel)
Implementations§
Source§impl Image
impl Image
Sourcepub fn filled(width: u32, height: u32, r: u8, g: u8, b: u8, a: u8) -> Self
pub fn filled(width: u32, height: u32, r: u8, g: u8, b: u8, a: u8) -> Self
Create an image filled with a single color.
Sourcepub fn fill_rect(
&mut self,
x: i32,
y: i32,
width: u32,
height: u32,
color: &Color,
)
pub fn fill_rect( &mut self, x: i32, y: i32, width: u32, height: u32, color: &Color, )
Fill a rectangle with a color (software rendering).
Sourcepub fn fill_circle(&mut self, cx: i32, cy: i32, radius: u32, color: &Color)
pub fn fill_circle(&mut self, cx: i32, cy: i32, radius: u32, color: &Color)
Fill a circle with a color (software rendering).
Sourcepub fn render(&mut self, commands: &[DrawCommand])
pub fn render(&mut self, commands: &[DrawCommand])
Render draw commands to this image (software renderer).
Sourcepub fn region(&self, x: u32, y: u32, width: u32, height: u32) -> Image
pub fn region(&self, x: u32, y: u32, width: u32, height: u32) -> Image
Extract a sub-region of the image.
Sourcepub fn scale(&self, new_width: u32, new_height: u32) -> Image
pub fn scale(&self, new_width: u32, new_height: u32) -> Image
Scale image to new dimensions (nearest neighbor).
Sourcepub fn count_color(&self, target: [u8; 4], tolerance: u8) -> usize
pub fn count_color(&self, target: [u8; 4], tolerance: u8) -> usize
Count pixels matching a specific color (with tolerance).
Sourcepub fn mean_color(&self) -> [f32; 4]
pub fn mean_color(&self) -> [f32; 4]
Calculate mean color.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Image
impl RefUnwindSafe for Image
impl Send for Image
impl Sync for Image
impl Unpin for Image
impl UnwindSafe for Image
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
Mutably borrows from an owned value. Read more
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>
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 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>
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