Struct image2::Pixel

source ·
pub struct Pixel<C: Color>(_, _);
Expand description

Normalized image data

Implementations§

source§

impl<C: Color> Pixel<C>

source

pub fn new() -> Pixel<C>

Create an empty pixel

source

pub fn with_color<D: Color>(self) -> Pixel<D>

Update the colorspace associated with a pixel without performing any conversion

source

pub fn data(&self) -> Data<'_, f64, C>

Data

source

pub fn data_mut(&mut self) -> DataMut<'_, f64, C>

Mutable Data

source

pub fn into_vec(self) -> Vec<f64>

Convert into a Vec

source

pub fn to_vec(&self) -> Vec<f64>

Copy and convert to a Vec

source

pub fn fill<T: Type>(&mut self, x: T) -> &mut Self

Fill a pixel with a single value

source

pub fn len(&self) -> Channel

Pixel channel count

source

pub fn is_empty(&self) -> bool

Pixel has no channels

source

pub fn clamp(&mut self) -> &mut Self

Clamp values betwen 0 and 1.0

source

pub fn clamped(self) -> Self

Returns self after calling clamp

source

pub fn is_alpha(&self, index: Channel) -> bool

Returns true when the provided channel index matches the alpha channel index

source

pub fn alpha(&self) -> Option<f64>

Get alpha value

source

pub fn with_alpha(&mut self, value: f64) -> &mut Self

Set alpha value

source

pub fn convert_to<D: Color>(&self, dest: &mut Pixel<D>)

Convert pixel color type to an existing pixel

source

pub fn convert<D: Color>(&self) -> Pixel<D>

Convert pixel color type

source

pub fn copy_from_slice<T: Type>(&mut self, data: impl AsRef<[T]>) -> &mut Self

Copy values from an existing slice

source

pub fn copy_from_data<T: Type>(&mut self, data: &Data<'_, T, C>) -> &mut Self

Copy values from an existing slice

source

pub fn convert_from_data<T: Type, D: Color>(&mut self, data: &Data<'_, T, D>)

Convert color and copy to slice

source

pub fn convert_to_data<T: Type, D: Color>(&self, data: &mut DataMut<'_, T, D>)

Convert color and copy to slice

source

pub fn copy_to_slice<T: Type>(&self, data: impl AsMut<[T]>)

Copy values to an existing slice

source

pub fn from_slice<T: Type>(data: impl AsRef<[T]>) -> Pixel<C>

Create from slice

source

pub fn from_data<T: Type>(data: &Data<'_, T, C>) -> Pixel<C>

Create from slice

source

pub fn copy_from(&mut self, other: &Pixel<C>) -> &mut Self

Create from another pixel

source

pub fn blend_alpha(&mut self) -> &mut Self

Blend alpha value

source

pub fn map(&mut self, f: impl Fn(f64) -> f64) -> &mut Self

Create a new pixel by applying f over an existing pixel

source

pub fn map2(&mut self, other: &Pixel<C>, f: impl Fn(f64, f64) -> f64) -> &mut Self

Zip two pixels, apply f and return a new pixel with the results

source

pub fn for_each(&self, f: impl FnMut(usize, f64))

Apply f for each channel in a pixel

source

pub fn iter(&self) -> impl Iterator<Item = &f64>

Get iterator over pixel data, ignoring alpha channel

source

pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut f64>

Get a mutable iterator over the pixel data, ignoring alpha channel

source

pub fn gamma(&mut self, value: f64) -> &mut Self

Gamma correction

source

pub fn gamma_log(&mut self) -> &mut Self

Convert to log RGB

source

pub fn gamma_lin(&mut self) -> &mut Self

Convert to linear RGB

Trait Implementations§

source§

impl<'a, C: Color> Add<&'a Pixel<C>> for &'a Pixel<C>

§

type Output = Pixel<C>

The resulting type after applying the + operator.
source§

fn add(self, other: &'a Pixel<C>) -> Pixel<C>

Performs the + operation. Read more
source§

impl<'a, C: Color> Add<&'a Pixel<C>> for Pixel<C>

§

type Output = Pixel<C>

The resulting type after applying the + operator.
source§

fn add(self, other: &'a Pixel<C>) -> Pixel<C>

Performs the + operation. Read more
source§

impl<'a, C: Color> Add<&'a Pixel<C>> for f64

§

type Output = Pixel<C>

The resulting type after applying the + operator.
source§

fn add(self, px: &'a Pixel<C>) -> Pixel<C>

Performs the + operation. Read more
source§

impl<C: Color> Add<Pixel<C>> for Pixel<C>

§

type Output = Pixel<C>

The resulting type after applying the + operator.
source§

fn add(self, other: Pixel<C>) -> Pixel<C>

Performs the + operation. Read more
source§

impl<C: Color> Add<Pixel<C>> for f64

§

type Output = Pixel<C>

The resulting type after applying the + operator.
source§

fn add(self, px: Pixel<C>) -> Pixel<C>

Performs the + operation. Read more
source§

impl<'a, T: Type, C: Color> Add<T> for &'a Pixel<C>

§

type Output = Pixel<C>

The resulting type after applying the + operator.
source§

fn add(self, other: T) -> Pixel<C>

Performs the + operation. Read more
source§

impl<T: Type, C: Color> Add<T> for Pixel<C>

§

type Output = Pixel<C>

The resulting type after applying the + operator.
source§

fn add(self, other: T) -> Pixel<C>

Performs the + operation. Read more
source§

impl<'a, C: Color> AddAssign<&'a Pixel<C>> for Pixel<C>

source§

fn add_assign(&mut self, other: &'a Pixel<C>)

Performs the += operation. Read more
source§

impl<C: Color> AddAssign<Pixel<C>> for Pixel<C>

source§

fn add_assign(&mut self, other: Pixel<C>)

Performs the += operation. Read more
source§

impl<T: Type, C: Color> AddAssign<T> for Pixel<C>

source§

fn add_assign(&mut self, other: T)

Performs the += operation. Read more
source§

impl<C: Color> AsMut<[f64]> for Pixel<C>

source§

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

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

impl<C: Color> AsRef<[f64]> for Pixel<C>

source§

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

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

impl<C: Clone + Color> Clone for Pixel<C>

source§

fn clone(&self) -> Pixel<C>

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<C: Debug + Color> Debug for Pixel<C>

source§

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

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

impl<C: Color> Default for Pixel<C>

source§

fn default() -> Self

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

impl<'de, C: Color> Deserialize<'de> for Pixel<C>

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<'a, C: Color> Div<&'a Pixel<C>> for &'a Pixel<C>

§

type Output = Pixel<C>

The resulting type after applying the / operator.
source§

fn div(self, other: &'a Pixel<C>) -> Pixel<C>

Performs the / operation. Read more
source§

impl<'a, C: Color> Div<&'a Pixel<C>> for Pixel<C>

§

type Output = Pixel<C>

The resulting type after applying the / operator.
source§

fn div(self, other: &'a Pixel<C>) -> Pixel<C>

Performs the / operation. Read more
source§

impl<'a, C: Color> Div<&'a Pixel<C>> for f64

§

type Output = Pixel<C>

The resulting type after applying the / operator.
source§

fn div(self, px: &'a Pixel<C>) -> Pixel<C>

Performs the / operation. Read more
source§

impl<C: Color> Div<Pixel<C>> for Pixel<C>

§

type Output = Pixel<C>

The resulting type after applying the / operator.
source§

fn div(self, other: Pixel<C>) -> Pixel<C>

Performs the / operation. Read more
source§

impl<C: Color> Div<Pixel<C>> for f64

§

type Output = Pixel<C>

The resulting type after applying the / operator.
source§

fn div(self, px: Pixel<C>) -> Pixel<C>

Performs the / operation. Read more
source§

impl<'a, T: Type, C: Color> Div<T> for &'a Pixel<C>

§

type Output = Pixel<C>

The resulting type after applying the / operator.
source§

fn div(self, other: T) -> Pixel<C>

Performs the / operation. Read more
source§

impl<T: Type, C: Color> Div<T> for Pixel<C>

§

type Output = Pixel<C>

The resulting type after applying the / operator.
source§

fn div(self, other: T) -> Pixel<C>

Performs the / operation. Read more
source§

impl<'a, C: Color> DivAssign<&'a Pixel<C>> for Pixel<C>

source§

fn div_assign(&mut self, other: &'a Pixel<C>)

Performs the /= operation. Read more
source§

impl<C: Color> DivAssign<Pixel<C>> for Pixel<C>

source§

fn div_assign(&mut self, other: Pixel<C>)

Performs the /= operation. Read more
source§

impl<T: Type, C: Color> DivAssign<T> for Pixel<C>

source§

fn div_assign(&mut self, other: T)

Performs the /= operation. Read more
source§

impl<C: Color> From<&[f64]> for Pixel<C>

source§

fn from(data: &[f64]) -> Self

Converts to this type from the input type.
source§

impl<C: Color> From<Vec<f64, Global>> for Pixel<C>

source§

fn from(data: Vec<f64>) -> Self

Converts to this type from the input type.
source§

impl<T: Type, C: Color> FromIterator<T> for Pixel<C>

source§

fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self

Creates a value from an iterator. Read more
source§

impl<'a, C: Color> Index<usize> for &'a Pixel<C>

§

type Output = f64

The returned type after indexing.
source§

fn index(&self, index: Channel) -> &f64

Performs the indexing (container[index]) operation. Read more
source§

impl<'a, C: Color> Index<usize> for &'a mut Pixel<C>

§

type Output = f64

The returned type after indexing.
source§

fn index(&self, index: Channel) -> &f64

Performs the indexing (container[index]) operation. Read more
source§

impl<C: Color> Index<usize> for Pixel<C>

§

type Output = f64

The returned type after indexing.
source§

fn index(&self, index: Channel) -> &f64

Performs the indexing (container[index]) operation. Read more
source§

impl<'a, C: Color> IndexMut<usize> for &'a mut Pixel<C>

source§

fn index_mut(&mut self, index: Channel) -> &mut f64

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<C: Color> IndexMut<usize> for Pixel<C>

source§

fn index_mut(&mut self, index: Channel) -> &mut f64

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<C: Color> IntoIterator for Pixel<C>

§

type Item = f64

The type of the elements being iterated over.
§

type IntoIter = IntoIter<<Pixel<C> as IntoIterator>::Item, Global>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<'a, C: Color> Mul<&'a Pixel<C>> for &'a Pixel<C>

§

type Output = Pixel<C>

The resulting type after applying the * operator.
source§

fn mul(self, other: &'a Pixel<C>) -> Pixel<C>

Performs the * operation. Read more
source§

impl<'a, C: Color> Mul<&'a Pixel<C>> for Pixel<C>

§

type Output = Pixel<C>

The resulting type after applying the * operator.
source§

fn mul(self, other: &'a Pixel<C>) -> Pixel<C>

Performs the * operation. Read more
source§

impl<'a, C: Color> Mul<&'a Pixel<C>> for f64

§

type Output = Pixel<C>

The resulting type after applying the * operator.
source§

fn mul(self, px: &'a Pixel<C>) -> Pixel<C>

Performs the * operation. Read more
source§

impl<C: Color> Mul<Pixel<C>> for Pixel<C>

§

type Output = Pixel<C>

The resulting type after applying the * operator.
source§

fn mul(self, other: Pixel<C>) -> Pixel<C>

Performs the * operation. Read more
source§

impl<C: Color> Mul<Pixel<C>> for f64

§

type Output = Pixel<C>

The resulting type after applying the * operator.
source§

fn mul(self, px: Pixel<C>) -> Pixel<C>

Performs the * operation. Read more
source§

impl<'a, T: Type, C: Color> Mul<T> for &'a Pixel<C>

§

type Output = Pixel<C>

The resulting type after applying the * operator.
source§

fn mul(self, other: T) -> Pixel<C>

Performs the * operation. Read more
source§

impl<T: Type, C: Color> Mul<T> for Pixel<C>

§

type Output = Pixel<C>

The resulting type after applying the * operator.
source§

fn mul(self, other: T) -> Pixel<C>

Performs the * operation. Read more
source§

impl<'a, C: Color> MulAssign<&'a Pixel<C>> for Pixel<C>

source§

fn mul_assign(&mut self, other: &'a Pixel<C>)

Performs the *= operation. Read more
source§

impl<C: Color> MulAssign<Pixel<C>> for Pixel<C>

source§

fn mul_assign(&mut self, other: Pixel<C>)

Performs the *= operation. Read more
source§

impl<T: Type, C: Color> MulAssign<T> for Pixel<C>

source§

fn mul_assign(&mut self, other: T)

Performs the *= operation. Read more
source§

impl<C: PartialEq + Color> PartialEq<Pixel<C>> for Pixel<C>

source§

fn eq(&self, other: &Pixel<C>) -> 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<C: PartialOrd + Color> PartialOrd<Pixel<C>> for Pixel<C>

source§

fn partial_cmp(&self, other: &Pixel<C>) -> 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<'a, C: Color> Rem<&'a Pixel<C>> for &'a Pixel<C>

§

type Output = Pixel<C>

The resulting type after applying the % operator.
source§

fn rem(self, other: &'a Pixel<C>) -> Pixel<C>

Performs the % operation. Read more
source§

impl<'a, C: Color> Rem<&'a Pixel<C>> for Pixel<C>

§

type Output = Pixel<C>

The resulting type after applying the % operator.
source§

fn rem(self, other: &'a Pixel<C>) -> Pixel<C>

Performs the % operation. Read more
source§

impl<'a, C: Color> Rem<&'a Pixel<C>> for f64

§

type Output = Pixel<C>

The resulting type after applying the % operator.
source§

fn rem(self, px: &'a Pixel<C>) -> Pixel<C>

Performs the % operation. Read more
source§

impl<C: Color> Rem<Pixel<C>> for Pixel<C>

§

type Output = Pixel<C>

The resulting type after applying the % operator.
source§

fn rem(self, other: Pixel<C>) -> Pixel<C>

Performs the % operation. Read more
source§

impl<C: Color> Rem<Pixel<C>> for f64

§

type Output = Pixel<C>

The resulting type after applying the % operator.
source§

fn rem(self, px: Pixel<C>) -> Pixel<C>

Performs the % operation. Read more
source§

impl<'a, T: Type, C: Color> Rem<T> for &'a Pixel<C>

§

type Output = Pixel<C>

The resulting type after applying the % operator.
source§

fn rem(self, other: T) -> Pixel<C>

Performs the % operation. Read more
source§

impl<T: Type, C: Color> Rem<T> for Pixel<C>

§

type Output = Pixel<C>

The resulting type after applying the % operator.
source§

fn rem(self, other: T) -> Pixel<C>

Performs the % operation. Read more
source§

impl<'a, C: Color> RemAssign<&'a Pixel<C>> for Pixel<C>

source§

fn rem_assign(&mut self, other: &'a Pixel<C>)

Performs the %= operation. Read more
source§

impl<C: Color> RemAssign<Pixel<C>> for Pixel<C>

source§

fn rem_assign(&mut self, other: Pixel<C>)

Performs the %= operation. Read more
source§

impl<T: Type, C: Color> RemAssign<T> for Pixel<C>

source§

fn rem_assign(&mut self, other: T)

Performs the %= operation. Read more
source§

impl<C: Color> Serialize for Pixel<C>

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<'a, C: Color> Sub<&'a Pixel<C>> for &'a Pixel<C>

§

type Output = Pixel<C>

The resulting type after applying the - operator.
source§

fn sub(self, other: &'a Pixel<C>) -> Pixel<C>

Performs the - operation. Read more
source§

impl<'a, C: Color> Sub<&'a Pixel<C>> for Pixel<C>

§

type Output = Pixel<C>

The resulting type after applying the - operator.
source§

fn sub(self, other: &'a Pixel<C>) -> Pixel<C>

Performs the - operation. Read more
source§

impl<'a, C: Color> Sub<&'a Pixel<C>> for f64

§

type Output = Pixel<C>

The resulting type after applying the - operator.
source§

fn sub(self, px: &'a Pixel<C>) -> Pixel<C>

Performs the - operation. Read more
source§

impl<C: Color> Sub<Pixel<C>> for Pixel<C>

§

type Output = Pixel<C>

The resulting type after applying the - operator.
source§

fn sub(self, other: Pixel<C>) -> Pixel<C>

Performs the - operation. Read more
source§

impl<C: Color> Sub<Pixel<C>> for f64

§

type Output = Pixel<C>

The resulting type after applying the - operator.
source§

fn sub(self, px: Pixel<C>) -> Pixel<C>

Performs the - operation. Read more
source§

impl<'a, T: Type, C: Color> Sub<T> for &'a Pixel<C>

§

type Output = Pixel<C>

The resulting type after applying the - operator.
source§

fn sub(self, other: T) -> Pixel<C>

Performs the - operation. Read more
source§

impl<T: Type, C: Color> Sub<T> for Pixel<C>

§

type Output = Pixel<C>

The resulting type after applying the - operator.
source§

fn sub(self, other: T) -> Pixel<C>

Performs the - operation. Read more
source§

impl<'a, C: Color> SubAssign<&'a Pixel<C>> for Pixel<C>

source§

fn sub_assign(&mut self, other: &'a Pixel<C>)

Performs the -= operation. Read more
source§

impl<C: Color> SubAssign<Pixel<C>> for Pixel<C>

source§

fn sub_assign(&mut self, other: Pixel<C>)

Performs the -= operation. Read more
source§

impl<T: Type, C: Color> SubAssign<T> for Pixel<C>

source§

fn sub_assign(&mut self, other: T)

Performs the -= operation. Read more
source§

impl<C: Color> StructuralPartialEq for Pixel<C>

Auto Trait Implementations§

§

impl<C> RefUnwindSafe for Pixel<C>where C: RefUnwindSafe,

§

impl<C> Send for Pixel<C>

§

impl<C> Sync for Pixel<C>

§

impl<C> Unpin for Pixel<C>

§

impl<C> UnwindSafe for Pixel<C>where C: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for Twhere 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,

source§

impl<T, Rhs> NumAssignOps<Rhs> for Twhere T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,

source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for Twhere T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,

source§

impl<T, Base> RefNum<Base> for Twhere T: NumOps<Base, Base> + for<'r> NumOps<&'r Base, Base>,