pub struct Image<P: Pixel, U: GenericImage<Pixel = P>> { /* private fields */ }
Expand description
Represents an image that can be passed to the merger. This is a wrapper around an image crate’s GenericImage and adds some additional functionality for the merger.
§Type Parameters
P
- The pixel type of the underlying image.U
- The underlying image type.
§Example
use image_merger::{Image, Rgba};
use image::ImageBuffer;
let image: Image<Rgba<u8>, ImageBuffer<Rgba<u8>, Vec<u8>>> = Image::new(100, 100);
assert_eq!(image.capacity(), 100 * 100 * 4);
Note that this is for example, in practicality, you should use the BufferedImage type alias.
Implementations§
Source§impl<P: Pixel, U: GenericImage<Pixel = P>> Image<P, U>
impl<P: Pixel, U: GenericImage<Pixel = P>> Image<P, U>
Sourcepub fn into_buffer(self) -> U
pub fn into_buffer(self) -> U
Consumes the image and returns the underlying image buffer.
Source§impl<P, Container> Image<P, ImageBuffer<P, Container>>
impl<P, Container> Image<P, ImageBuffer<P, Container>>
Sourcepub fn new_from_raw(
width: u32,
height: u32,
container: Container,
) -> Option<Self>
pub fn new_from_raw( width: u32, height: u32, container: Container, ) -> Option<Self>
Creates a new image from a raw buffer. The buffer must be large enough to fit the image. Normally, you should use the
new
method to create a new image, as it is more idiomatic, unless you need to manually create an image from a raw buffer.
§Arguments
width
- The width of the image.height
- The height of the image.container
- The raw buffer to create the image from.
§Returns
An Image with the given pixel and buffer type. Will return None if the buffer is not large enough to fit the image.
Trait Implementations§
Source§impl<P: Pixel, U: GenericImage<Pixel = P>> Deref for Image<P, U>
Dereferences to the underlying image.
impl<P: Pixel, U: GenericImage<Pixel = P>> Deref for Image<P, U>
Dereferences to the underlying image.
Source§impl<P, Container> From<ImageBuffer<P, Container>> for Image<P, ImageBuffer<P, Container>>
A trait that allows the creation of an Image from a preexisting image::ImageBuffer.
impl<P, Container> From<ImageBuffer<P, Container>> for Image<P, ImageBuffer<P, Container>>
A trait that allows the creation of an Image from a preexisting image::ImageBuffer.
§Type Parameters
P
- The pixel type of the underlying image.Container
- The underlying image buffer type. This must be dereferenceable to a slice of the underlying image’s subpixels.
§Example
use image_merger::{Image, Rgba, BufferedImage};
use image::ImageBuffer;
let buf: ImageBuffer<Rgba<u8>, Vec<u8>> = ImageBuffer::new(100, 100);
let image: BufferedImage<Rgba<u8>> = BufferedImage::from(buf);
Source§fn from(image: ImageBuffer<P, Container>) -> Self
fn from(image: ImageBuffer<P, Container>) -> Self
Creates a new Image from a preexisting ImageBuffer.
§Arguments
image
- The ImageBuffer to create an Image from.
Source§impl<Container> FromWithFormat<Container> for Image<Luma<u16>, ImageBuffer<Luma<u16>, Vec<u16>>>
Implementation of FromWithFormat
for an Image
with a pixel type of Luma
, holding a subpixel type of u16
and an underlying ImageBuffer
buffer that holds Vec<u16>
’s.
impl<Container> FromWithFormat<Container> for Image<Luma<u16>, ImageBuffer<Luma<u16>, Vec<u16>>>
Implementation of FromWithFormat
for an Image
with a pixel type of Luma
, holding a subpixel type of u16
and an underlying ImageBuffer
buffer that holds Vec<u16>
’s.
Source§fn from_with_format(container: Container, format: ImageFormat) -> Self
fn from_with_format(container: Container, format: ImageFormat) -> Self
Source§impl<Container> FromWithFormat<Container> for Image<Luma<u8>, ImageBuffer<Luma<u8>, Vec<u8>>>
Implementation of FromWithFormat
for an Image
with a pixel type of Luma
, holding a subpixel type of u8
and an underlying ImageBuffer
buffer that holds Vec<u8>
’s.
impl<Container> FromWithFormat<Container> for Image<Luma<u8>, ImageBuffer<Luma<u8>, Vec<u8>>>
Implementation of FromWithFormat
for an Image
with a pixel type of Luma
, holding a subpixel type of u8
and an underlying ImageBuffer
buffer that holds Vec<u8>
’s.
Source§fn from_with_format(container: Container, format: ImageFormat) -> Self
fn from_with_format(container: Container, format: ImageFormat) -> Self
Source§impl<Container> FromWithFormat<Container> for Image<LumaA<u16>, ImageBuffer<LumaA<u16>, Vec<u16>>>
Implementation of FromWithFormat
for an Image
with a pixel type of LumaA
, holding a subpixel type of u16
and an underlying ImageBuffer
buffer that holds Vec<u16>
’s.
impl<Container> FromWithFormat<Container> for Image<LumaA<u16>, ImageBuffer<LumaA<u16>, Vec<u16>>>
Implementation of FromWithFormat
for an Image
with a pixel type of LumaA
, holding a subpixel type of u16
and an underlying ImageBuffer
buffer that holds Vec<u16>
’s.
Source§fn from_with_format(container: Container, format: ImageFormat) -> Self
fn from_with_format(container: Container, format: ImageFormat) -> Self
Source§impl<Container> FromWithFormat<Container> for Image<LumaA<u8>, ImageBuffer<LumaA<u8>, Vec<u8>>>
Implementation of FromWithFormat
for an Image
with a pixel type of LumaA
, holding a subpixel type of u8
and an underlying ImageBuffer
buffer that holds Vec<u8>
’s.
impl<Container> FromWithFormat<Container> for Image<LumaA<u8>, ImageBuffer<LumaA<u8>, Vec<u8>>>
Implementation of FromWithFormat
for an Image
with a pixel type of LumaA
, holding a subpixel type of u8
and an underlying ImageBuffer
buffer that holds Vec<u8>
’s.
Source§fn from_with_format(container: Container, format: ImageFormat) -> Self
fn from_with_format(container: Container, format: ImageFormat) -> Self
Source§impl<Container> FromWithFormat<Container> for Image<Rgb<f32>, ImageBuffer<Rgb<f32>, Vec<f32>>>
Implementation of FromWithFormat
for an Image
with a pixel type of Rgb
, holding a subpixel type of f32
and an underlying ImageBuffer
buffer that holds Vec<f32>
’s.
impl<Container> FromWithFormat<Container> for Image<Rgb<f32>, ImageBuffer<Rgb<f32>, Vec<f32>>>
Implementation of FromWithFormat
for an Image
with a pixel type of Rgb
, holding a subpixel type of f32
and an underlying ImageBuffer
buffer that holds Vec<f32>
’s.
Source§fn from_with_format(container: Container, format: ImageFormat) -> Self
fn from_with_format(container: Container, format: ImageFormat) -> Self
Source§impl<Container> FromWithFormat<Container> for Image<Rgb<u16>, ImageBuffer<Rgb<u16>, Vec<u16>>>
Implementation of FromWithFormat
for an Image
with a pixel type of Rgb
, holding a subpixel type of u16
and an underlying ImageBuffer
buffer that holds Vec<u16>
’s.
impl<Container> FromWithFormat<Container> for Image<Rgb<u16>, ImageBuffer<Rgb<u16>, Vec<u16>>>
Implementation of FromWithFormat
for an Image
with a pixel type of Rgb
, holding a subpixel type of u16
and an underlying ImageBuffer
buffer that holds Vec<u16>
’s.
Source§fn from_with_format(container: Container, format: ImageFormat) -> Self
fn from_with_format(container: Container, format: ImageFormat) -> Self
Source§impl<Container> FromWithFormat<Container> for Image<Rgb<u8>, ImageBuffer<Rgb<u8>, Vec<u8>>>
Implementation of FromWithFormat
for an Image
with a pixel type of Rgb
, holding a subpixel type of u8
and an underlying ImageBuffer
buffer that holds Vec<u8>
’s.
impl<Container> FromWithFormat<Container> for Image<Rgb<u8>, ImageBuffer<Rgb<u8>, Vec<u8>>>
Implementation of FromWithFormat
for an Image
with a pixel type of Rgb
, holding a subpixel type of u8
and an underlying ImageBuffer
buffer that holds Vec<u8>
’s.
Source§fn from_with_format(container: Container, format: ImageFormat) -> Self
fn from_with_format(container: Container, format: ImageFormat) -> Self
Source§impl<Container> FromWithFormat<Container> for Image<Rgba<f32>, ImageBuffer<Rgba<f32>, Vec<f32>>>
Implementation of FromWithFormat
for an Image
with a pixel type of Rgba
, holding a subpixel type of f32
and an underlying ImageBuffer
buffer that holds Vec<f32>
’s.
impl<Container> FromWithFormat<Container> for Image<Rgba<f32>, ImageBuffer<Rgba<f32>, Vec<f32>>>
Implementation of FromWithFormat
for an Image
with a pixel type of Rgba
, holding a subpixel type of f32
and an underlying ImageBuffer
buffer that holds Vec<f32>
’s.
Source§fn from_with_format(container: Container, format: ImageFormat) -> Self
fn from_with_format(container: Container, format: ImageFormat) -> Self
Source§impl<Container> FromWithFormat<Container> for Image<Rgba<u16>, ImageBuffer<Rgba<u16>, Vec<u16>>>
Implementation of FromWithFormat
for an Image
with a pixel type of Rgba
, holding a subpixel type of u16
and an underlying ImageBuffer
buffer that holds Vec<u16>
’s.
impl<Container> FromWithFormat<Container> for Image<Rgba<u16>, ImageBuffer<Rgba<u16>, Vec<u16>>>
Implementation of FromWithFormat
for an Image
with a pixel type of Rgba
, holding a subpixel type of u16
and an underlying ImageBuffer
buffer that holds Vec<u16>
’s.
Source§fn from_with_format(container: Container, format: ImageFormat) -> Self
fn from_with_format(container: Container, format: ImageFormat) -> Self
Source§impl<Container> FromWithFormat<Container> for Image<Rgba<u8>, ImageBuffer<Rgba<u8>, Vec<u8>>>
Implementation of FromWithFormat
for an Image
with a pixel type of Rgba
, holding a subpixel type of u8
and an underlying ImageBuffer
buffer that holds Vec<u8>
’s.
impl<Container> FromWithFormat<Container> for Image<Rgba<u8>, ImageBuffer<Rgba<u8>, Vec<u8>>>
Implementation of FromWithFormat
for an Image
with a pixel type of Rgba
, holding a subpixel type of u8
and an underlying ImageBuffer
buffer that holds Vec<u8>
’s.
Source§fn from_with_format(container: Container, format: ImageFormat) -> Self
fn from_with_format(container: Container, format: ImageFormat) -> Self
impl<P: Eq + Pixel, U: Eq + GenericImage<Pixel = P>> Eq for Image<P, U>
impl<P: Pixel, U: GenericImage<Pixel = P>> StructuralPartialEq for Image<P, U>
Auto Trait Implementations§
impl<P, U> Freeze for Image<P, U>where
U: Freeze,
impl<P, U> RefUnwindSafe for Image<P, U>where
U: RefUnwindSafe,
impl<P, U> Send for Image<P, U>where
U: Send,
impl<P, U> Sync for Image<P, U>where
U: Sync,
impl<P, U> Unpin for Image<P, U>where
U: Unpin,
impl<P, U> UnwindSafe for Image<P, U>where
U: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more