pub struct Image<T: Type, C: Color> {
pub meta: Meta<T, C>,
pub data: Box<dyn ImageData<T>>,
}
Expand description
Image type
Fields§
§meta: Meta<T, C>
Metadata
data: Box<dyn ImageData<T>>
Pixel data
Implementations§
source§impl<T: Type, C: Color> Image<T, C>
impl<T: Type, C: Color> Image<T, C>
sourcepub fn new_with_data(
size: impl Into<Size>,
data: impl 'static + ImageData<T>
) -> Result<Image<T, C>, Error>
pub fn new_with_data( size: impl Into<Size>, data: impl 'static + ImageData<T> ) -> Result<Image<T, C>, Error>
Create a new image with the given size and data, returns Err
if the provided ImageData
isn’t big enough
for the specified dimensions
sourcepub fn new_like_with_type<U: Type>(&self) -> Image<U, C>
pub fn new_like_with_type<U: Type>(&self) -> Image<U, C>
Create a new image with the same size and color as an existing image with the given type
sourcepub fn new_like_with_color<D: Color>(&self) -> Image<T, D>
pub fn new_like_with_color<D: Color>(&self) -> Image<T, D>
Create a new image with the same size and type as an existing image with the given color
sourcepub fn new_like_with_type_and_color<U: Type, D: Color>(&self) -> Image<U, D>
pub fn new_like_with_type_and_color<U: Type, D: Color>(&self) -> Image<U, D>
Create a new image with the same size as an existing image with the given type and color
sourcepub fn new_mmap(
filename: impl AsRef<Path>,
meta: Option<Meta<T, C>>
) -> Result<Image<T, C>, Error>
pub fn new_mmap( filename: impl AsRef<Path>, meta: Option<Meta<T, C>> ) -> Result<Image<T, C>, Error>
New memory mapped image - if meta
is None then it is assumed the image already exists on disk
otherwise it will be created
sourcepub fn mmap(self, filename: impl AsRef<Path>) -> Result<Image<T, C>, Error>
pub fn mmap(self, filename: impl AsRef<Path>) -> Result<Image<T, C>, Error>
Map an existing image to disk, this consumes the original and returns the memory mapped image
sourcepub fn with_color<D: Color>(self) -> Image<T, D>
pub fn with_color<D: Color>(self) -> Image<T, D>
Update the colorspace associated with an image without performing any conversion
sourcepub fn buffer_mut(&mut self) -> &mut [u8] ⓘ
pub fn buffer_mut(&mut self) -> &mut [u8] ⓘ
Get image data as mutable bytes
sourcepub fn get_mut(&mut self, pt: impl Into<Point>) -> DataMut<'_, T, C>
pub fn get_mut(&mut self, pt: impl Into<Point>) -> DataMut<'_, T, C>
Get mutable data at specified index
sourcepub fn set(&mut self, pt: impl Into<Point>, data: impl AsRef<[T]>)
pub fn set(&mut self, pt: impl Into<Point>, data: impl AsRef<[T]>)
Set data to specified location
sourcepub fn in_bounds(&self, pt: impl Into<Point>) -> bool
pub fn in_bounds(&self, pt: impl Into<Point>) -> bool
Returns true when (x, y) is in bounds for the given image
sourcepub fn at(&self, pt: impl Into<Point>, px: impl AsMut<[T]>) -> bool
pub fn at(&self, pt: impl Into<Point>, px: impl AsMut<[T]>) -> bool
Get image data from an image, reusing an existing data buffer big enough for a single pixel
sourcepub fn pixel_at(&self, pt: impl Into<Point>, px: &mut Pixel<C>) -> bool
pub fn pixel_at(&self, pt: impl Into<Point>, px: &mut Pixel<C>) -> bool
Load data from and Image
into an existing Pixel
structure
sourcepub fn set_pixel(&mut self, pt: impl Into<Point>, px: &Pixel<C>)
pub fn set_pixel(&mut self, pt: impl Into<Point>, px: &Pixel<C>)
Set a normalized pixel to the specified location
sourcepub fn rows(&self) -> impl ParallelIterator<Item = (usize, &[T])>
pub fn rows(&self) -> impl ParallelIterator<Item = (usize, &[T])>
Iterate over image rows
sourcepub fn rows_mut(&mut self) -> impl ParallelIterator<Item = (usize, &mut [T])>
pub fn rows_mut(&mut self) -> impl ParallelIterator<Item = (usize, &mut [T])>
Iterate over mutable image rows
sourcepub fn row_range(
&self,
y: usize,
height: usize
) -> impl ParallelIterator<Item = (usize, &[T])>
pub fn row_range( &self, y: usize, height: usize ) -> impl ParallelIterator<Item = (usize, &[T])>
Iterate over image rows
sourcepub fn row_range_mut(
&mut self,
y: usize,
height: usize
) -> impl ParallelIterator<Item = (usize, &mut [T])>
pub fn row_range_mut( &mut self, y: usize, height: usize ) -> impl ParallelIterator<Item = (usize, &mut [T])>
Iterate over mutable image rows
sourcepub fn iter_region_mut(
&mut self,
roi: Region
) -> impl ParallelIterator<Item = (Point, DataMut<'_, T, C>)>
pub fn iter_region_mut( &mut self, roi: Region ) -> impl ParallelIterator<Item = (Point, DataMut<'_, T, C>)>
Iterate over part of an image with mutable data access
sourcepub fn iter_region(
&self,
roi: Region
) -> impl ParallelIterator<Item = (Point, Data<'_, T, C>)>
pub fn iter_region( &self, roi: Region ) -> impl ParallelIterator<Item = (Point, Data<'_, T, C>)>
Iterate over part of an image
sourcepub fn iter(&self) -> impl ParallelIterator<Item = (Point, Data<'_, T, C>)>
pub fn iter(&self) -> impl ParallelIterator<Item = (Point, Data<'_, T, C>)>
Get pixel iterator
sourcepub fn iter_mut(
&mut self
) -> impl ParallelIterator<Item = (Point, DataMut<'_, T, C>)>
pub fn iter_mut( &mut self ) -> impl ParallelIterator<Item = (Point, DataMut<'_, T, C>)>
Get mutable pixel iterator
sourcepub fn for_each<F: Sync + Send + Fn(Point, DataMut<'_, T, C>)>(&mut self, f: F)
pub fn for_each<F: Sync + Send + Fn(Point, DataMut<'_, T, C>)>(&mut self, f: F)
Iterate over each pixel applying f
to every pixel
sourcepub fn for_each_region<F: Sync + Send + Fn(Point, DataMut<'_, T, C>)>(
&mut self,
roi: Region,
f: F
)
pub fn for_each_region<F: Sync + Send + Fn(Point, DataMut<'_, T, C>)>( &mut self, roi: Region, f: F )
Iterate over a region of pixels qpplying f
to every pixel
sourcepub fn for_each2<F: Sync + Send + Fn(Point, DataMut<'_, T, C>, Data<'_, T, C>)>(
&mut self,
other: &Image<T, C>,
f: F
)
pub fn for_each2<F: Sync + Send + Fn(Point, DataMut<'_, T, C>, Data<'_, T, C>)>( &mut self, other: &Image<T, C>, f: F )
Iterate over each pixel of two images at once
sourcepub fn each_pixel<F: Sync + Send + FnMut(Point, &Pixel<C>)>(&self, f: F)
pub fn each_pixel<F: Sync + Send + FnMut(Point, &Pixel<C>)>(&self, f: F)
Iterate over pixels, with a mutable closure
sourcepub fn each_pixel_region<F: Sync + Send + FnMut(Point, &Pixel<C>)>(
&self,
region: Region,
f: F
)
pub fn each_pixel_region<F: Sync + Send + FnMut(Point, &Pixel<C>)>( &self, region: Region, f: F )
Iterate over pixels in region, with a mutable closure
sourcepub fn each_pixel_mut<F: Sync + Send + FnMut(Point, &mut Pixel<C>)>(
&mut self,
f: F
)
pub fn each_pixel_mut<F: Sync + Send + FnMut(Point, &mut Pixel<C>)>( &mut self, f: F )
Iterate over mutable pixels, with a mutable closure
sourcepub fn each_pixel_region_mut<F: Sync + Send + FnMut(Point, &mut Pixel<C>)>(
&mut self,
region: Region,
f: F
)
pub fn each_pixel_region_mut<F: Sync + Send + FnMut(Point, &mut Pixel<C>)>( &mut self, region: Region, f: F )
Iterate over mutable pixels in region, with a mutable closure
sourcepub fn copy_from_region(
&mut self,
offs: impl Into<Point>,
other: &Image<T, C>,
roi: Region
)
pub fn copy_from_region( &mut self, offs: impl Into<Point>, other: &Image<T, C>, roi: Region )
Copy into a region from another image starting at the given offset
sourcepub fn apply<U: Type, D: Color>(
&mut self,
filter: impl Filter<U, D, T, C>,
input: &[&Image<U, D>]
) -> &mut Self
pub fn apply<U: Type, D: Color>( &mut self, filter: impl Filter<U, D, T, C>, input: &[&Image<U, D>] ) -> &mut Self
Apply a filter using an Image as output
sourcepub async fn apply_async<'a, U: Type, D: Color>(
&mut self,
mode: AsyncMode,
filter: impl Filter<U, D, T, C> + Unpin,
input: &[&Image<U, D>]
) -> &mut Self
pub async fn apply_async<'a, U: Type, D: Color>( &mut self, mode: AsyncMode, filter: impl Filter<U, D, T, C> + Unpin, input: &[&Image<U, D>] ) -> &mut Self
Apply an async filter using an Image as output
sourcepub fn run_in_place(&mut self, filter: impl Filter<T, C>) -> &mut Self
pub fn run_in_place(&mut self, filter: impl Filter<T, C>) -> &mut Self
Run a filter using the same Image as input and output
sourcepub fn run<U: Type, D: Color>(
&self,
filter: impl Filter<T, C, U, D>,
output: Option<Meta<U, D>>
) -> Image<U, D>
pub fn run<U: Type, D: Color>( &self, filter: impl Filter<T, C, U, D>, output: Option<Meta<U, D>> ) -> Image<U, D>
Run a filter using an Image as input
sourcepub async fn run_async<'a, U: 'a + Type, D: 'a + Color>(
&self,
mode: AsyncMode,
filter: impl Filter<T, C, U, D> + Unpin,
output: Option<Meta<U, D>>
) -> Image<U, D>
pub async fn run_async<'a, U: 'a + Type, D: 'a + Color>( &self, mode: AsyncMode, filter: impl Filter<T, C, U, D> + Unpin, output: Option<Meta<U, D>> ) -> Image<U, D>
Run an async filter using an Image as input
sourcepub fn convert_to<U: Type, D: Color>(&self, dest: &mut Image<U, D>)
pub fn convert_to<U: Type, D: Color>(&self, dest: &mut Image<U, D>)
Convert image type/color
sourcepub fn set_gamma_log(&mut self)
pub fn set_gamma_log(&mut self)
Convert to log RGB
sourcepub fn set_gamma_lin(&mut self)
pub fn set_gamma_lin(&mut self)
Convert to linear RGB
Trait Implementations§
source§impl<T: Type, C: Color> PartialEq<Image<T, C>> for Image<T, C>
impl<T: Type, C: Color> PartialEq<Image<T, C>> for Image<T, C>
source§impl ToTexture<f32, Rgb> for Image<f32, Rgb>
impl ToTexture<f32, Rgb> for Image<f32, Rgb>
source§fn create_image_texture(&self, gl: &Context) -> Result<ImageTexture<T, C>, Error>
fn create_image_texture(&self, gl: &Context) -> Result<ImageTexture<T, C>, Error>
ImageTexture
source§fn draw_image_texture(
&self,
gl: &Context,
image_texture: &ImageTexture<T, C>,
display_size: Size,
offset: Point
) -> Result<(), Error>
fn draw_image_texture( &self, gl: &Context, image_texture: &ImageTexture<T, C>, display_size: Size, offset: Point ) -> Result<(), Error>
source§impl ToTexture<f32, Rgba> for Image<f32, Rgba>
impl ToTexture<f32, Rgba> for Image<f32, Rgba>
source§fn create_image_texture(&self, gl: &Context) -> Result<ImageTexture<T, C>, Error>
fn create_image_texture(&self, gl: &Context) -> Result<ImageTexture<T, C>, Error>
ImageTexture
source§fn draw_image_texture(
&self,
gl: &Context,
image_texture: &ImageTexture<T, C>,
display_size: Size,
offset: Point
) -> Result<(), Error>
fn draw_image_texture( &self, gl: &Context, image_texture: &ImageTexture<T, C>, display_size: Size, offset: Point ) -> Result<(), Error>
source§impl ToTexture<f32, Srgb> for Image<f32, Srgb>
impl ToTexture<f32, Srgb> for Image<f32, Srgb>
source§fn create_image_texture(&self, gl: &Context) -> Result<ImageTexture<T, C>, Error>
fn create_image_texture(&self, gl: &Context) -> Result<ImageTexture<T, C>, Error>
ImageTexture
source§fn draw_image_texture(
&self,
gl: &Context,
image_texture: &ImageTexture<T, C>,
display_size: Size,
offset: Point
) -> Result<(), Error>
fn draw_image_texture( &self, gl: &Context, image_texture: &ImageTexture<T, C>, display_size: Size, offset: Point ) -> Result<(), Error>
source§impl ToTexture<f32, Srgba> for Image<f32, Srgba>
impl ToTexture<f32, Srgba> for Image<f32, Srgba>
source§fn create_image_texture(&self, gl: &Context) -> Result<ImageTexture<T, C>, Error>
fn create_image_texture(&self, gl: &Context) -> Result<ImageTexture<T, C>, Error>
ImageTexture
source§fn draw_image_texture(
&self,
gl: &Context,
image_texture: &ImageTexture<T, C>,
display_size: Size,
offset: Point
) -> Result<(), Error>
fn draw_image_texture( &self, gl: &Context, image_texture: &ImageTexture<T, C>, display_size: Size, offset: Point ) -> Result<(), Error>
source§impl ToTexture<i16, Rgb> for Image<i16, Rgb>
impl ToTexture<i16, Rgb> for Image<i16, Rgb>
source§fn create_image_texture(&self, gl: &Context) -> Result<ImageTexture<T, C>, Error>
fn create_image_texture(&self, gl: &Context) -> Result<ImageTexture<T, C>, Error>
ImageTexture
source§fn draw_image_texture(
&self,
gl: &Context,
image_texture: &ImageTexture<T, C>,
display_size: Size,
offset: Point
) -> Result<(), Error>
fn draw_image_texture( &self, gl: &Context, image_texture: &ImageTexture<T, C>, display_size: Size, offset: Point ) -> Result<(), Error>
source§impl ToTexture<i16, Rgba> for Image<i16, Rgba>
impl ToTexture<i16, Rgba> for Image<i16, Rgba>
source§fn create_image_texture(&self, gl: &Context) -> Result<ImageTexture<T, C>, Error>
fn create_image_texture(&self, gl: &Context) -> Result<ImageTexture<T, C>, Error>
ImageTexture
source§fn draw_image_texture(
&self,
gl: &Context,
image_texture: &ImageTexture<T, C>,
display_size: Size,
offset: Point
) -> Result<(), Error>
fn draw_image_texture( &self, gl: &Context, image_texture: &ImageTexture<T, C>, display_size: Size, offset: Point ) -> Result<(), Error>
source§impl ToTexture<i16, Srgb> for Image<i16, Srgb>
impl ToTexture<i16, Srgb> for Image<i16, Srgb>
source§fn create_image_texture(&self, gl: &Context) -> Result<ImageTexture<T, C>, Error>
fn create_image_texture(&self, gl: &Context) -> Result<ImageTexture<T, C>, Error>
ImageTexture
source§fn draw_image_texture(
&self,
gl: &Context,
image_texture: &ImageTexture<T, C>,
display_size: Size,
offset: Point
) -> Result<(), Error>
fn draw_image_texture( &self, gl: &Context, image_texture: &ImageTexture<T, C>, display_size: Size, offset: Point ) -> Result<(), Error>
source§impl ToTexture<i16, Srgba> for Image<i16, Srgba>
impl ToTexture<i16, Srgba> for Image<i16, Srgba>
source§fn create_image_texture(&self, gl: &Context) -> Result<ImageTexture<T, C>, Error>
fn create_image_texture(&self, gl: &Context) -> Result<ImageTexture<T, C>, Error>
ImageTexture
source§fn draw_image_texture(
&self,
gl: &Context,
image_texture: &ImageTexture<T, C>,
display_size: Size,
offset: Point
) -> Result<(), Error>
fn draw_image_texture( &self, gl: &Context, image_texture: &ImageTexture<T, C>, display_size: Size, offset: Point ) -> Result<(), Error>
source§impl ToTexture<u16, Rgb> for Image<u16, Rgb>
impl ToTexture<u16, Rgb> for Image<u16, Rgb>
source§fn create_image_texture(&self, gl: &Context) -> Result<ImageTexture<T, C>, Error>
fn create_image_texture(&self, gl: &Context) -> Result<ImageTexture<T, C>, Error>
ImageTexture
source§fn draw_image_texture(
&self,
gl: &Context,
image_texture: &ImageTexture<T, C>,
display_size: Size,
offset: Point
) -> Result<(), Error>
fn draw_image_texture( &self, gl: &Context, image_texture: &ImageTexture<T, C>, display_size: Size, offset: Point ) -> Result<(), Error>
source§impl ToTexture<u16, Rgba> for Image<u16, Rgba>
impl ToTexture<u16, Rgba> for Image<u16, Rgba>
source§fn create_image_texture(&self, gl: &Context) -> Result<ImageTexture<T, C>, Error>
fn create_image_texture(&self, gl: &Context) -> Result<ImageTexture<T, C>, Error>
ImageTexture
source§fn draw_image_texture(
&self,
gl: &Context,
image_texture: &ImageTexture<T, C>,
display_size: Size,
offset: Point
) -> Result<(), Error>
fn draw_image_texture( &self, gl: &Context, image_texture: &ImageTexture<T, C>, display_size: Size, offset: Point ) -> Result<(), Error>
source§impl ToTexture<u16, Srgb> for Image<u16, Srgb>
impl ToTexture<u16, Srgb> for Image<u16, Srgb>
source§fn create_image_texture(&self, gl: &Context) -> Result<ImageTexture<T, C>, Error>
fn create_image_texture(&self, gl: &Context) -> Result<ImageTexture<T, C>, Error>
ImageTexture
source§fn draw_image_texture(
&self,
gl: &Context,
image_texture: &ImageTexture<T, C>,
display_size: Size,
offset: Point
) -> Result<(), Error>
fn draw_image_texture( &self, gl: &Context, image_texture: &ImageTexture<T, C>, display_size: Size, offset: Point ) -> Result<(), Error>
source§impl ToTexture<u16, Srgba> for Image<u16, Srgba>
impl ToTexture<u16, Srgba> for Image<u16, Srgba>
source§fn create_image_texture(&self, gl: &Context) -> Result<ImageTexture<T, C>, Error>
fn create_image_texture(&self, gl: &Context) -> Result<ImageTexture<T, C>, Error>
ImageTexture
source§fn draw_image_texture(
&self,
gl: &Context,
image_texture: &ImageTexture<T, C>,
display_size: Size,
offset: Point
) -> Result<(), Error>
fn draw_image_texture( &self, gl: &Context, image_texture: &ImageTexture<T, C>, display_size: Size, offset: Point ) -> Result<(), Error>
source§impl ToTexture<u8, Rgb> for Image<u8, Rgb>
impl ToTexture<u8, Rgb> for Image<u8, Rgb>
source§fn create_image_texture(&self, gl: &Context) -> Result<ImageTexture<T, C>, Error>
fn create_image_texture(&self, gl: &Context) -> Result<ImageTexture<T, C>, Error>
ImageTexture
source§fn draw_image_texture(
&self,
gl: &Context,
image_texture: &ImageTexture<T, C>,
display_size: Size,
offset: Point
) -> Result<(), Error>
fn draw_image_texture( &self, gl: &Context, image_texture: &ImageTexture<T, C>, display_size: Size, offset: Point ) -> Result<(), Error>
source§impl ToTexture<u8, Rgba> for Image<u8, Rgba>
impl ToTexture<u8, Rgba> for Image<u8, Rgba>
source§fn create_image_texture(&self, gl: &Context) -> Result<ImageTexture<T, C>, Error>
fn create_image_texture(&self, gl: &Context) -> Result<ImageTexture<T, C>, Error>
ImageTexture
source§fn draw_image_texture(
&self,
gl: &Context,
image_texture: &ImageTexture<T, C>,
display_size: Size,
offset: Point
) -> Result<(), Error>
fn draw_image_texture( &self, gl: &Context, image_texture: &ImageTexture<T, C>, display_size: Size, offset: Point ) -> Result<(), Error>
source§impl ToTexture<u8, Srgb> for Image<u8, Srgb>
impl ToTexture<u8, Srgb> for Image<u8, Srgb>
source§fn create_image_texture(&self, gl: &Context) -> Result<ImageTexture<T, C>, Error>
fn create_image_texture(&self, gl: &Context) -> Result<ImageTexture<T, C>, Error>
ImageTexture
source§fn draw_image_texture(
&self,
gl: &Context,
image_texture: &ImageTexture<T, C>,
display_size: Size,
offset: Point
) -> Result<(), Error>
fn draw_image_texture( &self, gl: &Context, image_texture: &ImageTexture<T, C>, display_size: Size, offset: Point ) -> Result<(), Error>
source§impl ToTexture<u8, Srgba> for Image<u8, Srgba>
impl ToTexture<u8, Srgba> for Image<u8, Srgba>
source§fn create_image_texture(&self, gl: &Context) -> Result<ImageTexture<T, C>, Error>
fn create_image_texture(&self, gl: &Context) -> Result<ImageTexture<T, C>, Error>
ImageTexture