Struct x11rb::image::PixelLayout [−][src]
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]
red: ColorComponent,
green: ColorComponent,
blue: ColorComponent
) -> Self
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]
fn clone(&self) -> PixelLayout
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for PixelLayout
[src]
impl Debug for PixelLayout
[src]
impl Eq for PixelLayout
[src]
impl PartialEq<PixelLayout> for PixelLayout
[src]
fn eq(&self, other: &PixelLayout) -> bool
[src]
fn ne(&self, other: &PixelLayout) -> bool
[src]
impl StructuralEq for PixelLayout
[src]
impl StructuralPartialEq for PixelLayout
[src]
Auto Trait Implementations
impl RefUnwindSafe for PixelLayout
impl Send for PixelLayout
impl Sync for PixelLayout
impl Unpin for PixelLayout
impl UnwindSafe for PixelLayout
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,