Struct x11rb::image::PixelLayout[][src]

pub struct PixelLayout { /* fields omitted */ }

A collection of color components describing the red, green, and blue components of a pixel.

A ColorComponent describes a single color component in an image. This structure describes the red, green, and blue color components by containing a ColorComponent for each of them.

Implementations

impl PixelLayout[src]

pub fn new(
    red: ColorComponent,
    green: ColorComponent,
    blue: ColorComponent
) -> Self
[src]

Create a new pixel layout from the description of each component

pub fn from_visual_type(visual: Visualtype) -> Result<Self, ParseError>[src]

Create a new pixel layout

This function errors if the visual has a different class than TrueColor or DirectColor, because color pallets and grayscales are not supported. This function also errors if the mask components of the visual are malformed.

pub fn depth(self) -> u8[src]

Get the depth of this pixel layout.

The depth is the number of significant bits of each pixel value.

pub fn decode(self, pixel: u32) -> (u16, u16, u16)[src]

Decode a pixel value into its red, green, and blue components.

This function returns each component expanded to width 16.

let layout = PixelLayout::new(
    ColorComponent::new(8, 16)?,
    ColorComponent::new(8, 8)?,
    ColorComponent::new(8, 0)?,
);
assert_eq!((0xABAB, 0x4343, 0x2121), layout.decode(0x78AB_4321));

pub fn encode(self, (red, green, blue): (u16, u16, u16)) -> u32[src]

Encode a color value according to this layout.

let layout = PixelLayout::new(
    ColorComponent::new(8, 16)?,
    ColorComponent::new(8, 8)?,
    ColorComponent::new(8, 0)?,
);
assert_eq!(0x00AB_4321, layout.encode((0xABAB, 0x4343, 0x2121)));

Trait Implementations

impl Clone for PixelLayout[src]

impl Copy for PixelLayout[src]

impl Debug for PixelLayout[src]

impl Eq for PixelLayout[src]

impl PartialEq<PixelLayout> for PixelLayout[src]

impl StructuralEq for PixelLayout[src]

impl StructuralPartialEq for PixelLayout[src]

Auto Trait Implementations

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