rgb

Struct Bgr

source
#[repr(C)]
pub struct Bgr<T> { pub b: T, pub g: T, pub r: T, }
Expand description

A Blue + Green + Red pixel.

§Examples

use rgb::Bgr;

let pixel: Bgr<u8> = Bgr { b: 0, g: 0, r: 0 };

Fields§

§b: T

Blue Component

§g: T

Green Component

§r: T

Red Component

Implementations§

source§

impl<T: Copy> Bgr<T>

source

pub const fn new_bgr(blue: T, green: T, red: T) -> Self

Creates a new Bgr pixel type from its components.

Alternatively, you can use struct literal syntax to create the new pixel type:

use rgb::Bgr;

let pixel = Bgr {b : blue, g : green, r : red};
source§

impl<T> Bgr<T>

source

pub const fn new(r: T, g: T, b: T) -> Self

👎Deprecated: This function has a misleading order of arguments. Use BGR{} literal instead

Convenience function for creating a new pixel Warning: The order of arguments is R,G,B

source§

impl<T: Clone> Bgr<T>

source

pub fn iter(&self) -> Cloned<Iter<'_, T>>

Iterate over color components (R, G, and B)

source§

impl<T: Clone> Bgr<T>

source

pub fn with_alpha(&self, a: T) -> BGRA<T>

Convenience function for converting to RGBA

source

pub fn new_alpha<A>(&self, a: A) -> BGRA<T, A>

👎Deprecated: use .with_alpha(a) instead

Convenience function for converting to RGBA with alpha channel of a different type than type of the pixels

Trait Implementations§

source§

impl<T> AsPixels<Bgr<T>> for [T]

source§

fn as_pixels(&self) -> &[BGR<T>]

source§

fn as_pixels_mut(&mut self) -> &mut [BGR<T>]

source§

impl<T: Clone> Clone for Bgr<T>

source§

fn clone(&self) -> Bgr<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Copy, B> ColorComponentMap<Bgr<B>, T, B> for Bgr<T>

source§

fn map_colors<F>(&self, f: F) -> BGR<B>
where F: FnMut(T) -> B,

Convenience function for applying the same formula to every rgb/gray component, but skipping the alpha component. Read more
source§

fn map_c<Callback>(&self, f: Callback) -> DestPixel
where Callback: FnMut(SrcComponent) -> DestComponent,

👎Deprecated: renamed to map_colors
Alias of map_colors
source§

impl<T: Copy, B> ComponentMap<Bgr<B>, T, B> for Bgr<T>

source§

fn map<F>(&self, f: F) -> BGR<B>
where F: FnMut(T) -> B,

Convenience function (equivalent of self.iter().map().collect()) for applying the same formula to every component. Read more
source§

impl<T> ComponentSlice<T> for Bgr<T>

source§

fn as_slice(&self) -> &[T]

The components interpreted as an array, e.g. one RGB expands to 3 elements. Read more
source§

fn as_mut_slice(&mut self) -> &mut [T]

The components interpreted as a mutable array, e.g. one RGB expands to 3 elements. Read more
source§

impl<T: Debug> Debug for Bgr<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T: Default> Default for Bgr<T>

source§

fn default() -> Bgr<T>

Returns the “default value” for a type. Read more
source§

impl<T: Display> Display for Bgr<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T: Copy> From<[T; 3]> for Bgr<T>

source§

fn from(other: [T; 3]) -> Self

Converts to this type from the input type.
source§

impl<R, S> From<(R, R, R)> for Bgr<S>
where R: Into<S>,

source§

fn from(value: (R, R, R)) -> Self

Converts to this type from the input type.
source§

impl<R, S> From<Bgr<R>> for (S, S, S)
where R: Into<S>,

source§

fn from(value: Bgr<R>) -> Self

Converts to this type from the input type.
source§

impl<T> From<Bgr<T>> for [T; 3]

source§

fn from(value: BGR<T>) -> Self

Converts to this type from the input type.
source§

impl<T: Copy> From<Bgr<T>> for Abgr<T, u16>

Assumes 65535 is opaque

source§

fn from(other: BGR<T>) -> Self

Converts to this type from the input type.
source§

impl<T: Copy> From<Bgr<T>> for Abgr<T, u8>

Assumes 255 is opaque

source§

fn from(other: BGR<T>) -> Self

Converts to this type from the input type.
source§

impl<T: Copy> From<Bgr<T>> for Argb<T, u16>

Assumes 65535 is opaque

source§

fn from(other: BGR<T>) -> Self

Converts to this type from the input type.
source§

impl<T: Copy> From<Bgr<T>> for Argb<T, u8>

Assumes 255 is opaque

source§

fn from(other: BGR<T>) -> Self

Converts to this type from the input type.
source§

impl<T: Copy> From<Bgr<T>> for Bgra<T, u16>

Assumes 65535 is opaque

source§

fn from(other: BGR<T>) -> Self

Converts to this type from the input type.
source§

impl<T: Copy> From<Bgr<T>> for Bgra<T, u8>

Assumes 255 is opaque

source§

fn from(other: BGR<T>) -> Self

Converts to this type from the input type.
source§

impl<T> From<Bgr<T>> for Rgb<T>
where T: Clone,

source§

fn from(other: BGR<T>) -> Self

Converts to this type from the input type.
source§

impl<T: Copy> From<Bgr<T>> for Rgba<T, u16>

Assumes 65535 is opaque

source§

fn from(other: BGR<T>) -> Self

Converts to this type from the input type.
source§

impl<T: Copy> From<Bgr<T>> for Rgba<T, u8>

Assumes 255 is opaque

source§

fn from(other: BGR<T>) -> Self

Converts to this type from the input type.
source§

impl<T> From<Rgb<T>> for Bgr<T>
where T: Clone,

source§

fn from(other: RGB<T>) -> Self

Converts to this type from the input type.
source§

impl<T: Hash> Hash for Bgr<T>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<T: LowerHex> LowerHex for Bgr<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T: Ord> Ord for Bgr<T>

source§

fn cmp(&self, other: &Bgr<T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
source§

impl<T: PartialEq> PartialEq for Bgr<T>

source§

fn eq(&self, other: &Bgr<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: PartialOrd> PartialOrd for Bgr<T>

source§

fn partial_cmp(&self, other: &Bgr<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<T: UpperHex> UpperHex for Bgr<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T> Zeroable for Bgr<T>
where T: Zeroable,

source§

fn zeroed() -> Self

source§

impl<T: Copy> Copy for Bgr<T>

source§

impl<T: Eq> Eq for Bgr<T>

source§

impl<T> Pod for Bgr<T>
where T: Pod,

source§

impl<T> StructuralPartialEq for Bgr<T>

Auto Trait Implementations§

§

impl<T> Freeze for Bgr<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Bgr<T>
where T: RefUnwindSafe,

§

impl<T> Send for Bgr<T>
where T: Send,

§

impl<T> Sync for Bgr<T>
where T: Sync,

§

impl<T> Unpin for Bgr<T>
where T: Unpin,

§

impl<T> UnwindSafe for Bgr<T>
where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CheckedBitPattern for T
where T: AnyBitPattern,

source§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
source§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> AnyBitPattern for T
where T: Pod,

source§

impl<T> NoUninit for T
where T: Pod,