pub struct Image {
pub data: Vec<u8>,
pub width: u32,
pub height: u32,
}Expand description
A decoded image: RGBA, 4 bytes per pixel, row-major.
Fields§
§data: Vec<u8>§width: u32§height: u32Implementations§
Source§impl Image
impl Image
pub fn new(width: u32, height: u32) -> Self
Sourcepub fn new_uninit(width: u32, height: u32) -> Self
pub fn new_uninit(width: u32, height: u32) -> Self
Create an image whose pixel data is left uninitialized.
Use this for diff-output buffers that the diff pipeline fully
overwrites — either by clear_transparent (diff_mask mode), by the
deferred gray-fill pass (when at least one block differs and diff_mask
is off), or by the hot pass writing changed blocks. The only call path
that does not overwrite is the early “identical” short-circuit: in that
case result.identical is true and every shipping front-end (CLI,
N-API, Python, the WASM in-place copy) already skips reading the output
buffer.
Avoiding vec![0u8; ...] here saves a 64 MB memset per 4K-image diff.
The OS’s allocator typically hands us freshly-cleared pages for big
allocations anyway, but tiny diffs (a few hundred KB) reuse arena memory
whose contents are whatever the last call left behind — fine here,
because the callers above respect the “identical → don’t read” contract.
pub fn as_u32(&self) -> &[u32]
pub fn as_u32_mut(&mut self) -> &mut [u32]
pub fn get_pixel(&self, x: u32, y: u32) -> u32
pub fn set_pixel(&mut self, x: u32, y: u32, pixel: u32)
Auto Trait Implementations§
impl Freeze for Image
impl RefUnwindSafe for Image
impl Send for Image
impl Sync for Image
impl Unpin for Image
impl UnsafeUnpin 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
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