pub struct BlendKernel;Expand description
GPU-style image blending kernel (CPU simulation via Rayon).
Operates on packed RGBA (4 bytes / pixel) buffers.
dst is modified in place (it acts as both the base and the output).
Implementations§
Source§impl BlendKernel
impl BlendKernel
Sourcepub fn blend(
src: &[u8],
dst: &mut [u8],
width: u32,
height: u32,
mode: BlendMode,
opacity: u8,
) -> Result<BlendStats, BlendError>
pub fn blend( src: &[u8], dst: &mut [u8], width: u32, height: u32, mode: BlendMode, opacity: u8, ) -> Result<BlendStats, BlendError>
Blend src over dst using the specified blend mode and global opacity.
opacity controls how much of src is mixed in (0 = invisible, 255 = fully opaque).
The per-pixel alpha in src is also respected by all modes.
§Errors
Returns BlendError if buffers or dimensions are invalid.
Sourcepub fn blend_masked(
src: &[u8],
dst: &mut [u8],
mask: &[u8],
width: u32,
height: u32,
mode: BlendMode,
global_opacity: u8,
) -> Result<BlendStats, BlendError>
pub fn blend_masked( src: &[u8], dst: &mut [u8], mask: &[u8], width: u32, height: u32, mode: BlendMode, global_opacity: u8, ) -> Result<BlendStats, BlendError>
Blend with a per-pixel opacity mask (single channel, one byte per pixel).
Each pixel’s effective opacity is global_opacity * mask[i] / 255.
§Errors
Returns BlendError if any buffer or mask length is invalid.
Sourcepub fn composite_layers(
layers: &[(&[u8], u8)],
width: u32,
height: u32,
) -> Result<Vec<u8>, BlendError>
pub fn composite_layers( layers: &[(&[u8], u8)], width: u32, height: u32, ) -> Result<Vec<u8>, BlendError>
Composite multiple layers using Porter-Duff “over” operator.
Layers are composited from bottom to top (index 0 is the base).
Each (buffer, opacity) entry is blended onto the accumulator.
§Errors
Returns BlendError if any layer has incorrect dimensions.
Sourcepub fn apply_tint(
src: &[u8],
dst: &mut [u8],
width: u32,
height: u32,
tint: [u8; 4],
) -> Result<(), BlendError>
pub fn apply_tint( src: &[u8], dst: &mut [u8], width: u32, height: u32, tint: [u8; 4], ) -> Result<(), BlendError>
Apply a constant color tint (multiply by a solid RGBA color).
Each pixel is multiplied component-wise by tint / 255.
§Errors
Returns BlendError if buffer or dimensions are invalid.
Sourcepub fn premultiply_alpha(
buf: &mut [u8],
width: u32,
height: u32,
) -> Result<(), BlendError>
pub fn premultiply_alpha( buf: &mut [u8], width: u32, height: u32, ) -> Result<(), BlendError>
Premultiply RGB channels by the alpha channel in place.
Input: [R, G, B, A] straight alpha.
Output: [R*A/255, G*A/255, B*A/255, A] premultiplied.
§Errors
Returns BlendError on dimension or buffer mismatch.
Sourcepub fn unpremultiply_alpha(
buf: &mut [u8],
width: u32,
height: u32,
) -> Result<(), BlendError>
pub fn unpremultiply_alpha( buf: &mut [u8], width: u32, height: u32, ) -> Result<(), BlendError>
Un-premultiply alpha (divide RGB by alpha).
Pixels with A = 0 are left as [0, 0, 0, 0].
§Errors
Returns BlendError on dimension or buffer mismatch.
Trait Implementations§
Source§impl Clone for BlendKernel
impl Clone for BlendKernel
Source§fn clone(&self) -> BlendKernel
fn clone(&self) -> BlendKernel
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BlendKernel
impl Debug for BlendKernel
Source§impl Default for BlendKernel
impl Default for BlendKernel
Source§fn default() -> BlendKernel
fn default() -> BlendKernel
Auto Trait Implementations§
impl Freeze for BlendKernel
impl RefUnwindSafe for BlendKernel
impl Send for BlendKernel
impl Sync for BlendKernel
impl Unpin for BlendKernel
impl UnsafeUnpin for BlendKernel
impl UnwindSafe for BlendKernel
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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