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>>),
}Expand description
A Dynamic Image
Variants§
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
Implementations§
Source§impl DynamicImage
impl DynamicImage
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 grey 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 grey 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 to_rgb(&self) -> ImageBuffer<Rgb<u8>, Vec<u8>>
pub fn to_rgb(&self) -> ImageBuffer<Rgb<u8>, Vec<u8>>
Returns a copy of this image as an RGB image.
Sourcepub fn to_rgba(&self) -> ImageBuffer<Rgba<u8>, Vec<u8>>
pub fn to_rgba(&self) -> ImageBuffer<Rgba<u8>, Vec<u8>>
Returns a copy of this image as an RGBA image.
Sourcepub fn to_luma(&self) -> ImageBuffer<Luma<u8>, Vec<u8>>
pub fn to_luma(&self) -> ImageBuffer<Luma<u8>, Vec<u8>>
Returns a copy of this image as a Luma image.
Sourcepub fn to_luma_alpha(&self) -> ImageBuffer<LumaA<u8>, Vec<u8>>
pub fn to_luma_alpha(&self) -> ImageBuffer<LumaA<u8>, Vec<u8>>
Returns a copy of this image as a LumaA image.
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.
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 raw_pixels(&self) -> Vec<u8> ⓘ
pub fn raw_pixels(&self) -> Vec<u8> ⓘ
Return this image’s pixels as a byte vector.
Sourcepub fn grayscale(&self) -> DynamicImage
pub fn grayscale(&self) -> DynamicImage
Return a grayscale version of this image.
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.
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 GenericImage for DynamicImage
impl GenericImage for DynamicImage
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>)
DEPRECATED: Use iterator pixels_mut to blend the pixels directly.
Source§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!
Source§fn dimensions(&self) -> (u32, u32)
fn dimensions(&self) -> (u32, u32)
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 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§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 pixels(&self) -> Pixels<'_, Self>
fn pixels(&self) -> Pixels<'_, Self>
Source§fn pixels_mut(&mut self) -> MutPixels<'_, Self>
fn pixels_mut(&mut self) -> MutPixels<'_, Self>
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<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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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