#[non_exhaustive]pub enum DynamicImage {
ImageLuma8(ImageBuffer<Luma<u8>, Vec<u8>>),
ImageLumaA8(ImageBuffer<LumaA<u8>, Vec<u8>>),
ImageRgb8(ImageBuffer<Rgb<u8>, Vec<u8>>),
ImageRgba8(ImageBuffer<Rgba<u8>, Vec<u8>>),
ImageLuma16(ImageBuffer<Luma<u16>, Vec<u16>>),
ImageLumaA16(ImageBuffer<LumaA<u16>, Vec<u16>>),
ImageRgb16(ImageBuffer<Rgb<u16>, Vec<u16>>),
ImageRgba16(ImageBuffer<Rgba<u16>, Vec<u16>>),
ImageRgb32F(ImageBuffer<Rgb<f32>, Vec<f32>>),
ImageRgba32F(ImageBuffer<Rgba<f32>, Vec<f32>>),
}
Expand description
A Dynamic Image
This represents a matrix of pixels which are convertible from and to an RGBA representation. More variants that adhere to these principles may get added in the future, in particular to cover other combinations typically used.
§Usage
This type can act as a converter between specific ImageBuffer
instances.
use image::{DynamicImage, GrayImage, RgbImage};
let rgb: RgbImage = RgbImage::new(10, 10);
let luma: GrayImage = DynamicImage::ImageRgb8(rgb).into_luma8();
§Design
There is no goal to provide an all-encompassing type with all possible memory layouts. This would hardly be feasible as a simple enum, due to the sheer number of combinations of channel kinds, channel order, and bit depth. Rather, this type provides an opinionated selection with normalized channel order which can store common pixel values without loss.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
ImageLuma8(ImageBuffer<Luma<u8>, Vec<u8>>)
Each pixel in this image is 8-bit Luma
ImageLumaA8(ImageBuffer<LumaA<u8>, Vec<u8>>)
Each pixel in this image is 8-bit Luma with alpha
ImageRgb8(ImageBuffer<Rgb<u8>, Vec<u8>>)
Each pixel in this image is 8-bit Rgb
ImageRgba8(ImageBuffer<Rgba<u8>, Vec<u8>>)
Each pixel in this image is 8-bit Rgb with alpha
ImageLuma16(ImageBuffer<Luma<u16>, Vec<u16>>)
Each pixel in this image is 16-bit Luma
ImageLumaA16(ImageBuffer<LumaA<u16>, Vec<u16>>)
Each pixel in this image is 16-bit Luma with alpha
ImageRgb16(ImageBuffer<Rgb<u16>, Vec<u16>>)
Each pixel in this image is 16-bit Rgb
ImageRgba16(ImageBuffer<Rgba<u16>, Vec<u16>>)
Each pixel in this image is 16-bit Rgb with alpha
ImageRgb32F(ImageBuffer<Rgb<f32>, Vec<f32>>)
Each pixel in this image is 32-bit float Rgb
ImageRgba32F(ImageBuffer<Rgba<f32>, Vec<f32>>)
Each pixel in this image is 32-bit float Rgb with alpha
Implementations§
source§impl DynamicImage
impl DynamicImage
sourcepub fn new(w: u32, h: u32, color: ColorType) -> DynamicImage
pub fn new(w: u32, h: u32, color: ColorType) -> DynamicImage
Creates a dynamic image backed by a buffer depending on the color type given.
sourcepub fn new_luma8(w: u32, h: u32) -> DynamicImage
pub fn new_luma8(w: u32, h: u32) -> DynamicImage
Creates a dynamic image backed by a buffer of gray pixels.
sourcepub fn new_luma_a8(w: u32, h: u32) -> DynamicImage
pub fn new_luma_a8(w: u32, h: u32) -> DynamicImage
Creates a dynamic image backed by a buffer of gray pixels with transparency.
sourcepub fn new_rgb8(w: u32, h: u32) -> DynamicImage
pub fn new_rgb8(w: u32, h: u32) -> DynamicImage
Creates a dynamic image backed by a buffer of RGB pixels.
sourcepub fn new_rgba8(w: u32, h: u32) -> DynamicImage
pub fn new_rgba8(w: u32, h: u32) -> DynamicImage
Creates a dynamic image backed by a buffer of RGBA pixels.
sourcepub fn new_luma16(w: u32, h: u32) -> DynamicImage
pub fn new_luma16(w: u32, h: u32) -> DynamicImage
Creates a dynamic image backed by a buffer of gray pixels.
sourcepub fn new_luma_a16(w: u32, h: u32) -> DynamicImage
pub fn new_luma_a16(w: u32, h: u32) -> DynamicImage
Creates a dynamic image backed by a buffer of gray pixels with transparency.
sourcepub fn new_rgb16(w: u32, h: u32) -> DynamicImage
pub fn new_rgb16(w: u32, h: u32) -> DynamicImage
Creates a dynamic image backed by a buffer of RGB pixels.
sourcepub fn new_rgba16(w: u32, h: u32) -> DynamicImage
pub fn new_rgba16(w: u32, h: u32) -> DynamicImage
Creates a dynamic image backed by a buffer of RGBA pixels.
sourcepub fn new_rgb32f(w: u32, h: u32) -> DynamicImage
pub fn new_rgb32f(w: u32, h: u32) -> DynamicImage
Creates a dynamic image backed by a buffer of RGB pixels.
sourcepub fn new_rgba32f(w: u32, h: u32) -> DynamicImage
pub fn new_rgba32f(w: u32, h: u32) -> DynamicImage
Creates a dynamic image backed by a buffer of RGBA pixels.
sourcepub fn from_decoder<'a>(
decoder: impl ImageDecoder<'a>,
) -> Result<DynamicImage, ImageError>
pub fn from_decoder<'a>( decoder: impl ImageDecoder<'a>, ) -> Result<DynamicImage, ImageError>
Decodes an encoded image into a dynamic image.
sourcepub fn to_rgb8(&self) -> ImageBuffer<Rgb<u8>, Vec<u8>>
pub fn to_rgb8(&self) -> ImageBuffer<Rgb<u8>, Vec<u8>>
Returns a copy of this image as an RGB image.
sourcepub fn to_rgb16(&self) -> ImageBuffer<Rgb<u16>, Vec<u16>>
pub fn to_rgb16(&self) -> ImageBuffer<Rgb<u16>, Vec<u16>>
Returns a copy of this image as an RGB image.
sourcepub fn to_rgb32f(&self) -> ImageBuffer<Rgb<f32>, Vec<f32>>
pub fn to_rgb32f(&self) -> ImageBuffer<Rgb<f32>, Vec<f32>>
Returns a copy of this image as an RGB image.
sourcepub fn to_rgba8(&self) -> ImageBuffer<Rgba<u8>, Vec<u8>>
pub fn to_rgba8(&self) -> ImageBuffer<Rgba<u8>, Vec<u8>>
Returns a copy of this image as an RGBA image.
sourcepub fn to_rgba16(&self) -> ImageBuffer<Rgba<u16>, Vec<u16>>
pub fn to_rgba16(&self) -> ImageBuffer<Rgba<u16>, Vec<u16>>
Returns a copy of this image as an RGBA image.
sourcepub fn to_rgba32f(&self) -> ImageBuffer<Rgba<f32>, Vec<f32>>
pub fn to_rgba32f(&self) -> ImageBuffer<Rgba<f32>, Vec<f32>>
Returns a copy of this image as an RGBA image.
sourcepub fn to_luma8(&self) -> ImageBuffer<Luma<u8>, Vec<u8>>
pub fn to_luma8(&self) -> ImageBuffer<Luma<u8>, Vec<u8>>
Returns a copy of this image as a Luma image.
sourcepub fn to_luma16(&self) -> ImageBuffer<Luma<u16>, Vec<u16>>
pub fn to_luma16(&self) -> ImageBuffer<Luma<u16>, Vec<u16>>
Returns a copy of this image as a Luma image.
sourcepub fn to_luma32f(&self) -> ImageBuffer<Luma<f32>, Vec<f32>>
pub fn to_luma32f(&self) -> ImageBuffer<Luma<f32>, Vec<f32>>
Returns a copy of this image as a Luma image.
sourcepub fn to_luma_alpha8(&self) -> ImageBuffer<LumaA<u8>, Vec<u8>>
pub fn to_luma_alpha8(&self) -> ImageBuffer<LumaA<u8>, Vec<u8>>
Returns a copy of this image as a LumaA image.
sourcepub fn to_luma_alpha16(&self) -> ImageBuffer<LumaA<u16>, Vec<u16>>
pub fn to_luma_alpha16(&self) -> ImageBuffer<LumaA<u16>, Vec<u16>>
Returns a copy of this image as a LumaA image.
sourcepub fn to_luma_alpha32f(&self) -> ImageBuffer<LumaA<f32>, Vec<f32>>
pub fn to_luma_alpha32f(&self) -> ImageBuffer<LumaA<f32>, Vec<f32>>
Returns a copy of this image as a LumaA image.
sourcepub fn into_rgb8(self) -> ImageBuffer<Rgb<u8>, Vec<u8>>
pub fn into_rgb8(self) -> ImageBuffer<Rgb<u8>, Vec<u8>>
Consume the image and returns a RGB image.
If the image was already the correct format, it is returned as is. Otherwise, a copy is created.
sourcepub fn into_rgb16(self) -> ImageBuffer<Rgb<u16>, Vec<u16>>
pub fn into_rgb16(self) -> ImageBuffer<Rgb<u16>, Vec<u16>>
Consume the image and returns a RGB image.
If the image was already the correct format, it is returned as is. Otherwise, a copy is created.
sourcepub fn into_rgb32f(self) -> ImageBuffer<Rgb<f32>, Vec<f32>>
pub fn into_rgb32f(self) -> ImageBuffer<Rgb<f32>, Vec<f32>>
Consume the image and returns a RGB image.
If the image was already the correct format, it is returned as is. Otherwise, a copy is created.
sourcepub fn into_rgba8(self) -> ImageBuffer<Rgba<u8>, Vec<u8>>
pub fn into_rgba8(self) -> ImageBuffer<Rgba<u8>, Vec<u8>>
Consume the image and returns a RGBA image.
If the image was already the correct format, it is returned as is. Otherwise, a copy is created.
sourcepub fn into_rgba16(self) -> ImageBuffer<Rgba<u16>, Vec<u16>>
pub fn into_rgba16(self) -> ImageBuffer<Rgba<u16>, Vec<u16>>
Consume the image and returns a RGBA image.
If the image was already the correct format, it is returned as is. Otherwise, a copy is created.
sourcepub fn into_rgba32f(self) -> ImageBuffer<Rgba<f32>, Vec<f32>>
pub fn into_rgba32f(self) -> ImageBuffer<Rgba<f32>, Vec<f32>>
Consume the image and returns a RGBA image.
If the image was already the correct format, it is returned as is. Otherwise, a copy is created.
sourcepub fn into_luma8(self) -> ImageBuffer<Luma<u8>, Vec<u8>>
pub fn into_luma8(self) -> ImageBuffer<Luma<u8>, Vec<u8>>
Consume the image and returns a Luma image.
If the image was already the correct format, it is returned as is. Otherwise, a copy is created.
sourcepub fn into_luma16(self) -> ImageBuffer<Luma<u16>, Vec<u16>>
pub fn into_luma16(self) -> ImageBuffer<Luma<u16>, Vec<u16>>
Consume the image and returns a Luma image.
If the image was already the correct format, it is returned as is. Otherwise, a copy is created.
sourcepub fn into_luma_alpha8(self) -> ImageBuffer<LumaA<u8>, Vec<u8>>
pub fn into_luma_alpha8(self) -> ImageBuffer<LumaA<u8>, Vec<u8>>
Consume the image and returns a LumaA image.
If the image was already the correct format, it is returned as is. Otherwise, a copy is created.
sourcepub fn into_luma_alpha16(self) -> ImageBuffer<LumaA<u16>, Vec<u16>>
pub fn into_luma_alpha16(self) -> ImageBuffer<LumaA<u16>, Vec<u16>>
Consume the image and returns a LumaA image.
If the image was already the correct format, it is returned as is. Otherwise, a copy is created.
sourcepub fn crop(&mut self, x: u32, y: u32, width: u32, height: u32) -> DynamicImage
pub fn crop(&mut self, x: u32, y: u32, width: u32, height: u32) -> DynamicImage
Return a cut-out of this image delimited by the bounding rectangle.
Note: this method does not modify the object,
and its signature will be replaced with crop_imm()
’s in the 0.24 release
sourcepub fn crop_imm(&self, x: u32, y: u32, width: u32, height: u32) -> DynamicImage
pub fn crop_imm(&self, x: u32, y: u32, width: u32, height: u32) -> DynamicImage
Return a cut-out of this image delimited by the bounding rectangle.
sourcepub fn as_rgb8(&self) -> Option<&ImageBuffer<Rgb<u8>, Vec<u8>>>
pub fn as_rgb8(&self) -> Option<&ImageBuffer<Rgb<u8>, Vec<u8>>>
Return a reference to an 8bit RGB image
sourcepub fn as_mut_rgb8(&mut self) -> Option<&mut ImageBuffer<Rgb<u8>, Vec<u8>>>
pub fn as_mut_rgb8(&mut self) -> Option<&mut ImageBuffer<Rgb<u8>, Vec<u8>>>
Return a mutable reference to an 8bit RGB image
sourcepub fn as_rgba8(&self) -> Option<&ImageBuffer<Rgba<u8>, Vec<u8>>>
pub fn as_rgba8(&self) -> Option<&ImageBuffer<Rgba<u8>, Vec<u8>>>
Return a reference to an 8bit RGBA image
sourcepub fn as_mut_rgba8(&mut self) -> Option<&mut ImageBuffer<Rgba<u8>, Vec<u8>>>
pub fn as_mut_rgba8(&mut self) -> Option<&mut ImageBuffer<Rgba<u8>, Vec<u8>>>
Return a mutable reference to an 8bit RGBA image
sourcepub fn as_luma8(&self) -> Option<&ImageBuffer<Luma<u8>, Vec<u8>>>
pub fn as_luma8(&self) -> Option<&ImageBuffer<Luma<u8>, Vec<u8>>>
Return a reference to an 8bit Grayscale image
sourcepub fn as_mut_luma8(&mut self) -> Option<&mut ImageBuffer<Luma<u8>, Vec<u8>>>
pub fn as_mut_luma8(&mut self) -> Option<&mut ImageBuffer<Luma<u8>, Vec<u8>>>
Return a mutable reference to an 8bit Grayscale image
sourcepub fn as_luma_alpha8(&self) -> Option<&ImageBuffer<LumaA<u8>, Vec<u8>>>
pub fn as_luma_alpha8(&self) -> Option<&ImageBuffer<LumaA<u8>, Vec<u8>>>
Return a reference to an 8bit Grayscale image with an alpha channel
sourcepub fn as_mut_luma_alpha8(
&mut self,
) -> Option<&mut ImageBuffer<LumaA<u8>, Vec<u8>>>
pub fn as_mut_luma_alpha8( &mut self, ) -> Option<&mut ImageBuffer<LumaA<u8>, Vec<u8>>>
Return a mutable reference to an 8bit Grayscale image with an alpha channel
sourcepub fn as_rgb16(&self) -> Option<&ImageBuffer<Rgb<u16>, Vec<u16>>>
pub fn as_rgb16(&self) -> Option<&ImageBuffer<Rgb<u16>, Vec<u16>>>
Return a reference to an 16bit RGB image
sourcepub fn as_mut_rgb16(&mut self) -> Option<&mut ImageBuffer<Rgb<u16>, Vec<u16>>>
pub fn as_mut_rgb16(&mut self) -> Option<&mut ImageBuffer<Rgb<u16>, Vec<u16>>>
Return a mutable reference to an 16bit RGB image
sourcepub fn as_rgba16(&self) -> Option<&ImageBuffer<Rgba<u16>, Vec<u16>>>
pub fn as_rgba16(&self) -> Option<&ImageBuffer<Rgba<u16>, Vec<u16>>>
Return a reference to an 16bit RGBA image
sourcepub fn as_mut_rgba16(&mut self) -> Option<&mut ImageBuffer<Rgba<u16>, Vec<u16>>>
pub fn as_mut_rgba16(&mut self) -> Option<&mut ImageBuffer<Rgba<u16>, Vec<u16>>>
Return a mutable reference to an 16bit RGBA image
sourcepub fn as_rgb32f(&self) -> Option<&ImageBuffer<Rgb<f32>, Vec<f32>>>
pub fn as_rgb32f(&self) -> Option<&ImageBuffer<Rgb<f32>, Vec<f32>>>
Return a reference to an 32bit RGB image
sourcepub fn as_mut_rgb32f(&mut self) -> Option<&mut ImageBuffer<Rgb<f32>, Vec<f32>>>
pub fn as_mut_rgb32f(&mut self) -> Option<&mut ImageBuffer<Rgb<f32>, Vec<f32>>>
Return a mutable reference to an 32bit RGB image
sourcepub fn as_rgba32f(&self) -> Option<&ImageBuffer<Rgba<f32>, Vec<f32>>>
pub fn as_rgba32f(&self) -> Option<&ImageBuffer<Rgba<f32>, Vec<f32>>>
Return a reference to an 32bit RGBA image
sourcepub fn as_mut_rgba32f(
&mut self,
) -> Option<&mut ImageBuffer<Rgba<f32>, Vec<f32>>>
pub fn as_mut_rgba32f( &mut self, ) -> Option<&mut ImageBuffer<Rgba<f32>, Vec<f32>>>
Return a mutable reference to an 16bit RGBA image
sourcepub fn as_luma16(&self) -> Option<&ImageBuffer<Luma<u16>, Vec<u16>>>
pub fn as_luma16(&self) -> Option<&ImageBuffer<Luma<u16>, Vec<u16>>>
Return a reference to an 16bit Grayscale image
sourcepub fn as_mut_luma16(&mut self) -> Option<&mut ImageBuffer<Luma<u16>, Vec<u16>>>
pub fn as_mut_luma16(&mut self) -> Option<&mut ImageBuffer<Luma<u16>, Vec<u16>>>
Return a mutable reference to an 16bit Grayscale image
sourcepub fn as_luma_alpha16(&self) -> Option<&ImageBuffer<LumaA<u16>, Vec<u16>>>
pub fn as_luma_alpha16(&self) -> Option<&ImageBuffer<LumaA<u16>, Vec<u16>>>
Return a reference to an 16bit Grayscale image with an alpha channel
sourcepub fn as_mut_luma_alpha16(
&mut self,
) -> Option<&mut ImageBuffer<LumaA<u16>, Vec<u16>>>
pub fn as_mut_luma_alpha16( &mut self, ) -> Option<&mut ImageBuffer<LumaA<u16>, Vec<u16>>>
Return a mutable reference to an 16bit Grayscale image with an alpha channel
sourcepub fn as_flat_samples_u8(&self) -> Option<FlatSamples<&[u8]>>
pub fn as_flat_samples_u8(&self) -> Option<FlatSamples<&[u8]>>
Return a view on the raw sample buffer for 8 bit per channel images.
sourcepub fn as_flat_samples_u16(&self) -> Option<FlatSamples<&[u16]>>
pub fn as_flat_samples_u16(&self) -> Option<FlatSamples<&[u16]>>
Return a view on the raw sample buffer for 16 bit per channel images.
sourcepub fn as_flat_samples_f32(&self) -> Option<FlatSamples<&[f32]>>
pub fn as_flat_samples_f32(&self) -> Option<FlatSamples<&[f32]>>
Return a view on the raw sample buffer for 32bit per channel images.
sourcepub fn into_bytes(self) -> Vec<u8> ⓘ
pub fn into_bytes(self) -> Vec<u8> ⓘ
Return this image’s pixels as a byte vector. If the ImageBuffer
container is Vec<u8>
, this operation is free. Otherwise, a copy
is returned.
sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
👎Deprecated since 0.24.0: use image.into_bytes()
or image.as_bytes().to_vec()
instead
pub fn to_bytes(&self) -> Vec<u8> ⓘ
image.into_bytes()
or image.as_bytes().to_vec()
insteadReturn a copy of this image’s pixels as a byte vector. Deprecated, because it does nothing but hide an expensive clone operation.
sourcepub fn grayscale(&self) -> DynamicImage
pub fn grayscale(&self) -> DynamicImage
Return a grayscale version of this image.
Returns Luma
images in most cases. However, for f32
images,
this will return a grayscale Rgb/Rgba
image instead.
sourcepub fn resize(
&self,
nwidth: u32,
nheight: u32,
filter: FilterType,
) -> DynamicImage
pub fn resize( &self, nwidth: u32, nheight: u32, filter: FilterType, ) -> DynamicImage
Resize this image using the specified filter algorithm.
Returns a new image. The image’s aspect ratio is preserved.
The image is scaled to the maximum possible size that fits
within the bounds specified by nwidth
and nheight
.
sourcepub fn resize_exact(
&self,
nwidth: u32,
nheight: u32,
filter: FilterType,
) -> DynamicImage
pub fn resize_exact( &self, nwidth: u32, nheight: u32, filter: FilterType, ) -> DynamicImage
Resize this image using the specified filter algorithm.
Returns a new image. Does not preserve aspect ratio.
nwidth
and nheight
are the new image’s dimensions
sourcepub fn thumbnail(&self, nwidth: u32, nheight: u32) -> DynamicImage
pub fn thumbnail(&self, nwidth: u32, nheight: u32) -> DynamicImage
Scale this image down to fit within a specific size.
Returns a new image. The image’s aspect ratio is preserved.
The image is scaled to the maximum possible size that fits
within the bounds specified by nwidth
and nheight
.
This method uses a fast integer algorithm where each source pixel contributes to exactly one target pixel. May give aliasing artifacts if new size is close to old size.
sourcepub fn thumbnail_exact(&self, nwidth: u32, nheight: u32) -> DynamicImage
pub fn thumbnail_exact(&self, nwidth: u32, nheight: u32) -> DynamicImage
Scale this image down to a specific size.
Returns a new image. Does not preserve aspect ratio.
nwidth
and nheight
are the new image’s dimensions.
This method uses a fast integer algorithm where each source
pixel contributes to exactly one target pixel.
May give aliasing artifacts if new size is close to old size.
sourcepub fn resize_to_fill(
&self,
nwidth: u32,
nheight: u32,
filter: FilterType,
) -> DynamicImage
pub fn resize_to_fill( &self, nwidth: u32, nheight: u32, filter: FilterType, ) -> DynamicImage
Resize this image using the specified filter algorithm.
Returns a new image. The image’s aspect ratio is preserved.
The image is scaled to the maximum possible size that fits
within the larger (relative to aspect ratio) of the bounds
specified by nwidth
and nheight
, then cropped to
fit within the other bound.
sourcepub fn blur(&self, sigma: f32) -> DynamicImage
pub fn blur(&self, sigma: f32) -> DynamicImage
Performs a Gaussian blur on this image.
sigma
is a measure of how much to blur by.
sourcepub fn unsharpen(&self, sigma: f32, threshold: i32) -> DynamicImage
pub fn unsharpen(&self, sigma: f32, threshold: i32) -> DynamicImage
Performs an unsharpen mask on this image.
sigma
is the amount to blur the image by.
threshold
is a control of how much to sharpen.
See https://en.wikipedia.org/wiki/Unsharp_masking#Digital_unsharp_masking
sourcepub fn filter3x3(&self, kernel: &[f32]) -> DynamicImage
pub fn filter3x3(&self, kernel: &[f32]) -> DynamicImage
Filters this image with the specified 3x3 kernel.
sourcepub fn adjust_contrast(&self, c: f32) -> DynamicImage
pub fn adjust_contrast(&self, c: f32) -> DynamicImage
Adjust the contrast of this image.
contrast
is the amount to adjust the contrast by.
Negative values decrease the contrast and positive values increase the contrast.
sourcepub fn brighten(&self, value: i32) -> DynamicImage
pub fn brighten(&self, value: i32) -> DynamicImage
Brighten the pixels of this image.
value
is the amount to brighten each pixel by.
Negative values decrease the brightness and positive values increase it.
sourcepub fn huerotate(&self, value: i32) -> DynamicImage
pub fn huerotate(&self, value: i32) -> DynamicImage
Hue rotate the supplied image.
value
is the degrees to rotate each pixel by.
0 and 360 do nothing, the rest rotates by the given degree value.
just like the css webkit filter hue-rotate(180)
sourcepub fn flipv(&self) -> DynamicImage
pub fn flipv(&self) -> DynamicImage
Flip this image vertically
sourcepub fn fliph(&self) -> DynamicImage
pub fn fliph(&self) -> DynamicImage
Flip this image horizontally
sourcepub fn rotate90(&self) -> DynamicImage
pub fn rotate90(&self) -> DynamicImage
Rotate this image 90 degrees clockwise.
sourcepub fn rotate180(&self) -> DynamicImage
pub fn rotate180(&self) -> DynamicImage
Rotate this image 180 degrees clockwise.
sourcepub fn rotate270(&self) -> DynamicImage
pub fn rotate270(&self) -> DynamicImage
Rotate this image 270 degrees clockwise.
sourcepub fn write_to<W, F>(&self, w: &mut W, format: F) -> Result<(), ImageError>
pub fn write_to<W, F>(&self, w: &mut W, format: F) -> Result<(), ImageError>
Encode this image and write it to w
.
Assumes the writer is buffered. In most cases,
you should wrap your writer in a BufWriter
for best performance.
sourcepub fn write_with_encoder(
&self,
encoder: impl ImageEncoder,
) -> Result<(), ImageError>
pub fn write_with_encoder( &self, encoder: impl ImageEncoder, ) -> Result<(), ImageError>
Encode this image with the provided encoder.
sourcepub fn save<Q>(&self, path: Q) -> Result<(), ImageError>
pub fn save<Q>(&self, path: Q) -> Result<(), ImageError>
Saves the buffer to a file at the path specified.
The image format is derived from the file extension.
sourcepub fn save_with_format<Q>(
&self,
path: Q,
format: ImageFormat,
) -> Result<(), ImageError>
pub fn save_with_format<Q>( &self, path: Q, format: ImageFormat, ) -> Result<(), ImageError>
Saves the buffer to a file at the specified path in the specified format.
See save_buffer_with_format
for
supported types.
Trait Implementations§
source§impl Clone for DynamicImage
impl Clone for DynamicImage
source§fn clone(&self) -> DynamicImage
fn clone(&self) -> DynamicImage
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for DynamicImage
impl Debug for DynamicImage
source§impl Default for DynamicImage
impl Default for DynamicImage
source§fn default() -> DynamicImage
fn default() -> DynamicImage
source§impl From<DynamicImage> for ImageBuffer<Luma<u16>, Vec<u16>>
impl From<DynamicImage> for ImageBuffer<Luma<u16>, Vec<u16>>
source§fn from(value: DynamicImage) -> ImageBuffer<Luma<u16>, Vec<u16>>
fn from(value: DynamicImage) -> ImageBuffer<Luma<u16>, Vec<u16>>
source§impl From<DynamicImage> for ImageBuffer<Luma<u8>, Vec<u8>>
impl From<DynamicImage> for ImageBuffer<Luma<u8>, Vec<u8>>
source§fn from(value: DynamicImage) -> ImageBuffer<Luma<u8>, Vec<u8>>
fn from(value: DynamicImage) -> ImageBuffer<Luma<u8>, Vec<u8>>
source§impl From<DynamicImage> for ImageBuffer<LumaA<u16>, Vec<u16>>
impl From<DynamicImage> for ImageBuffer<LumaA<u16>, Vec<u16>>
source§fn from(value: DynamicImage) -> ImageBuffer<LumaA<u16>, Vec<u16>>
fn from(value: DynamicImage) -> ImageBuffer<LumaA<u16>, Vec<u16>>
source§impl From<DynamicImage> for ImageBuffer<LumaA<u8>, Vec<u8>>
impl From<DynamicImage> for ImageBuffer<LumaA<u8>, Vec<u8>>
source§fn from(value: DynamicImage) -> ImageBuffer<LumaA<u8>, Vec<u8>>
fn from(value: DynamicImage) -> ImageBuffer<LumaA<u8>, Vec<u8>>
source§impl From<DynamicImage> for ImageBuffer<Rgb<u16>, Vec<u16>>
impl From<DynamicImage> for ImageBuffer<Rgb<u16>, Vec<u16>>
source§fn from(value: DynamicImage) -> ImageBuffer<Rgb<u16>, Vec<u16>>
fn from(value: DynamicImage) -> ImageBuffer<Rgb<u16>, Vec<u16>>
source§impl From<DynamicImage> for ImageBuffer<Rgb<u8>, Vec<u8>>
impl From<DynamicImage> for ImageBuffer<Rgb<u8>, Vec<u8>>
source§fn from(value: DynamicImage) -> ImageBuffer<Rgb<u8>, Vec<u8>>
fn from(value: DynamicImage) -> ImageBuffer<Rgb<u8>, Vec<u8>>
source§impl From<DynamicImage> for ImageBuffer<Rgba<f32>, Vec<f32>>
impl From<DynamicImage> for ImageBuffer<Rgba<f32>, Vec<f32>>
source§fn from(value: DynamicImage) -> ImageBuffer<Rgba<f32>, Vec<f32>>
fn from(value: DynamicImage) -> ImageBuffer<Rgba<f32>, Vec<f32>>
source§impl From<DynamicImage> for ImageBuffer<Rgba<u16>, Vec<u16>>
impl From<DynamicImage> for ImageBuffer<Rgba<u16>, Vec<u16>>
source§fn from(value: DynamicImage) -> ImageBuffer<Rgba<u16>, Vec<u16>>
fn from(value: DynamicImage) -> ImageBuffer<Rgba<u16>, Vec<u16>>
source§impl From<DynamicImage> for ImageBuffer<Rgba<u8>, Vec<u8>>
impl From<DynamicImage> for ImageBuffer<Rgba<u8>, Vec<u8>>
source§fn from(value: DynamicImage) -> ImageBuffer<Rgba<u8>, Vec<u8>>
fn from(value: DynamicImage) -> ImageBuffer<Rgba<u8>, Vec<u8>>
source§impl From<ImageBuffer<Luma<f32>, Vec<f32>>> for DynamicImage
impl From<ImageBuffer<Luma<f32>, Vec<f32>>> for DynamicImage
source§fn from(image: ImageBuffer<Luma<f32>, Vec<f32>>) -> DynamicImage
fn from(image: ImageBuffer<Luma<f32>, Vec<f32>>) -> DynamicImage
source§impl From<ImageBuffer<Luma<u16>, Vec<u16>>> for DynamicImage
impl From<ImageBuffer<Luma<u16>, Vec<u16>>> for DynamicImage
source§fn from(image: ImageBuffer<Luma<u16>, Vec<u16>>) -> DynamicImage
fn from(image: ImageBuffer<Luma<u16>, Vec<u16>>) -> DynamicImage
source§impl From<ImageBuffer<Luma<u8>, Vec<u8>>> for DynamicImage
impl From<ImageBuffer<Luma<u8>, Vec<u8>>> for DynamicImage
source§fn from(image: ImageBuffer<Luma<u8>, Vec<u8>>) -> DynamicImage
fn from(image: ImageBuffer<Luma<u8>, Vec<u8>>) -> DynamicImage
source§impl From<ImageBuffer<LumaA<f32>, Vec<f32>>> for DynamicImage
impl From<ImageBuffer<LumaA<f32>, Vec<f32>>> for DynamicImage
source§fn from(image: ImageBuffer<LumaA<f32>, Vec<f32>>) -> DynamicImage
fn from(image: ImageBuffer<LumaA<f32>, Vec<f32>>) -> DynamicImage
source§impl From<ImageBuffer<LumaA<u16>, Vec<u16>>> for DynamicImage
impl From<ImageBuffer<LumaA<u16>, Vec<u16>>> for DynamicImage
source§fn from(image: ImageBuffer<LumaA<u16>, Vec<u16>>) -> DynamicImage
fn from(image: ImageBuffer<LumaA<u16>, Vec<u16>>) -> DynamicImage
source§impl From<ImageBuffer<LumaA<u8>, Vec<u8>>> for DynamicImage
impl From<ImageBuffer<LumaA<u8>, Vec<u8>>> for DynamicImage
source§fn from(image: ImageBuffer<LumaA<u8>, Vec<u8>>) -> DynamicImage
fn from(image: ImageBuffer<LumaA<u8>, Vec<u8>>) -> DynamicImage
source§impl From<ImageBuffer<Rgb<f32>, Vec<f32>>> for DynamicImage
impl From<ImageBuffer<Rgb<f32>, Vec<f32>>> for DynamicImage
source§fn from(image: ImageBuffer<Rgb<f32>, Vec<f32>>) -> DynamicImage
fn from(image: ImageBuffer<Rgb<f32>, Vec<f32>>) -> DynamicImage
source§impl From<ImageBuffer<Rgb<u16>, Vec<u16>>> for DynamicImage
impl From<ImageBuffer<Rgb<u16>, Vec<u16>>> for DynamicImage
source§fn from(image: ImageBuffer<Rgb<u16>, Vec<u16>>) -> DynamicImage
fn from(image: ImageBuffer<Rgb<u16>, Vec<u16>>) -> DynamicImage
source§impl From<ImageBuffer<Rgb<u8>, Vec<u8>>> for DynamicImage
impl From<ImageBuffer<Rgb<u8>, Vec<u8>>> for DynamicImage
source§fn from(image: ImageBuffer<Rgb<u8>, Vec<u8>>) -> DynamicImage
fn from(image: ImageBuffer<Rgb<u8>, Vec<u8>>) -> DynamicImage
source§impl From<ImageBuffer<Rgba<f32>, Vec<f32>>> for DynamicImage
impl From<ImageBuffer<Rgba<f32>, Vec<f32>>> for DynamicImage
source§fn from(image: ImageBuffer<Rgba<f32>, Vec<f32>>) -> DynamicImage
fn from(image: ImageBuffer<Rgba<f32>, Vec<f32>>) -> DynamicImage
source§impl From<ImageBuffer<Rgba<u16>, Vec<u16>>> for DynamicImage
impl From<ImageBuffer<Rgba<u16>, Vec<u16>>> for DynamicImage
source§fn from(image: ImageBuffer<Rgba<u16>, Vec<u16>>) -> DynamicImage
fn from(image: ImageBuffer<Rgba<u16>, Vec<u16>>) -> DynamicImage
source§impl From<ImageBuffer<Rgba<u8>, Vec<u8>>> for DynamicImage
impl From<ImageBuffer<Rgba<u8>, Vec<u8>>> for DynamicImage
source§fn from(image: ImageBuffer<Rgba<u8>, Vec<u8>>) -> DynamicImage
fn from(image: ImageBuffer<Rgba<u8>, Vec<u8>>) -> DynamicImage
source§impl GenericImage for DynamicImage
impl GenericImage for DynamicImage
source§fn get_pixel_mut(&mut self, _: u32, _: u32) -> &mut Rgba<u8>
👎Deprecated since 0.24.0: Use get_pixel
and put_pixel
instead.
fn get_pixel_mut(&mut self, _: u32, _: u32) -> &mut Rgba<u8>
get_pixel
and put_pixel
instead.Do not use is function: It is unimplemented!
source§fn put_pixel(&mut self, x: u32, y: u32, pixel: Rgba<u8>)
fn put_pixel(&mut self, x: u32, y: u32, pixel: Rgba<u8>)
source§fn blend_pixel(&mut self, x: u32, y: u32, pixel: Rgba<u8>)
fn blend_pixel(&mut self, x: u32, y: u32, pixel: Rgba<u8>)
pixels_mut
to blend the pixels directlysource§unsafe fn unsafe_put_pixel(&mut self, x: u32, y: u32, pixel: Self::Pixel)
unsafe fn unsafe_put_pixel(&mut self, x: u32, y: u32, pixel: Self::Pixel)
source§fn copy_from<O>(&mut self, other: &O, x: u32, y: u32) -> Result<(), ImageError>where
O: GenericImageView<Pixel = Self::Pixel>,
fn copy_from<O>(&mut self, other: &O, x: u32, y: u32) -> Result<(), ImageError>where
O: GenericImageView<Pixel = Self::Pixel>,
source§fn copy_within(&mut self, source: Rect, x: u32, y: u32) -> bool
fn copy_within(&mut self, source: Rect, x: u32, y: u32) -> bool
source§fn sub_image(
&mut self,
x: u32,
y: u32,
width: u32,
height: u32,
) -> SubImage<&mut Self>where
Self: Sized,
fn sub_image(
&mut self,
x: u32,
y: u32,
width: u32,
height: u32,
) -> SubImage<&mut Self>where
Self: Sized,
GenericImageView::view
The coordinates set the position of the top left corner of the SubImage.source§impl GenericImageView for DynamicImage
impl GenericImageView for DynamicImage
source§fn dimensions(&self) -> (u32, u32)
fn dimensions(&self) -> (u32, u32)
source§fn bounds(&self) -> (u32, u32, u32, u32)
fn bounds(&self) -> (u32, u32, u32, u32)
dimensions
insteadsource§fn get_pixel(&self, x: u32, y: u32) -> Rgba<u8>
fn get_pixel(&self, x: u32, y: u32) -> Rgba<u8>
source§fn in_bounds(&self, x: u32, y: u32) -> bool
fn in_bounds(&self, x: u32, y: u32) -> bool
source§unsafe fn unsafe_get_pixel(&self, x: u32, y: u32) -> Self::Pixel
unsafe fn unsafe_get_pixel(&self, x: u32, y: u32) -> Self::Pixel
source§fn pixels(&self) -> Pixels<'_, Self> ⓘwhere
Self: Sized,
fn pixels(&self) -> Pixels<'_, Self> ⓘwhere
Self: Sized,
source§fn view(&self, x: u32, y: u32, width: u32, height: u32) -> SubImage<&Self>where
Self: Sized,
fn view(&self, x: u32, y: u32, width: u32, height: u32) -> SubImage<&Self>where
Self: Sized,
GenericImage::sub_image
if you need a mutable view instead.
The coordinates set the position of the top left corner of the view.source§impl PartialEq for DynamicImage
impl PartialEq for DynamicImage
impl StructuralPartialEq for DynamicImage
Auto Trait Implementations§
impl Freeze for DynamicImage
impl RefUnwindSafe for DynamicImage
impl Send for DynamicImage
impl Sync for DynamicImage
impl Unpin for DynamicImage
impl UnwindSafe for DynamicImage
Blanket Implementations§
source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
source§impl<T, Res> Apply<Res> for Twhere
T: ?Sized,
impl<T, Res> Apply<Res> for Twhere
T: ?Sized,
source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
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<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters
when converting.source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self
into C
, using the provided parameters.source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle
.source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other
into Self
, while performing the appropriate scaling,
rounding and clamping.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
source§fn into_angle(self) -> U
fn into_angle(self) -> U
T
.source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters
when converting.source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self
into C
, using the provided parameters.source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
source§fn into_color(self) -> U
fn into_color(self) -> U
source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
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 moresource§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self
into T
, while performing the appropriate scaling,
rounding and clamping.source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors
fails to cast.source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds
error is returned which contains
the unclamped color. Read more