Struct Image

Source
pub struct Image { /* private fields */ }

Implementations§

Source§

impl Image

Source

pub fn new(shape: Shape, colorspace: ColorSpace) -> Self

Source

pub fn from_data(data: Vec<u8>, shape: Shape, colorspace: ColorSpace) -> Self

Source

pub fn swap(&mut self, idx_a: usize, idx_b: usize)

Source

pub fn slice(&self, start: usize, end: usize) -> &[u8]

Source

pub fn mut_slice(&mut self, start: usize, end: usize) -> &mut [u8]

Source

pub fn width(&self) -> usize

Source

pub fn height(&self) -> usize

Source

pub fn size(&self) -> usize

Source

pub fn crop(&self, topleft: Point, shape: Shape) -> Self

Source

pub fn get_index(&self, point: &Point) -> Result<usize, Error>

Calculates the 1D Index based on the provided (x, y) Just wraps get_index_from_xy for sake of convenience

§Arguments
  • Point - Point containing desired x and y
§Returns
  • usize containing Index if within bounds, otherwise Error
Source

pub fn get_index_from_xy(&self, x: usize, y: usize) -> Result<usize, Error>

Compute 1D Index (row-major) when provided with the x, y coordinate, width and channel value.

§Arguments
  • x - The x coordinate (should be between 0 - width of Image)
  • y - The y coordinate (should be between 0 - height of Image)
§Returns
  • usize containing Index if within bounds, otherwise Error
Source

pub fn get_pixel(&self, point: &Point) -> &[u8]

Return a slize of 1 pixel (including all channels)

§Arguments
  • x - The x coordinate
  • y - The y coordinate
§Returns
  • An immutable &u8
Source

pub fn get_mut_pixel(&mut self, point: &Point) -> &mut [u8]

Same as get_pixel but just a mutable reference

Source

pub fn set_pixel(&mut self, point: &Point, color: &Color) -> Result<(), Error>

Trait Implementations§

Source§

impl Clone for Image

Source§

fn clone(&self) -> Image

Returns a duplicate 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 Debug for Image

Source§

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

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

impl Drawable<CircleParams> for Image

Source§

fn draw(&mut self, params: &CircleParams) -> Result<(), Error>

Draw a circle on the Image using the Midpoint Circle Algorithm.

Source§

impl Drawable<RectParams> for Image

Source§

fn draw(&mut self, params: &RectParams) -> Result<(), Error>

Draw a rectangle on the Image

Source§

impl Encoder for Image

Source§

fn encode(&self, codec: Codex) -> Result<Vec<u8>, Error>

Source§

impl Index<(usize, usize)> for Image

Overriding [] for 2D indexing.

§Returns an immutable reference to a given pixel

Source§

type Output = [u8]

The returned type after indexing.
Source§

fn index(&self, (x, y): Index2D) -> &Self::Output

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

impl Index<(usize, usize, usize)> for Image

Overriding [] for 3D indexing. This is useful when you want to modify a specific channel For example, to modify green channel, image[(2, 2, 1)] = 255 Where 1 = the channel number.

See ColorSpace for more information on Channel Numbers

Source§

type Output = u8

The returned type after indexing.
Source§

fn index(&self, (x, y, c): Index3D) -> &Self::Output

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

impl Index<usize> for Image

Overriding [] for 1D indexing.

§Returns an immutable reference to the requested Index

Source§

type Output = u8

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

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

impl IndexMut<(usize, usize)> for Image

Source§

fn index_mut(&mut self, (x, y): Index2D) -> &mut Self::Output

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

impl IndexMut<(usize, usize, usize)> for Image

Source§

fn index_mut(&mut self, (x, y, c): Index3D) -> &mut Self::Output

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

impl IndexMut<usize> for Image

Overriding [] for 1D indexing.

§Returns a mutable reference to the requested Index

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

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

impl Reader for Image

Source§

fn read(path: &str, codex: Codex) -> Result<Image, Error>

Source§

impl Resizable<BiCubicParams> for Image

Source§

fn resize(&mut self, shape: Shape) -> Result<(), Error>

Source§

impl Resizable<BiLinearParams> for Image

Source§

fn resize(&mut self, shape: Shape) -> Result<(), Error>

Source§

impl Resizable<NearestNeighborParams> for Image

Source§

fn resize(&mut self, shape: Shape) -> Result<(), Error>

Source§

impl Rotatable<RotationType> for Image

Source§

fn rotate(&mut self, value: RotationType) -> Result<(), Error>

Perform in-place rotation.

Source§

impl Rotatable<i32> for Image

Source§

fn rotate(&mut self, value: i32) -> Result<(), Error>

Source§

impl Writer for Image

Source§

fn write(&self, path: String, codec: Codex) -> Result<(), Error>

Auto Trait Implementations§

§

impl Freeze for Image

§

impl RefUnwindSafe for Image

§

impl Send for Image

§

impl Sync for Image

§

impl Unpin for Image

§

impl UnwindSafe for Image

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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, 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.