Enum matrix_qrcode::image::DynamicImage
[−]pub enum DynamicImage {
ImageLuma8(ImageBuffer<Luma<u8>, Vec<u8, Global>>),
ImageLumaA8(ImageBuffer<LumaA<u8>, Vec<u8, Global>>),
ImageRgb8(ImageBuffer<Rgb<u8>, Vec<u8, Global>>),
ImageRgba8(ImageBuffer<Rgba<u8>, Vec<u8, Global>>),
ImageBgr8(ImageBuffer<Bgr<u8>, Vec<u8, Global>>),
ImageBgra8(ImageBuffer<Bgra<u8>, Vec<u8, Global>>),
ImageLuma16(ImageBuffer<Luma<u16>, Vec<u16, Global>>),
ImageLumaA16(ImageBuffer<LumaA<u16>, Vec<u16, Global>>),
ImageRgb16(ImageBuffer<Rgb<u16>, Vec<u16, Global>>),
ImageRgba16(ImageBuffer<Rgba<u16>, Vec<u16, Global>>),
}
Expand description
A Dynamic Image
Variants
ImageLuma8(ImageBuffer<Luma<u8>, Vec<u8, Global>>)
Each pixel in this image is 8-bit Luma
ImageLumaA8(ImageBuffer<LumaA<u8>, Vec<u8, Global>>)
Each pixel in this image is 8-bit Luma with alpha
ImageRgb8(ImageBuffer<Rgb<u8>, Vec<u8, Global>>)
Each pixel in this image is 8-bit Rgb
ImageRgba8(ImageBuffer<Rgba<u8>, Vec<u8, Global>>)
Each pixel in this image is 8-bit Rgb with alpha
ImageBgr8(ImageBuffer<Bgr<u8>, Vec<u8, Global>>)
Each pixel in this image is 8-bit Bgr
ImageBgra8(ImageBuffer<Bgra<u8>, Vec<u8, Global>>)
Each pixel in this image is 8-bit Bgr with alpha
ImageLuma16(ImageBuffer<Luma<u16>, Vec<u16, Global>>)
Each pixel in this image is 16-bit Luma
ImageLumaA16(ImageBuffer<LumaA<u16>, Vec<u16, Global>>)
Each pixel in this image is 16-bit Luma with alpha
ImageRgb16(ImageBuffer<Rgb<u16>, Vec<u16, Global>>)
Each pixel in this image is 16-bit Rgb
ImageRgba16(ImageBuffer<Rgba<u16>, Vec<u16, Global>>)
Each pixel in this image is 16-bit Rgb with alpha
Implementations
impl DynamicImage
impl DynamicImage
pub 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 grey pixels.
pub 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 grey pixels with transparency.
pub 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.
pub 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.
pub fn new_bgra8(w: u32, h: u32) -> DynamicImage
pub fn new_bgra8(w: u32, h: u32) -> DynamicImage
Creates a dynamic image backed by a buffer of BGRA pixels.
pub fn new_bgr8(w: u32, h: u32) -> DynamicImage
pub fn new_bgr8(w: u32, h: u32) -> DynamicImage
Creates a dynamic image backed by a buffer of BGR pixels.
pub 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 grey pixels.
pub 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 grey pixels with transparency.
pub 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.
pub 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.
pub 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.
pub fn to_rgb(&self) -> ImageBuffer<Rgb<u8>, Vec<u8, Global>>
👎 Deprecated: replaced by to_rgb8
pub fn to_rgb(&self) -> ImageBuffer<Rgb<u8>, Vec<u8, Global>>
replaced by to_rgb8
Returns a copy of this image as an RGB image.
pub fn to_rgb8(&self) -> ImageBuffer<Rgb<u8>, Vec<u8, Global>>
pub fn to_rgb8(&self) -> ImageBuffer<Rgb<u8>, Vec<u8, Global>>
Returns a copy of this image as an RGB image.
pub fn to_rgb16(&self) -> ImageBuffer<Rgb<u16>, Vec<u16, Global>>
pub fn to_rgb16(&self) -> ImageBuffer<Rgb<u16>, Vec<u16, Global>>
Returns a copy of this image as an RGB image.
pub fn to_rgba(&self) -> ImageBuffer<Rgba<u8>, Vec<u8, Global>>
👎 Deprecated: replaced by to_rgba8
pub fn to_rgba(&self) -> ImageBuffer<Rgba<u8>, Vec<u8, Global>>
replaced by to_rgba8
Returns a copy of this image as an RGBA image.
pub fn to_rgba8(&self) -> ImageBuffer<Rgba<u8>, Vec<u8, Global>>
pub fn to_rgba8(&self) -> ImageBuffer<Rgba<u8>, Vec<u8, Global>>
Returns a copy of this image as an RGBA image.
pub fn to_rgba16(&self) -> ImageBuffer<Rgba<u16>, Vec<u16, Global>>
pub fn to_rgba16(&self) -> ImageBuffer<Rgba<u16>, Vec<u16, Global>>
Returns a copy of this image as an RGBA image.
pub fn to_bgr(&self) -> ImageBuffer<Bgr<u8>, Vec<u8, Global>>
👎 Deprecated: replaced by to_bgr8
pub fn to_bgr(&self) -> ImageBuffer<Bgr<u8>, Vec<u8, Global>>
replaced by to_bgr8
Returns a copy of this image as an BGR image.
pub fn to_bgr8(&self) -> ImageBuffer<Bgr<u8>, Vec<u8, Global>>
pub fn to_bgr8(&self) -> ImageBuffer<Bgr<u8>, Vec<u8, Global>>
Returns a copy of this image as an BGR image.
pub fn to_bgra(&self) -> ImageBuffer<Bgra<u8>, Vec<u8, Global>>
👎 Deprecated: replaced by to_bgra8
pub fn to_bgra(&self) -> ImageBuffer<Bgra<u8>, Vec<u8, Global>>
replaced by to_bgra8
Returns a copy of this image as an BGRA image.
pub fn to_bgra8(&self) -> ImageBuffer<Bgra<u8>, Vec<u8, Global>>
pub fn to_bgra8(&self) -> ImageBuffer<Bgra<u8>, Vec<u8, Global>>
Returns a copy of this image as an BGRA image.
pub fn to_luma(&self) -> ImageBuffer<Luma<u8>, Vec<u8, Global>>
👎 Deprecated: replaced by to_luma8
pub fn to_luma(&self) -> ImageBuffer<Luma<u8>, Vec<u8, Global>>
replaced by to_luma8
Returns a copy of this image as a Luma image.
pub fn to_luma8(&self) -> ImageBuffer<Luma<u8>, Vec<u8, Global>>
pub fn to_luma8(&self) -> ImageBuffer<Luma<u8>, Vec<u8, Global>>
Returns a copy of this image as a Luma image.
pub fn to_luma16(&self) -> ImageBuffer<Luma<u16>, Vec<u16, Global>>
pub fn to_luma16(&self) -> ImageBuffer<Luma<u16>, Vec<u16, Global>>
Returns a copy of this image as a Luma image.
pub fn to_luma_alpha(&self) -> ImageBuffer<LumaA<u8>, Vec<u8, Global>>
👎 Deprecated: replaced by to_luma_alpha8
pub fn to_luma_alpha(&self) -> ImageBuffer<LumaA<u8>, Vec<u8, Global>>
replaced by to_luma_alpha8
Returns a copy of this image as a LumaA image.
pub fn to_luma_alpha8(&self) -> ImageBuffer<LumaA<u8>, Vec<u8, Global>>
pub fn to_luma_alpha8(&self) -> ImageBuffer<LumaA<u8>, Vec<u8, Global>>
Returns a copy of this image as a LumaA image.
pub fn to_luma_alpha16(&self) -> ImageBuffer<LumaA<u16>, Vec<u16, Global>>
pub fn to_luma_alpha16(&self) -> ImageBuffer<LumaA<u16>, Vec<u16, Global>>
Returns a copy of this image as a LumaA image.
pub fn into_rgb(self) -> ImageBuffer<Rgb<u8>, Vec<u8, Global>>
👎 Deprecated: replaced by into_rgb8
pub fn into_rgb(self) -> ImageBuffer<Rgb<u8>, Vec<u8, Global>>
replaced by into_rgb8
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.
pub fn into_rgb8(self) -> ImageBuffer<Rgb<u8>, Vec<u8, Global>>
pub fn into_rgb8(self) -> ImageBuffer<Rgb<u8>, Vec<u8, Global>>
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.
pub fn into_rgb16(self) -> ImageBuffer<Rgb<u16>, Vec<u16, Global>>
pub fn into_rgb16(self) -> ImageBuffer<Rgb<u16>, Vec<u16, Global>>
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.
pub fn into_rgba(self) -> ImageBuffer<Rgba<u8>, Vec<u8, Global>>
👎 Deprecated: replaced by into_rgba8
pub fn into_rgba(self) -> ImageBuffer<Rgba<u8>, Vec<u8, Global>>
replaced by into_rgba8
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.
pub fn into_rgba8(self) -> ImageBuffer<Rgba<u8>, Vec<u8, Global>>
pub fn into_rgba8(self) -> ImageBuffer<Rgba<u8>, Vec<u8, Global>>
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.
pub fn into_rgba16(self) -> ImageBuffer<Rgba<u16>, Vec<u16, Global>>
pub fn into_rgba16(self) -> ImageBuffer<Rgba<u16>, Vec<u16, Global>>
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.
pub fn into_bgr(self) -> ImageBuffer<Bgr<u8>, Vec<u8, Global>>
👎 Deprecated: replaced by into_bgra8
pub fn into_bgr(self) -> ImageBuffer<Bgr<u8>, Vec<u8, Global>>
replaced by into_bgra8
Consume the image and returns a BGR image.
If the image was already the correct format, it is returned as is. Otherwise, a copy is created.
pub fn into_bgr8(self) -> ImageBuffer<Bgr<u8>, Vec<u8, Global>>
pub fn into_bgr8(self) -> ImageBuffer<Bgr<u8>, Vec<u8, Global>>
Consume the image and returns a BGR image.
If the image was already the correct format, it is returned as is. Otherwise, a copy is created.
pub fn into_bgra(self) -> ImageBuffer<Bgra<u8>, Vec<u8, Global>>
👎 Deprecated: replaced by into_bgra8
pub fn into_bgra(self) -> ImageBuffer<Bgra<u8>, Vec<u8, Global>>
replaced by into_bgra8
Consume the image and returns a BGRA image.
If the image was already the correct format, it is returned as is. Otherwise, a copy is created.
pub fn into_bgra8(self) -> ImageBuffer<Bgra<u8>, Vec<u8, Global>>
pub fn into_bgra8(self) -> ImageBuffer<Bgra<u8>, Vec<u8, Global>>
Consume the image and returns a BGRA image.
If the image was already the correct format, it is returned as is. Otherwise, a copy is created.
pub fn into_luma(self) -> ImageBuffer<Luma<u8>, Vec<u8, Global>>
👎 Deprecated: replaced by into_luma8
pub fn into_luma(self) -> ImageBuffer<Luma<u8>, Vec<u8, Global>>
replaced by into_luma8
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.
pub fn into_luma8(self) -> ImageBuffer<Luma<u8>, Vec<u8, Global>>
pub fn into_luma8(self) -> ImageBuffer<Luma<u8>, Vec<u8, Global>>
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.
pub fn into_luma16(self) -> ImageBuffer<Luma<u16>, Vec<u16, Global>>
pub fn into_luma16(self) -> ImageBuffer<Luma<u16>, Vec<u16, Global>>
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.
pub fn into_luma_alpha(self) -> ImageBuffer<LumaA<u8>, Vec<u8, Global>>
👎 Deprecated: replaced by into_luma_alpha8
pub fn into_luma_alpha(self) -> ImageBuffer<LumaA<u8>, Vec<u8, Global>>
replaced by into_luma_alpha8
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.
pub fn into_luma_alpha8(self) -> ImageBuffer<LumaA<u8>, Vec<u8, Global>>
pub fn into_luma_alpha8(self) -> ImageBuffer<LumaA<u8>, Vec<u8, Global>>
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.
pub fn into_luma_alpha16(self) -> ImageBuffer<LumaA<u16>, Vec<u16, Global>>
pub fn into_luma_alpha16(self) -> ImageBuffer<LumaA<u16>, Vec<u16, Global>>
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.
pub 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
pub 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.
pub fn as_rgb8(&self) -> Option<&ImageBuffer<Rgb<u8>, Vec<u8, Global>>>
pub fn as_rgb8(&self) -> Option<&ImageBuffer<Rgb<u8>, Vec<u8, Global>>>
Return a reference to an 8bit RGB image
pub fn as_mut_rgb8(
&mut self
) -> Option<&mut ImageBuffer<Rgb<u8>, Vec<u8, Global>>>
pub fn as_mut_rgb8(
&mut self
) -> Option<&mut ImageBuffer<Rgb<u8>, Vec<u8, Global>>>
Return a mutable reference to an 8bit RGB image
pub fn as_bgr8(&self) -> Option<&ImageBuffer<Bgr<u8>, Vec<u8, Global>>>
pub fn as_bgr8(&self) -> Option<&ImageBuffer<Bgr<u8>, Vec<u8, Global>>>
Return a reference to an 8bit BGR image
pub fn as_mut_bgr8(
&mut self
) -> Option<&mut ImageBuffer<Bgr<u8>, Vec<u8, Global>>>
pub fn as_mut_bgr8(
&mut self
) -> Option<&mut ImageBuffer<Bgr<u8>, Vec<u8, Global>>>
Return a mutable reference to an 8bit BGR image
pub fn as_rgba8(&self) -> Option<&ImageBuffer<Rgba<u8>, Vec<u8, Global>>>
pub fn as_rgba8(&self) -> Option<&ImageBuffer<Rgba<u8>, Vec<u8, Global>>>
Return a reference to an 8bit RGBA image
pub fn as_mut_rgba8(
&mut self
) -> Option<&mut ImageBuffer<Rgba<u8>, Vec<u8, Global>>>
pub fn as_mut_rgba8(
&mut self
) -> Option<&mut ImageBuffer<Rgba<u8>, Vec<u8, Global>>>
Return a mutable reference to an 8bit RGBA image
pub fn as_bgra8(&self) -> Option<&ImageBuffer<Bgra<u8>, Vec<u8, Global>>>
pub fn as_bgra8(&self) -> Option<&ImageBuffer<Bgra<u8>, Vec<u8, Global>>>
Return a reference to an 8bit BGRA image
pub fn as_mut_bgra8(
&mut self
) -> Option<&mut ImageBuffer<Bgra<u8>, Vec<u8, Global>>>
pub fn as_mut_bgra8(
&mut self
) -> Option<&mut ImageBuffer<Bgra<u8>, Vec<u8, Global>>>
Return a mutable reference to an 8bit RGBA image
pub fn as_luma8(&self) -> Option<&ImageBuffer<Luma<u8>, Vec<u8, Global>>>
pub fn as_luma8(&self) -> Option<&ImageBuffer<Luma<u8>, Vec<u8, Global>>>
Return a reference to an 8bit Grayscale image
pub fn as_mut_luma8(
&mut self
) -> Option<&mut ImageBuffer<Luma<u8>, Vec<u8, Global>>>
pub fn as_mut_luma8(
&mut self
) -> Option<&mut ImageBuffer<Luma<u8>, Vec<u8, Global>>>
Return a mutable reference to an 8bit Grayscale image
pub fn as_luma_alpha8(&self) -> Option<&ImageBuffer<LumaA<u8>, Vec<u8, Global>>>
pub fn as_luma_alpha8(&self) -> Option<&ImageBuffer<LumaA<u8>, Vec<u8, Global>>>
Return a reference to an 8bit Grayscale image with an alpha channel
pub fn as_mut_luma_alpha8(
&mut self
) -> Option<&mut ImageBuffer<LumaA<u8>, Vec<u8, Global>>>
pub fn as_mut_luma_alpha8(
&mut self
) -> Option<&mut ImageBuffer<LumaA<u8>, Vec<u8, Global>>>
Return a mutable reference to an 8bit Grayscale image with an alpha channel
pub fn as_rgb16(&self) -> Option<&ImageBuffer<Rgb<u16>, Vec<u16, Global>>>
pub fn as_rgb16(&self) -> Option<&ImageBuffer<Rgb<u16>, Vec<u16, Global>>>
Return a reference to an 16bit RGB image
pub fn as_mut_rgb16(
&mut self
) -> Option<&mut ImageBuffer<Rgb<u16>, Vec<u16, Global>>>
pub fn as_mut_rgb16(
&mut self
) -> Option<&mut ImageBuffer<Rgb<u16>, Vec<u16, Global>>>
Return a mutable reference to an 16bit RGB image
pub fn as_rgba16(&self) -> Option<&ImageBuffer<Rgba<u16>, Vec<u16, Global>>>
pub fn as_rgba16(&self) -> Option<&ImageBuffer<Rgba<u16>, Vec<u16, Global>>>
Return a reference to an 16bit RGBA image
pub fn as_mut_rgba16(
&mut self
) -> Option<&mut ImageBuffer<Rgba<u16>, Vec<u16, Global>>>
pub fn as_mut_rgba16(
&mut self
) -> Option<&mut ImageBuffer<Rgba<u16>, Vec<u16, Global>>>
Return a mutable reference to an 16bit RGBA image
pub fn as_luma16(&self) -> Option<&ImageBuffer<Luma<u16>, Vec<u16, Global>>>
pub fn as_luma16(&self) -> Option<&ImageBuffer<Luma<u16>, Vec<u16, Global>>>
Return a reference to an 16bit Grayscale image
pub fn as_mut_luma16(
&mut self
) -> Option<&mut ImageBuffer<Luma<u16>, Vec<u16, Global>>>
pub fn as_mut_luma16(
&mut self
) -> Option<&mut ImageBuffer<Luma<u16>, Vec<u16, Global>>>
Return a mutable reference to an 16bit Grayscale image
pub fn as_luma_alpha16(
&self
) -> Option<&ImageBuffer<LumaA<u16>, Vec<u16, Global>>>
pub fn as_luma_alpha16(
&self
) -> Option<&ImageBuffer<LumaA<u16>, Vec<u16, Global>>>
Return a reference to an 16bit Grayscale image with an alpha channel
pub fn as_mut_luma_alpha16(
&mut self
) -> Option<&mut ImageBuffer<LumaA<u16>, Vec<u16, Global>>>
pub fn as_mut_luma_alpha16(
&mut self
) -> Option<&mut ImageBuffer<LumaA<u16>, Vec<u16, Global>>>
Return a mutable reference to an 16bit Grayscale image with an alpha channel
pub 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.
pub 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.
pub fn as_bytes(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn as_bytes(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Return this image’s pixels as a native endian byte slice.
pub fn into_bytes(self) -> Vec<u8, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn into_bytes(self) -> Vec<u8, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
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.
pub fn to_bytes(&self) -> Vec<u8, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn to_bytes(&self) -> Vec<u8, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Return a copy of this image’s pixels as a byte vector.
pub fn grayscale(&self) -> DynamicImage
pub fn grayscale(&self) -> DynamicImage
Return a grayscale version of this image.
pub fn invert(&mut self)
pub fn invert(&mut self)
Invert the colors of this image. This method operates inplace.
pub 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
.
pub 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
pub 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.
pub 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.
pub 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.
pub 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.
pub 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
pub fn filter3x3(&self, kernel: &[f32]) -> DynamicImage
pub fn filter3x3(&self, kernel: &[f32]) -> DynamicImage
Filters this image with the specified 3x3 kernel.
pub 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.
pub 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.
pub 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)
pub fn flipv(&self) -> DynamicImage
pub fn flipv(&self) -> DynamicImage
Flip this image vertically
pub fn fliph(&self) -> DynamicImage
pub fn fliph(&self) -> DynamicImage
Flip this image horizontally
pub fn rotate90(&self) -> DynamicImage
pub fn rotate90(&self) -> DynamicImage
Rotate this image 90 degrees clockwise.
pub fn rotate180(&self) -> DynamicImage
pub fn rotate180(&self) -> DynamicImage
Rotate this image 180 degrees clockwise.
pub fn rotate270(&self) -> DynamicImage
pub fn rotate270(&self) -> DynamicImage
Rotate this image 270 degrees clockwise.
pub fn write_to<W, F>(&self, w: &mut W, format: F) -> Result<(), ImageError> where
W: Write,
F: Into<ImageOutputFormat>,
pub fn write_to<W, F>(&self, w: &mut W, format: F) -> Result<(), ImageError> where
W: Write,
F: Into<ImageOutputFormat>,
Encode this image and write it to w
pub fn save<Q>(&self, path: Q) -> Result<(), ImageError> where
Q: AsRef<Path>,
pub fn save<Q>(&self, path: Q) -> Result<(), ImageError> where
Q: AsRef<Path>,
Saves the buffer to a file at the path specified.
The image format is derived from the file extension.
pub fn save_with_format<Q>(
&self,
path: Q,
format: ImageFormat
) -> Result<(), ImageError> where
Q: AsRef<Path>,
pub fn save_with_format<Q>(
&self,
path: Q,
format: ImageFormat
) -> Result<(), ImageError> where
Q: AsRef<Path>,
Saves the buffer to a file at the specified path in the specified format.
See save_buffer_with_format
for
supported types.
Trait Implementations
impl Clone for DynamicImage
impl Clone for DynamicImage
fn clone(&self) -> DynamicImage
fn clone(&self) -> DynamicImage
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for DynamicImage
impl Debug for DynamicImage
impl GenericImage for DynamicImage
impl GenericImage for DynamicImage
fn blend_pixel(&mut self, x: u32, y: u32, pixel: Rgba<u8>)
fn blend_pixel(&mut self, x: u32, y: u32, pixel: Rgba<u8>)
DEPRECATED: Use iterator pixels_mut
to blend the pixels directly.
fn get_pixel_mut(&mut self, u32, u32) -> &mut Rgba<u8>
fn get_pixel_mut(&mut self, u32, u32) -> &mut Rgba<u8>
DEPRECATED: Do not use is function: It is unimplemented!
type InnerImage = DynamicImage
type InnerImage = DynamicImage
Underlying image type. This is mainly used by SubImages in order to always have a reference to the original image. This allows for less indirections and it eases the use of nested SubImages. Read more
fn put_pixel(&mut self, x: u32, y: u32, pixel: Rgba<u8>)
fn put_pixel(&mut self, x: u32, y: u32, pixel: Rgba<u8>)
Put a pixel at location (x, y). Indexed from top left. Read more
fn inner_mut(&mut self) -> &mut <DynamicImage as GenericImage>::InnerImage
fn inner_mut(&mut self) -> &mut <DynamicImage as GenericImage>::InnerImage
Returns a mutable reference to the underlying image.
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)
Puts a pixel at location (x, y). Indexed from top left. Read more
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>,
Copies all of the pixels from another image into this image. Read more
fn copy_within(&mut self, source: Rect, x: u32, y: u32) -> bool
fn copy_within(&mut self, source: Rect, x: u32, y: u32) -> bool
Copies all of the pixels from one part of this image to another part of this image. Read more
fn sub_image(
&mut self,
x: u32,
y: u32,
width: u32,
height: u32
) -> SubImage<&mut Self::InnerImage>
fn sub_image(
&mut self,
x: u32,
y: u32,
width: u32,
height: u32
) -> SubImage<&mut Self::InnerImage>
Returns a mutable subimage that is a view into this image.
If you want an immutable subimage instead, use GenericImageView::view
The coordinates set the position of the top left corner of the SubImage. Read more
impl GenericImageView for DynamicImage
impl GenericImageView for DynamicImage
type InnerImageView = DynamicImage
type InnerImageView = DynamicImage
Underlying image type. This is mainly used by SubImages in order to always have a reference to the original image. This allows for less indirections and it eases the use of nested SubImages. Read more
fn dimensions(&self) -> (u32, u32)
fn dimensions(&self) -> (u32, u32)
The width and height of this image.
fn get_pixel(&self, x: u32, y: u32) -> Rgba<u8>
fn get_pixel(&self, x: u32, y: u32) -> Rgba<u8>
Returns the pixel located at (x, y). Indexed from top left. Read more
fn inner(&self) -> &<DynamicImage as GenericImageView>::InnerImageView
fn inner(&self) -> &<DynamicImage as GenericImageView>::InnerImageView
Returns a reference to the underlying image.
fn in_bounds(&self, x: u32, y: u32) -> bool
fn in_bounds(&self, x: u32, y: u32) -> bool
Returns true if this x, y coordinate is contained inside the image.
unsafe fn unsafe_get_pixel(&self, x: u32, y: u32) -> Self::Pixel
unsafe fn unsafe_get_pixel(&self, x: u32, y: u32) -> Self::Pixel
Returns the pixel located at (x, y). Indexed from top left. Read more
fn pixels(&self) -> Pixels<'_, Self>ⓘNotable traits for Pixels<'a, I>impl<'a, I> Iterator for Pixels<'a, I> where
I: GenericImageView, type Item = (u32, u32, <I as GenericImageView>::Pixel);
fn pixels(&self) -> Pixels<'_, Self>ⓘNotable traits for Pixels<'a, I>impl<'a, I> Iterator for Pixels<'a, I> where
I: GenericImageView, type Item = (u32, u32, <I as GenericImageView>::Pixel);
I: GenericImageView, type Item = (u32, u32, <I as GenericImageView>::Pixel);
Returns an Iterator over the pixels of this image. The iterator yields the coordinates of each pixel along with their value Read more
fn view(
&self,
x: u32,
y: u32,
width: u32,
height: u32
) -> SubImage<&Self::InnerImageView>
fn view(
&self,
x: u32,
y: u32,
width: u32,
height: u32
) -> SubImage<&Self::InnerImageView>
Returns an subimage that is an immutable view into this image.
You can use GenericImage::sub_image
if you need a mutable view instead.
The coordinates set the position of the top left corner of the view. Read more
impl Hash for DynamicImage
impl Hash for DynamicImage
impl PartialEq<DynamicImage> for DynamicImage
impl PartialEq<DynamicImage> for DynamicImage
fn eq(&self, other: &DynamicImage) -> bool
fn eq(&self, other: &DynamicImage) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
fn ne(&self, other: &DynamicImage) -> bool
fn ne(&self, other: &DynamicImage) -> bool
This method tests for !=
.
sourceimpl TryFrom<DynamicImage> for QrVerificationData
impl TryFrom<DynamicImage> for QrVerificationData
type Error = DecodingError
type Error = DecodingError
The type returned in the event of a conversion error.
sourcefn try_from(
image: DynamicImage
) -> Result<QrVerificationData, <QrVerificationData as TryFrom<DynamicImage>>::Error>
fn try_from(
image: DynamicImage
) -> Result<QrVerificationData, <QrVerificationData as TryFrom<DynamicImage>>::Error>
Performs the conversion.
impl Eq for DynamicImage
impl StructuralEq for DynamicImage
impl StructuralPartialEq for DynamicImage
Auto Trait Implementations
impl RefUnwindSafe for DynamicImage
impl Send for DynamicImage
impl Sync for DynamicImage
impl Unpin for DynamicImage
impl UnwindSafe for DynamicImage
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more