pub struct CompositionMode(/* private fields */);
Expand description

Defines the modes supported for digital image compositing. Composition modes are used to specify how the pixels in one image, the source, are merged with the pixel in another image, the destination.

C++ enum: QPainter::CompositionMode.

C++ documentation:

Defines the modes supported for digital image compositing. Composition modes are used to specify how the pixels in one image, the source, are merged with the pixel in another image, the destination.

Please note that the bitwise raster operation modes, denoted with a RasterOp prefix, are only natively supported in the X11 and raster paint engines. This means that the only way to utilize these modes on the Mac is via a QImage. The RasterOp denoted blend modes are not supported for pens and brushes with alpha components. Also, turning on the QPainter::Antialiasing render hint will effectively disable the RasterOp modes.

The most common type is SourceOver (often referred to as just alpha blending) where the source pixel is blended on top of the destination pixel in such a way that the alpha component of the source defines the translucency of the pixel.

Several composition modes require an alpha channel in the source or target images to have an effect. For optimal performance the image format Format_ARGB32_Premultiplied is preferred.

When a composition mode is set it applies to all painting operator, pens, brushes, gradients and pixmap/image drawing.

See also compositionMode(), setCompositionMode(), Composition Modes, and Image Composition Example.

Implementations§

source§

impl CompositionMode

source

pub fn to_int(&self) -> c_int

source§

impl CompositionMode

source

pub const CompositionModeSourceOver: CompositionMode = _

This is the default mode. The alpha of the source is used to blend the pixel on top of the destination. (C++ enum variant: CompositionMode_SourceOver = 0)

source

pub const CompositionModeDestinationOver: CompositionMode = _

The alpha of the destination is used to blend it on top of the source pixels. This mode is the inverse of CompositionMode_SourceOver. (C++ enum variant: CompositionMode_DestinationOver = 1)

source

pub const CompositionModeClear: CompositionMode = _

The pixels in the destination are cleared (set to fully transparent) independent of the source. (C++ enum variant: CompositionMode_Clear = 2)

source

pub const CompositionModeSource: CompositionMode = _

The output is the source pixel. (This means a basic copy operation and is identical to SourceOver when the source pixel is opaque). (C++ enum variant: CompositionMode_Source = 3)

source

pub const CompositionModeDestination: CompositionMode = _

The output is the destination pixel. This means that the blending has no effect. This mode is the inverse of CompositionMode_Source. (C++ enum variant: CompositionMode_Destination = 4)

source

pub const CompositionModeSourceIn: CompositionMode = _

The output is the source, where the alpha is reduced by that of the destination. (C++ enum variant: CompositionMode_SourceIn = 5)

source

pub const CompositionModeDestinationIn: CompositionMode = _

The output is the destination, where the alpha is reduced by that of the source. This mode is the inverse of CompositionMode_SourceIn. (C++ enum variant: CompositionMode_DestinationIn = 6)

source

pub const CompositionModeSourceOut: CompositionMode = _

The output is the source, where the alpha is reduced by the inverse of destination. (C++ enum variant: CompositionMode_SourceOut = 7)

source

pub const CompositionModeDestinationOut: CompositionMode = _

The output is the destination, where the alpha is reduced by the inverse of the source. This mode is the inverse of CompositionMode_SourceOut. (C++ enum variant: CompositionMode_DestinationOut = 8)

source

pub const CompositionModeSourceAtop: CompositionMode = _

The source pixel is blended on top of the destination, with the alpha of the source pixel reduced by the alpha of the destination pixel. (C++ enum variant: CompositionMode_SourceAtop = 9)

source

pub const CompositionModeDestinationAtop: CompositionMode = _

The destination pixel is blended on top of the source, with the alpha of the destination pixel is reduced by the alpha of the destination pixel. This mode is the inverse of CompositionMode_SourceAtop. (C++ enum variant: CompositionMode_DestinationAtop = 10)

source

pub const CompositionModeXor: CompositionMode = _

The source, whose alpha is reduced with the inverse of the destination alpha, is merged with the destination, whose alpha is reduced by the inverse of the source alpha. CompositionMode_Xor is not the same as the bitwise Xor. (C++ enum variant: CompositionMode_Xor = 11)

source

pub const CompositionModePlus: CompositionMode = _

Both the alpha and color of the source and destination pixels are added together. (C++ enum variant: CompositionMode_Plus = 12)

source

pub const CompositionModeMultiply: CompositionMode = _

The output is the source color multiplied by the destination. Multiplying a color with white leaves the color unchanged, while multiplying a color with black produces black. (C++ enum variant: CompositionMode_Multiply = 13)

source

pub const CompositionModeScreen: CompositionMode = _

The source and destination colors are inverted and then multiplied. Screening a color with white produces white, whereas screening a color with black leaves the color unchanged. (C++ enum variant: CompositionMode_Screen = 14)

source

pub const CompositionModeOverlay: CompositionMode = _

Multiplies or screens the colors depending on the destination color. The destination color is mixed with the source color to reflect the lightness or darkness of the destination. (C++ enum variant: CompositionMode_Overlay = 15)

source

pub const CompositionModeDarken: CompositionMode = _

The darker of the source and destination colors is selected. (C++ enum variant: CompositionMode_Darken = 16)

source

pub const CompositionModeLighten: CompositionMode = _

The lighter of the source and destination colors is selected. (C++ enum variant: CompositionMode_Lighten = 17)

source

pub const CompositionModeColorDodge: CompositionMode = _

The destination color is brightened to reflect the source color. A black source color leaves the destination color unchanged. (C++ enum variant: CompositionMode_ColorDodge = 18)

source

pub const CompositionModeColorBurn: CompositionMode = _

The destination color is darkened to reflect the source color. A white source color leaves the destination color unchanged. (C++ enum variant: CompositionMode_ColorBurn = 19)

source

pub const CompositionModeHardLight: CompositionMode = _

Multiplies or screens the colors depending on the source color. A light source color will lighten the destination color, whereas a dark source color will darken the destination color. (C++ enum variant: CompositionMode_HardLight = 20)

source

pub const CompositionModeSoftLight: CompositionMode = _

Darkens or lightens the colors depending on the source color. Similar to CompositionMode_HardLight. (C++ enum variant: CompositionMode_SoftLight = 21)

source

pub const CompositionModeDifference: CompositionMode = _

Subtracts the darker of the colors from the lighter. Painting with white inverts the destination color, whereas painting with black leaves the destination color unchanged. (C++ enum variant: CompositionMode_Difference = 22)

source

pub const CompositionModeExclusion: CompositionMode = _

Similar to CompositionMode_Difference, but with a lower contrast. Painting with white inverts the destination color, whereas painting with black leaves the destination color unchanged. (C++ enum variant: CompositionMode_Exclusion = 23)

source

pub const RasterOpSourceOrDestination: CompositionMode = _

Does a bitwise OR operation on the source and destination pixels (src OR dst). (C++ enum variant: RasterOp_SourceOrDestination = 24)

source

pub const RasterOpSourceAndDestination: CompositionMode = _

Does a bitwise AND operation on the source and destination pixels (src AND dst). (C++ enum variant: RasterOp_SourceAndDestination = 25)

source

pub const RasterOpSourceXorDestination: CompositionMode = _

Does a bitwise XOR operation on the source and destination pixels (src XOR dst). (C++ enum variant: RasterOp_SourceXorDestination = 26)

source

pub const RasterOpNotSourceAndNotDestination: CompositionMode = _

Does a bitwise NOR operation on the source and destination pixels ((NOT src) AND (NOT dst)). (C++ enum variant: RasterOp_NotSourceAndNotDestination = 27)

source

pub const RasterOpNotSourceOrNotDestination: CompositionMode = _

Does a bitwise NAND operation on the source and destination pixels ((NOT src) OR (NOT dst)). (C++ enum variant: RasterOp_NotSourceOrNotDestination = 28)

source

pub const RasterOpNotSourceXorDestination: CompositionMode = _

Does a bitwise operation where the source pixels are inverted and then XOR’ed with the destination ((NOT src) XOR dst). (C++ enum variant: RasterOp_NotSourceXorDestination = 29)

source

pub const RasterOpNotSource: CompositionMode = _

Does a bitwise operation where the source pixels are inverted (NOT src). (C++ enum variant: RasterOp_NotSource = 30)

source

pub const RasterOpNotSourceAndDestination: CompositionMode = _

Does a bitwise operation where the source is inverted and then AND’ed with the destination ((NOT src) AND dst). (C++ enum variant: RasterOp_NotSourceAndDestination = 31)

source

pub const RasterOpSourceAndNotDestination: CompositionMode = _

Does a bitwise operation where the source is AND’ed with the inverted destination pixels (src AND (NOT dst)). (C++ enum variant: RasterOp_SourceAndNotDestination = 32)

source

pub const RasterOpNotSourceOrDestination: CompositionMode = _

Does a bitwise operation where the source is inverted and then OR’ed with the destination ((NOT src) OR dst). (C++ enum variant: RasterOp_NotSourceOrDestination = 33)

source

pub const RasterOpSourceOrNotDestination: CompositionMode = _

Does a bitwise operation where the source is OR’ed with the inverted destination pixels (src OR (NOT dst)). (C++ enum variant: RasterOp_SourceOrNotDestination = 34)

source

pub const RasterOpClearDestination: CompositionMode = _

The pixels in the destination are cleared (set to 0) independent of the source. (C++ enum variant: RasterOp_ClearDestination = 35)

source

pub const RasterOpSetDestination: CompositionMode = _

The pixels in the destination are set (set to 1) independent of the source. (C++ enum variant: RasterOp_SetDestination = 36)

source

pub const RasterOpNotDestination: CompositionMode = _

Does a bitwise operation where the destination pixels are inverted (NOT dst). (C++ enum variant: RasterOp_NotDestination = 37)

Trait Implementations§

source§

impl Clone for CompositionMode

source§

fn clone(&self) -> CompositionMode

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for CompositionMode

source§

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

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

impl From<CompositionMode> for c_int

source§

fn from(value: CompositionMode) -> Self

Converts to this type from the input type.
source§

impl From<i32> for CompositionMode

source§

fn from(value: c_int) -> Self

Converts to this type from the input type.
source§

impl PartialEq for CompositionMode

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for CompositionMode

source§

impl Eq for CompositionMode

source§

impl StructuralEq for CompositionMode

source§

impl StructuralPartialEq for CompositionMode

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, U> CastInto<U> for T
where U: CastFrom<T>,

source§

unsafe fn cast_into(self) -> U

Performs the conversion. 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> StaticUpcast<T> for T

source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

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>,

§

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>,

§

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.