Struct yuv::RGB

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

An RGB pixel (from the rgb crate) The RGB pixel

The component type can be u8 (aliased as RGB8), u16 (aliased as RGB16), or any other type (but simple copyable types are recommended.)

Fields§

§r: ComponentType

Red

§g: ComponentType

Green

§b: ComponentType

Blue

Implementations§

source§

impl<T> RGB<T>

source

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

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

source§

impl<T> RGB<T>
where T: Clone,

source

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

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

source§

impl<T> RGB<T>
where T: Clone,

source

pub fn alpha(&self, a: T) -> RGBA<T>

Convenience function for converting to RGBA

source

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

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

Trait Implementations§

source§

impl<T> Add<T> for RGB<T>
where T: Copy + Add<Output = T>,

px + 1

§

type Output = RGB<T>

The resulting type after applying the + operator.
source§

fn add(self, r: T) -> <RGB<T> as Add<T>>::Output

Performs the + operation. Read more
source§

impl<T> Add for RGB<T>
where T: Add,

px + px

§

type Output = RGB<<T as Add>::Output>

The resulting type after applying the + operator.
source§

fn add(self, other: RGB<T>) -> <RGB<T> as Add>::Output

Performs the + operation. Read more
source§

impl<T> AddAssign<T> for RGB<T>
where T: Copy + Add<Output = T>,

px + 1

source§

fn add_assign(&mut self, r: T)

Performs the += operation. Read more
source§

impl<T> AddAssign for RGB<T>
where T: Add<Output = T> + Copy,

px + px

source§

fn add_assign(&mut self, other: RGB<T>)

Performs the += operation. Read more
source§

impl<T> AsMut<[T]> for RGB<T>

source§

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

Converts this type into a mutable reference of the (usually inferred) input type.
source§

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

source§

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

Reinterpret the slice as a read-only/shared slice of pixels. Multiple consecutive elements in the slice are intepreted as a single pixel (depending on format, e.g. 3 for RGB, 4 for RGBA). Read more
source§

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

Reinterpret the slice as a mutable/exclusive slice of pixels. Multiple consecutive elements in the slice are intepreted as a single pixel (depending on format, e.g. 3 for RGB, 4 for RGBA). Read more
source§

impl<T> AsRef<[T]> for RGB<T>

source§

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

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<ComponentType> Clone for RGB<ComponentType>
where ComponentType: Clone,

source§

fn clone(&self) -> RGB<ComponentType>

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, B> ColorComponentMap<RGB<B>, T, B> for RGB<T>
where T: Copy,

source§

fn map_c<F>(&self, f: F) -> RGB<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§

impl<T, B> ComponentMap<RGB<B>, T, B> for RGB<T>
where T: Copy,

source§

fn map<F>(&self, f: F) -> RGB<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 RGB<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<ComponentType> Debug for RGB<ComponentType>
where ComponentType: Debug,

source§

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

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

impl<ComponentType> Default for RGB<ComponentType>
where ComponentType: Default,

source§

fn default() -> RGB<ComponentType>

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

impl<T> Display for RGB<T>
where T: Display,

source§

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

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

impl<T> Div<T> for RGB<T>
where T: Copy + Div<Output = T>,

px / 1

§

type Output = RGB<T>

The resulting type after applying the / operator.
source§

fn div(self, r: T) -> <RGB<T> as Div<T>>::Output

Performs the / operation. Read more
source§

impl<T> DivAssign<T> for RGB<T>
where T: Copy + Div<Output = T>,

px * 1

source§

fn div_assign(&mut self, r: T)

Performs the /= operation. Read more
source§

impl<T> From<[T; 3]> for RGB<T>
where T: Copy,

source§

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

Converts to this type from the input type.
source§

impl<T> From<(T, T, T)> for RGB<T>

source§

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

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>) -> RGB<T>

Converts to this type from the input type.
source§

impl<T> From<Gray<T>> for RGB<T>
where T: Clone,

source§

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

Converts to this type from the input type.
source§

impl From<RGB<f32>> for RGB<f64>

source§

fn from(other: RGB<f32>) -> RGB<f64>

Converts to this type from the input type.
source§

impl From<RGB<i16>> for RGB<f32>

source§

fn from(other: RGB<i16>) -> RGB<f32>

Converts to this type from the input type.
source§

impl From<RGB<i16>> for RGB<f64>

source§

fn from(other: RGB<i16>) -> RGB<f64>

Converts to this type from the input type.
source§

impl From<RGB<i32>> for RGB<f64>

source§

fn from(other: RGB<i32>) -> RGB<f64>

Converts to this type from the input type.
source§

impl From<RGB<u16>> for RGB<f32>

source§

fn from(other: RGB<u16>) -> RGB<f32>

Converts to this type from the input type.
source§

impl From<RGB<u16>> for RGB<f64>

source§

fn from(other: RGB<u16>) -> RGB<f64>

Converts to this type from the input type.
source§

impl From<RGB<u16>> for RGB<i32>

source§

fn from(other: RGB<u16>) -> RGB<i32>

Converts to this type from the input type.
source§

impl From<RGB<u16>> for RGB<u32>

source§

fn from(other: RGB<u16>) -> RGB<u32>

Converts to this type from the input type.
source§

impl From<RGB<u16>> for RGB<u64>

source§

fn from(other: RGB<u16>) -> RGB<u64>

Converts to this type from the input type.
source§

impl From<RGB<u8>> for RGB<f32>

source§

fn from(other: RGB<u8>) -> RGB<f32>

Converts to this type from the input type.
source§

impl From<RGB<u8>> for RGB<f64>

source§

fn from(other: RGB<u8>) -> RGB<f64>

Converts to this type from the input type.
source§

impl From<RGB<u8>> for RGB<i16>

source§

fn from(other: RGB<u8>) -> RGB<i16>

Converts to this type from the input type.
source§

impl From<RGB<u8>> for RGB<u16>

source§

fn from(other: RGB<u8>) -> RGB<u16>

Converts to this type from the input type.
source§

impl From<RGB<u8>> for RGB<u32>

source§

fn from(other: RGB<u8>) -> RGB<u32>

Converts to this type from the input type.
source§

impl<T> FromIterator<T> for RGB<T>

source§

fn from_iter<I>(into_iter: I) -> RGB<T>
where I: IntoIterator<Item = T>,

Takes exactly 3 elements from the iterator and creates a new instance. Panics if there are fewer elements in the iterator.

source§

impl<ComponentType> Hash for RGB<ComponentType>
where ComponentType: Hash,

source§

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

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> Into<[T; 3]> for RGB<T>

source§

fn into(self) -> [T; 3]

Converts this type into the (usually inferred) input type.
source§

impl<T> Into<(T, T, T)> for RGB<T>

source§

fn into(self) -> (T, T, T)

Converts this type into the (usually inferred) input type.
source§

impl<T> LowerHex for RGB<T>
where T: LowerHex,

source§

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

Formats the value using the given formatter.
source§

impl<T> Mul<T> for RGB<T>
where T: Copy + Mul<Output = T>,

px * 1

§

type Output = RGB<T>

The resulting type after applying the * operator.
source§

fn mul(self, r: T) -> <RGB<T> as Mul<T>>::Output

Performs the * operation. Read more
source§

impl<T> Mul for RGB<T>
where T: Mul,

px * px

§

type Output = RGB<<T as Mul>::Output>

The resulting type after applying the * operator.
source§

fn mul(self, other: RGB<T>) -> <RGB<T> as Mul>::Output

Performs the * operation. Read more
source§

impl<T> MulAssign<T> for RGB<T>
where T: Copy + Mul<Output = T>,

px * 1

source§

fn mul_assign(&mut self, r: T)

Performs the *= operation. Read more
source§

impl<T> MulAssign for RGB<T>
where T: Mul<Output = T> + Copy,

px * px

source§

fn mul_assign(&mut self, other: RGB<T>)

Performs the *= operation. Read more
source§

impl<ComponentType> Ord for RGB<ComponentType>
where ComponentType: Ord,

source§

fn cmp(&self, other: &RGB<ComponentType>) -> 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 + PartialOrd,

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

impl<ComponentType> PartialEq for RGB<ComponentType>
where ComponentType: PartialEq,

source§

fn eq(&self, other: &RGB<ComponentType>) -> bool

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

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

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

impl<ComponentType> PartialOrd for RGB<ComponentType>
where ComponentType: PartialOrd,

source§

fn partial_cmp(&self, other: &RGB<ComponentType>) -> 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

This method 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

This method 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

This method 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

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

impl<T> Sub<T> for RGB<T>
where T: Copy + Sub<Output = T>,

px - 1

§

type Output = RGB<<T as Sub>::Output>

The resulting type after applying the - operator.
source§

fn sub(self, r: T) -> <RGB<T> as Sub<T>>::Output

Performs the - operation. Read more
source§

impl<T> Sub for RGB<T>
where T: Sub,

px - px

§

type Output = RGB<<T as Sub>::Output>

The resulting type after applying the - operator.
source§

fn sub(self, other: RGB<T>) -> <RGB<T> as Sub>::Output

Performs the - operation. Read more
source§

impl<T> SubAssign<T> for RGB<T>
where T: Copy + Sub<Output = T>,

px - 1

source§

fn sub_assign(&mut self, r: T)

Performs the -= operation. Read more
source§

impl<T> SubAssign for RGB<T>
where T: Sub<Output = T> + Copy,

px - px

source§

fn sub_assign(&mut self, other: RGB<T>)

Performs the -= operation. Read more
source§

impl<T> Sum for RGB<T>
where T: Default + Add<Output = T>,

source§

fn sum<I>(iter: I) -> RGB<T>
where I: Iterator<Item = RGB<T>>,

Method which takes an iterator and generates Self from the elements by “summing up” the items.
source§

impl<T> UpperHex for RGB<T>
where T: UpperHex,

source§

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

Formats the value using the given formatter.
source§

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

source§

fn zeroed() -> Self

source§

impl<ComponentType> Copy for RGB<ComponentType>
where ComponentType: Copy,

source§

impl<ComponentType> Eq for RGB<ComponentType>
where ComponentType: Eq,

source§

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

source§

impl<ComponentType> StructuralPartialEq for RGB<ComponentType>

Auto Trait Implementations§

§

impl<ComponentType> Freeze for RGB<ComponentType>
where ComponentType: Freeze,

§

impl<ComponentType> RefUnwindSafe for RGB<ComponentType>
where ComponentType: RefUnwindSafe,

§

impl<ComponentType> Send for RGB<ComponentType>
where ComponentType: Send,

§

impl<ComponentType> Sync for RGB<ComponentType>
where ComponentType: Sync,

§

impl<ComponentType> Unpin for RGB<ComponentType>
where ComponentType: Unpin,

§

impl<ComponentType> UnwindSafe for RGB<ComponentType>
where ComponentType: 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,

§

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

§

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

§

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

§

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,