[][src]Struct rsvg_internals::surface_utils::Pixel

pub struct Pixel {
    pub r: u8,
    pub g: u8,
    pub b: u8,
    pub a: u8,
}

A pixel consisting of R, G, B and A values.

Fields

r: u8g: u8b: u8a: u8

Methods

impl Pixel[src]

pub fn unpremultiply(self) -> Self[src]

Returns an unpremultiplied value of this pixel.

pub fn premultiply(self) -> Self[src]

Returns a premultiplied value of this pixel.

pub fn to_u32(self) -> u32[src]

Returns the pixel value as a u32, in the same format as cairo::Format::ARgb32.

pub fn from_u32(x: u32) -> Self[src]

Converts a u32 in the same format as cairo::Format::ARgb32 into a Pixel.

pub fn to_mask(self, opacity: u8) -> Self[src]

Returns a 'mask' pixel with only the alpha channel

Assuming, the pixel is linear RGB (not sRGB) y = luminance Y = 0.2126 R + 0.7152 G + 0.0722 B 1.0 opacity = 255

When Y = 1.0, pixel for mask should be 0xFFFFFFFF (you get 1.0 luminance from 255 from R, G and B)

r_mult = 0xFFFFFFFF / (255.0 * 255.0) * .2126 = 14042.45 ~= 14042 g_mult = 0xFFFFFFFF / (255.0 * 255.0) * .7152 = 47239.69 ~= 47240 b_mult = 0xFFFFFFFF / (255.0 * 255.0) * .0722 = 4768.88 ~= 4769

This allows for the following expected behaviour: (we only care about the most sig byte) if pixel = 0x00FFFFFF, pixel' = 0xFF...... if pixel = 0x00020202, pixel' = 0x02...... if pixel = 0x00000000, pixel' = 0x00......

pub fn diff(self, pixel: &Pixel) -> Pixel[src]

Trait Implementations

impl Clone for Pixel[src]

impl Copy for Pixel[src]

impl Debug for Pixel[src]

impl Eq for Pixel[src]

impl Hash for Pixel[src]

impl PartialEq<Pixel> for Pixel[src]

impl StructuralEq for Pixel[src]

impl StructuralPartialEq for Pixel[src]

Auto Trait Implementations

impl RefUnwindSafe for Pixel

impl Send for Pixel

impl Sync for Pixel

impl Unpin for Pixel

impl UnwindSafe for Pixel

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Scalar for T where
    T: PartialEq<T> + Copy + Any + Debug
[src]

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,