Skip to main content

BlendMode

Enum BlendMode 

Source
pub enum BlendMode {
Show 24 variants Normal, Multiply, Screen, Overlay, SoftLight, HardLight, ColorDodge, ColorBurn, Darken, Lighten, Difference, Exclusion, Add, Subtract, Hue, Saturation, Color, Luminosity, PorterDuffOver, PorterDuffUnder, PorterDuffIn, PorterDuffOut, PorterDuffAtop, PorterDuffXor,
}
Expand description

Specifies how two video layers are combined during compositing.

Variants are grouped into two families:

  • Photographic blend modes (18) — operate on pixel values; both layers are typically opaque. Implemented via FFmpeg’s blend filter with the all_mode option, except BlendMode::Normal which uses overlay.

  • Porter-Duff alpha compositing (6) — operate on the alpha channel; at least the top layer must carry an alpha channel (e.g. rgba or yuva420p pixel format).

§Implementation status

All 14 arithmetic photographic modes and all 6 Porter-Duff operations are fully implemented and covered by regression tests (issues #327–#347).

The four HSL-space modes — BlendMode::Hue, BlendMode::Saturation, BlendMode::Color, and BlendMode::Luminosity — are accepted by the builder but produce no output at runtime: FFmpeg’s blend filter does not include these mode names in the bundled version. The builder returns FilterError::BuildFailed when the filter graph cannot be configured for these modes.

Variants§

§

Normal

Standard alpha-over composite (top * opacity + bottom * (1 − opacity)).

Implemented via FFmpeg’s overlay=format=auto:shortest=1.

§

Multiply

Multiply per-channel pixel values; darkens the result.

Maps to blend all_mode=multiply.

§

Screen

Inverse of multiply; lightens the result.

Maps to blend all_mode=screen.

§

Overlay

Combines Multiply and Screen based on base-layer luminance.

Maps to blend all_mode=overlay.

§

SoftLight

Gentle contrast enhancement; 50 % gray top layer is identity.

Maps to blend all_mode=softlight.

§

HardLight

Harsher version of Overlay; driven by the top layer’s luminance.

Maps to blend all_mode=hardlight.

§

ColorDodge

Brightens the base by dividing it by the inverse of the blend.

Maps to blend all_mode=dodge.

§

ColorBurn

Darkens the base; inverse of Color Dodge.

Maps to blend all_mode=burn.

§

Darken

Retains the darker of the two pixels per channel.

Maps to blend all_mode=darken.

§

Lighten

Retains the lighter of the two pixels per channel.

Maps to blend all_mode=lighten.

§

Difference

Per-channel absolute difference. Useful for alignment verification.

Maps to blend all_mode=difference.

§

Exclusion

Similar to Difference but with lower contrast in mid-tones.

Maps to blend all_mode=exclusion.

§

Add

Linear addition, clamped at maximum.

Maps to blend all_mode=addition.

§

Subtract

Linear subtraction, clamped at minimum.

Maps to blend all_mode=subtract.

§

Hue

Applies the top layer’s hue to the base’s saturation and luminance.

Maps to blend all_mode=hue.

Note: not supported by the bundled FFmpeg blend filter; graph construction succeeds but no output frame is produced at runtime.

§

Saturation

Applies the top layer’s saturation to the base’s hue and luminance.

Maps to blend all_mode=saturation.

Note: not supported by the bundled FFmpeg blend filter; graph construction succeeds but no output frame is produced at runtime.

§

Color

Applies the top layer’s hue + saturation to the base’s luminance.

Maps to blend all_mode=color.

Note: not supported by the bundled FFmpeg blend filter; graph construction succeeds but no output frame is produced at runtime.

§

Luminosity

Applies the top layer’s luminance to the base’s hue and saturation.

Maps to blend all_mode=luminosity.

Note: not supported by the bundled FFmpeg blend filter; graph construction succeeds but no output frame is produced at runtime.

§

PorterDuffOver

Top layer rendered over the bottom (standard alpha compositing).

Implemented via overlay=format=auto:shortest=1.

§

PorterDuffUnder

Bottom layer rendered over the top; equivalent to Over with inputs swapped.

§

PorterDuffIn

Top layer masked by the bottom layer’s alpha (intersection).

§

PorterDuffOut

Top layer visible only where the bottom layer is transparent.

§

PorterDuffAtop

Top layer placed atop the bottom; visible only where the bottom is opaque.

§

PorterDuffXor

Pixels from exactly one layer (XOR of opaque regions).

Trait Implementations§

Source§

impl Clone for BlendMode

Source§

fn clone(&self) -> BlendMode

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for BlendMode

Source§

impl Debug for BlendMode

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for BlendMode

Source§

impl PartialEq for BlendMode

Source§

fn eq(&self, other: &BlendMode) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for BlendMode

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.