Struct Image

Source
pub struct Image<'a>(pub *mut Image, _, _);
Expand description

Image type

Tuple Fields§

§0: *mut Image

Implementations§

Source§

impl<'a> Image<'a>

Source

pub fn as_mut_halide_buffer(&mut self) -> Result<Buffer<'_>, Error>

Use the image as a mutable halide_buffer_t

Source

pub fn as_halide_buffer(&self) -> Result<Buffer<'_>, Error>

Use the image as a halide_buffer_t

NOTE: This buffer should only be used immutably, it is not safe to use the resulting Buffer as an output argument. Use as_mut_halide_buffer if you will be mutating the contents

Source§

impl<'a> Image<'a>

Source

pub fn read_default<P: AsRef<Path>>(path: P) -> Result<Image<'a>, Error>

Read default colorspace/type from disk using ezimage

Source

pub fn read<P: AsRef<Path>>( path: P, color: Color, t: Type, ) -> Result<Image<'a>, Error>

Read from disk using ezimage

Source

pub fn write<P: AsRef<Path>>(&self, path: P) -> Result<(), Error>

Write image to disk using ezimage

Source

pub fn new(meta: Meta) -> Result<Self, Error>

Allocate a new image

Source

pub fn new_with_data<T, X: AsMut<[T]>>( meta: Meta, data: X, ) -> Result<Self, Error>

Wrap existing data

Source

pub fn new_like_with_color(&self, color: Color) -> Result<Self, Error>

Create a new image similar to an existing image with the color changed

Source

pub fn new_like_with_type(&self, t: Type) -> Result<Self, Error>

Create a new image similar to an existing image with the type changed

Source

pub fn meta(&self) -> &Meta

Get metadata

Source

pub fn shape(&self) -> (usize, usize, usize)

Get image (width, height, channels)

Source

pub fn get_type(&self) -> Type

Source

pub fn get_color(&self) -> Color

Source

pub fn elem_size(&self) -> usize

Size of each channel in the underlying data

Source

pub fn data_ptr(&self) -> *mut c_void

Get a pointer to the underlying data

Source

pub fn data<T>(&self) -> Result<&[T], Error>

Get the underlying data as a slice

Source

pub fn buffer(&self) -> Result<&[u8], Error>

Get the underlying data as a byte slice

Source

pub fn data_mut<T>(&mut self) -> Result<&mut [T], Error>

Get the underlying data as a mutable slice

Source

pub fn buffer_mut(&mut self) -> Result<&mut [u8], Error>

Get the underlying data as a mutable byte slice

Source

pub fn is_type<T>(&self) -> bool

Determines if the image matches the type parameter T

Source

pub fn at<T>(&mut self, x: usize, y: usize) -> Result<&mut [T], Error>

Get a mutable reference to the data at position (x, y)

Source

pub fn get_pixel(&self, x: usize, y: usize, px: &mut Pixel) -> bool

Get the pixel at (x, y)

Source

pub fn set_pixel(&self, x: usize, y: usize, px: &Pixel) -> bool

Set the pixel at (x, y)

Source

pub fn for_each<T, F: FnMut((usize, usize), &mut [T])>( &mut self, f: F, ) -> Result<(), Error>

Iterate over each pixel and apply f

Source

pub fn for_each2<T, F: FnMut((usize, usize), &mut [T], &[T])>( &mut self, other: &Image<'_>, f: F, ) -> Result<(), Error>

Iterate over each pixel in two images of the same size and apply f

Source

pub fn convert_in_place(&mut self, color: Color, t: Type) -> Result<(), Error>

Convert an image colorspace in-place, overwriting the source image

Source

pub fn convert_to(&self, dest: &mut Image<'_>) -> Result<(), Error>

Convert an image colorspace based on the destination image type, allocating a new image

Source

pub fn convert(&self, color: Color, t: Type) -> Result<Image<'_>, Error>

Convert an image colorspace, allocating a new image

Source

pub fn adjust_gamma(&self, g: f32) -> Result<(), Error>

Gamma correctoin

Source

pub fn convert_aces0(&self) -> Result<Image<'_>, Error>

Source

pub fn convert_aces1(&self) -> Result<Image<'_>, Error>

Source

pub fn convert_aces0_to_xyz(&self) -> Result<Image<'_>, Error>

Source

pub fn convert_aces1_to_xyz(&self) -> Result<Image<'_>, Error>

Source

pub fn scale(&self, x: f64, y: f64) -> Result<Image<'_>, Error>

Scale an image using the given factor for each dimension

Source

pub fn resize_to(&self, dest: &mut Image<'_>) -> Result<(), Error>

Resize an image to match the destination image size

Source

pub fn resize(&self, width: usize, height: usize) -> Result<Image<'_>, Error>

Resize an image to the given size

Source

pub fn clone<'b>(&self) -> Image<'b>

Copy an image

Source

pub fn each_pixel<F: FnMut(usize, usize, &mut Pixel) -> Result<bool, Error>>( &mut self, nthreads: Option<usize>, f: F, ) -> Result<(), Error>

Iterate over each pixel in parallel rows

Trait Implementations§

Source§

impl<'a> Drop for Image<'a>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'a> Send for Image<'a>

Source§

impl<'a> Sync for Image<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Image<'a>

§

impl<'a> RefUnwindSafe for Image<'a>

§

impl<'a> Unpin for Image<'a>

§

impl<'a> UnwindSafe for Image<'a>

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