Struct lodepng::GreyAlpha

source ·
#[repr(C)]
pub struct GreyAlpha<ComponentType, AlphaComponentType = ComponentType>(pub ComponentType, pub AlphaComponentType);
Expand description

Grayscale with alpha. Use .0/.1 to access.

Tuple Fields§

§0: ComponentType

brightness level

§1: AlphaComponentType

alpha

Implementations§

source§

impl<T, A> GrayAlpha<T, A>
where T: Clone,

source

pub fn gray(&self) -> Gray<T>

Copy Gray component out of the GrayAlpha struct

source§

impl<T, A> GrayAlpha<T, A>

source

pub const fn new(brightness: T, alpha: A) -> GrayAlpha<T, A>

New grayscale+alpha pixel

source

pub fn gray_mut(&mut self) -> &mut Gray<T>

Provide a mutable view of only Gray component (leaving out alpha).

source§

impl<T, A> GrayAlpha<T, A>
where T: Copy, A: Clone,

source

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

Create a new GrayAlpha with the new alpha value, but same gray value

source

pub fn map_alpha<F, B>(&self, f: F) -> GrayAlpha<T, B>
where F: FnOnce(A) -> B,

Create a new GrayAlpha with a new alpha value created by the callback.

source

pub fn map_gray<F, U, B>(&self, f: F) -> GrayAlpha<U, B>
where F: FnOnce(T) -> U, U: Clone, B: From<A> + Clone,

Create new GrayAlpha with the same alpha value, but different Gray value

Trait Implementations§

source§

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

px + 1

§

type Output = GrayAlpha<T>

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl<T, A> Add for GrayAlpha<T, A>
where T: Add, A: Add,

px + px

§

type Output = GrayAlpha<<T as Add>::Output, <A as Add>::Output>

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl<T> AddAssign<T> for GrayAlpha<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, A> AddAssign for GrayAlpha<T, A>
where T: Add<Output = T> + Copy, A: Add<Output = A> + Copy,

px + px

source§

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

Performs the += operation. Read more
source§

impl<T> AsMut<T> for GrayAlpha<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<GrayAlpha<T>> for [T]

source§

fn as_pixels(&self) -> &[GrayAlpha<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 [GrayAlpha<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 GrayAlpha<T>

source§

fn as_ref(&self) -> &T

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

impl<ComponentType, AlphaComponentType> Clone for GrayAlpha<ComponentType, AlphaComponentType>
where ComponentType: Clone, AlphaComponentType: Clone,

source§

fn clone(&self) -> GrayAlpha<ComponentType, AlphaComponentType>

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

source§

fn map_c<F>(&self, f: F) -> GrayAlpha<B, A>
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<GrayAlpha<B>, T, B> for GrayAlpha<T>
where T: Copy,

source§

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

source§

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

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

impl<ComponentType, AlphaComponentType> Default for GrayAlpha<ComponentType, AlphaComponentType>
where ComponentType: Default, AlphaComponentType: Default,

source§

fn default() -> GrayAlpha<ComponentType, AlphaComponentType>

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

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

px / 1

§

type Output = GrayAlpha<T>

The resulting type after applying the / operator.
source§

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

Performs the / operation. Read more
source§

impl<T> DivAssign<T> for GrayAlpha<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<Gray<T>> for GrayAlpha<T, u16>
where T: Copy,

Assumes 65535 is opaque

source§

fn from(other: Gray<T>) -> GrayAlpha<T, u16>

Converts to this type from the input type.
source§

impl<T> From<Gray<T>> for GrayAlpha<T, u8>
where T: Copy,

Assumes 255 is opaque

source§

fn from(other: Gray<T>) -> GrayAlpha<T, u8>

Converts to this type from the input type.
source§

impl<T, A> From<GrayAlpha<T, A>> for RGBA<T, A>
where T: Clone,

source§

fn from(other: GrayAlpha<T, A>) -> RGBA<T, A>

Converts to this type from the input type.
source§

impl<ComponentType, AlphaComponentType> Hash for GrayAlpha<ComponentType, AlphaComponentType>
where ComponentType: Hash, AlphaComponentType: 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> Mul<T> for GrayAlpha<T>
where T: Copy + Mul<Output = T>,

px * 1

§

type Output = GrayAlpha<T>

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

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

px * 1

source§

fn mul_assign(&mut self, r: T)

Performs the *= operation. Read more
source§

impl<ComponentType, AlphaComponentType> Ord for GrayAlpha<ComponentType, AlphaComponentType>
where ComponentType: Ord, AlphaComponentType: Ord,

source§

fn cmp(&self, other: &GrayAlpha<ComponentType, AlphaComponentType>) -> 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, AlphaComponentType> PartialEq for GrayAlpha<ComponentType, AlphaComponentType>
where ComponentType: PartialEq, AlphaComponentType: PartialEq,

source§

fn eq(&self, other: &GrayAlpha<ComponentType, AlphaComponentType>) -> 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, AlphaComponentType> PartialOrd for GrayAlpha<ComponentType, AlphaComponentType>
where ComponentType: PartialOrd, AlphaComponentType: PartialOrd,

source§

fn partial_cmp( &self, other: &GrayAlpha<ComponentType, AlphaComponentType> ) -> 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 GrayAlpha<T>
where T: Copy + Sub<Output = T>,

px - 1

§

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

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl<T, A> Sub for GrayAlpha<T, A>
where T: Sub, A: Sub,

px - px

§

type Output = GrayAlpha<<T as Sub>::Output, <A as Sub>::Output>

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl<T> SubAssign<T> for GrayAlpha<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, A> SubAssign for GrayAlpha<T, A>
where T: Sub<Output = T> + Copy, A: Sub<Output = A> + Copy,

px - px

source§

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

Performs the -= operation. Read more
source§

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

source§

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

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

impl<T, A> Zeroable for GrayAlpha<T, A>
where T: Zeroable, A: Zeroable,

§

fn zeroed() -> Self

source§

impl<ComponentType, AlphaComponentType> Copy for GrayAlpha<ComponentType, AlphaComponentType>
where ComponentType: Copy, AlphaComponentType: Copy,

source§

impl<ComponentType, AlphaComponentType> Eq for GrayAlpha<ComponentType, AlphaComponentType>
where ComponentType: Eq, AlphaComponentType: Eq,

source§

impl<T, A> Pod for GrayAlpha<T, A>
where T: Pod, A: Pod,

source§

impl<ComponentType, AlphaComponentType> StructuralEq for GrayAlpha<ComponentType, AlphaComponentType>

source§

impl<ComponentType, AlphaComponentType> StructuralPartialEq for GrayAlpha<ComponentType, AlphaComponentType>

Auto Trait Implementations§

§

impl<ComponentType, AlphaComponentType> RefUnwindSafe for GrayAlpha<ComponentType, AlphaComponentType>
where AlphaComponentType: RefUnwindSafe, ComponentType: RefUnwindSafe,

§

impl<ComponentType, AlphaComponentType> Send for GrayAlpha<ComponentType, AlphaComponentType>
where AlphaComponentType: Send, ComponentType: Send,

§

impl<ComponentType, AlphaComponentType> Sync for GrayAlpha<ComponentType, AlphaComponentType>
where AlphaComponentType: Sync, ComponentType: Sync,

§

impl<ComponentType, AlphaComponentType> Unpin for GrayAlpha<ComponentType, AlphaComponentType>
where AlphaComponentType: Unpin, ComponentType: Unpin,

§

impl<ComponentType, AlphaComponentType> UnwindSafe for GrayAlpha<ComponentType, AlphaComponentType>
where AlphaComponentType: UnwindSafe, 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
§

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

fn is_valid_bit_pattern(_bits: &T) -> bool

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

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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,

§

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

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

§

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