[][src]Struct beryllium::PixelFormat

#[repr(transparent)]
pub struct PixelFormat<'sdl> { /* fields omitted */ }

A handle to the information about a particular pixel layout.

This type works similar to the Palette type, where many images can share a single PixelFormat value and changes to the PixelFormat will show up in all places. Thankfully, the only changes you can make to a PixelFormat is changing the palette used.

Every PixelFormat is either "paletted" or not. If the PixelFormat is paletted then allocating the format value also allocates a Palette of the appropriate length. That length is either 32 (4 bits per pixel index values) or 256 (8 bits per pixel index values). Formats with a bits per pixel values of more than 8 don't use a palette.

Methods

impl<'_> PixelFormat<'_>[src]

pub fn get_rgb(&self, pixel: u32) -> Color[src]

Gets the RGB Color components of a pixel value in this format.

  • The alpha channel is always given as 0xFF

pub fn get_rgba(&self, pixel: u32) -> Color[src]

Gets the RGBA Color components of a pixel value in this format.

  • The alpha channel is always given as 0xFF if the format has no alpha channel.

pub fn map_rgb(&self, color: Color) -> u32[src]

Maps a Color value into an RGB pixel value in this format.

  • If the format is paletted the closest index is returned.
  • If the format supports alpha it will be a fully opaque pixel.
  • The pixel format data is always in the lowest bits, so you can safely downcast pixel values to u16 and u8 as appropriate.

pub fn map_rgba(&self, color: Color) -> u32[src]

Maps a Color value into an RGBA pixel value in this format.

  • If the format is paletted the closest index is returned.
  • If the format has no alpha channel or is paletted then the input alpha value is simply ignored.
  • The pixel format data is always in the lowest bits, so you can safely downcast pixel values to u16 and u8 as appropriate.

pub fn set_palette(&mut self, palette: &Palette) -> Result<(), String>[src]

Reassigns the Palette for this PixelFormat

pub fn format(&self) -> PixelFormatEnum[src]

The enum value of this pixel format.

pub fn palette(&self) -> Option<&Palette>[src]

Obtains the palette of this format, if any.

pub fn bits_per_pixel(&self) -> u8[src]

Significant bits in a pixel value: probably 8, 15, 16, 24, or 32.

pub fn bytes_per_pixel(&self) -> u8[src]

The bytes required to hold a pixel value: probably 1, 2, 3, or 4.

pub fn r_mask(&self) -> u32[src]

Mask for the location of the red component within a pixel value.

pub fn g_mask(&self) -> u32[src]

Mask for the location of the green component within a pixel value.

pub fn b_mask(&self) -> u32[src]

Mask for the location of the blue component within a pixel value.

pub fn a_mask(&self) -> u32[src]

Mask for the location of the alpha component within a pixel value.

Trait Implementations

impl<'_> Drop for PixelFormat<'_>[src]

impl<'sdl> Debug for PixelFormat<'sdl>[src]

Auto Trait Implementations

impl<'sdl> Unpin for PixelFormat<'sdl>

impl<'sdl> !Sync for PixelFormat<'sdl>

impl<'sdl> !Send for PixelFormat<'sdl>

impl<'sdl> RefUnwindSafe for PixelFormat<'sdl>

impl<'sdl> UnwindSafe for PixelFormat<'sdl>

Blanket Implementations

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

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

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<T> Borrow<T> for T where
    T: ?Sized
[src]

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

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