[][src]Struct embedded_graphics::pixelcolor::Rgb565

pub struct Rgb565(pub u16);

A pixel type defining the commonly used RGB565 format

Pixel values are stored in a single u16 segmented as follows:

15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0
 r  r  r  r  r  g  g  g  g  g  g  b  b  b  b  b

Methods

impl Rgb565[src]

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

Get the red component as a u8

The least significant 3 bits will always be 0

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

Get the green component as a u8

The least significant 2 bits will always be 0

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

Get the blue component as a u8

The least significant 3 bits will always be 0

Trait Implementations

impl Clone for Rgb565[src]

impl Copy for Rgb565[src]

impl Debug for Rgb565[src]

impl From<[u8; 2]> for Rgb565[src]

Build a u16 from two u8s

Uses u16::from_be_bytes internally. If the input bytes are little endian, use u16::from_le_bytes directly:

use embedded_graphics::pixelcolor::Rgb565;

let pixel = Rgb565(u16::from_le_bytes([0xab, 0xcd]));

assert_eq!(pixel, Rgb565(0xCDAB));

impl From<(u8, u8, u8)> for Rgb565[src]

Take a tuple of 8 bit (red, green, blue) color values and convert them to a single 16 bit color

The 2 or 3 (for the green channel) least significant bits are discarded

impl From<u16> for Rgb565[src]

impl From<u8> for Rgb565[src]

Convert from an 8 bit greyscale colour into a 16 bit greyscale representation

The 5 (or 6 for the green channel) most significant bits are taken from the input and assigned to the three colour channels see http://www.barth-dev.de/online/rgb565-color-picker/ for a more in depth explanation.

impl PartialEq<Rgb565> for Rgb565[src]

impl PixelColor for Rgb565[src]

impl StructuralPartialEq for Rgb565[src]

Auto Trait Implementations

impl Send for Rgb565

impl Sync for Rgb565

impl Unpin for Rgb565

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