Enum image::DynamicImage
source · pub enum DynamicImage {
ImageLuma8(GrayImage),
ImageLumaA8(GrayAlphaImage),
ImageRgb8(RgbImage),
ImageRgba8(RgbaImage),
ImageBgr8(ImageBuffer<Bgr<u8>, Vec<u8>>),
ImageBgra8(ImageBuffer<Bgra<u8>, Vec<u8>>),
}
Expand description
A Dynamic Image
Variants
ImageLuma8(GrayImage)
Each pixel in this image is 8-bit Luma
ImageLumaA8(GrayAlphaImage)
Each pixel in this image is 8-bit Luma with alpha
ImageRgb8(RgbImage)
Each pixel in this image is 8-bit Rgb
ImageRgba8(RgbaImage)
Each pixel in this image is 8-bit Rgb with alpha
ImageBgr8(ImageBuffer<Bgr<u8>, Vec<u8>>)
Each pixel in this image is 8-bit Bgr
ImageBgra8(ImageBuffer<Bgra<u8>, Vec<u8>>)
Each pixel in this image is 8-bit Bgr with alpha
Implementations
sourceimpl 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 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.
sourcepub 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.
sourcepub fn to_bgr(&self) -> ImageBuffer<Bgr<u8>, Vec<u8>>
pub fn to_bgr(&self) -> ImageBuffer<Bgr<u8>, Vec<u8>>
Returns a copy of this image as an BGR image.
sourcepub fn to_bgra(&self) -> ImageBuffer<Bgra<u8>, Vec<u8>>
pub fn to_bgra(&self) -> ImageBuffer<Bgra<u8>, Vec<u8>>
Returns a copy of this image as an RGBA image.
sourcepub fn to_luma_alpha(&self) -> GrayAlphaImage
pub fn to_luma_alpha(&self) -> GrayAlphaImage
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_mut_rgb8(&mut self) -> Option<&mut RgbImage>
pub fn as_mut_rgb8(&mut self) -> Option<&mut RgbImage>
Return a mutable reference to an 8bit RGB image
sourcepub fn as_bgr8(&self) -> Option<&ImageBuffer<Bgr<u8>, Vec<u8>>>
pub fn as_bgr8(&self) -> Option<&ImageBuffer<Bgr<u8>, Vec<u8>>>
Return a reference to an 8bit BGR image
sourcepub fn as_mut_bgr8(&mut self) -> Option<&mut ImageBuffer<Bgr<u8>, Vec<u8>>>
pub fn as_mut_bgr8(&mut self) -> Option<&mut ImageBuffer<Bgr<u8>, Vec<u8>>>
Return a mutable reference to an 8bit BGR image
sourcepub fn as_mut_rgba8(&mut self) -> Option<&mut RgbaImage>
pub fn as_mut_rgba8(&mut self) -> Option<&mut RgbaImage>
Return a mutable reference to an 8bit RGBA image
sourcepub fn as_bgra8(&self) -> Option<&ImageBuffer<Bgra<u8>, Vec<u8>>>
pub fn as_bgra8(&self) -> Option<&ImageBuffer<Bgra<u8>, Vec<u8>>>
Return a reference to an 8bit BGRA image
sourcepub fn as_mut_bgra8(&mut self) -> Option<&mut ImageBuffer<Bgra<u8>, Vec<u8>>>
pub fn as_mut_bgra8(&mut self) -> Option<&mut ImageBuffer<Bgra<u8>, Vec<u8>>>
Return a mutable reference to an 8bit RGBA image
sourcepub fn as_mut_luma8(&mut self) -> Option<&mut GrayImage>
pub fn as_mut_luma8(&mut self) -> Option<&mut GrayImage>
Return a mutable reference to an 8bit Grayscale image
sourcepub fn as_luma_alpha8(&self) -> Option<&GrayAlphaImage>
pub fn as_luma_alpha8(&self) -> Option<&GrayAlphaImage>
Return a reference to an 8bit Grayscale image with an alpha channel
sourcepub fn as_mut_luma_alpha8(&mut self) -> Option<&mut GrayAlphaImage>
pub fn as_mut_luma_alpha8(&mut self) -> Option<&mut GrayAlphaImage>
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.
sourcepub fn write_to<W: Write, F: Into<ImageOutputFormat>>(
&self,
w: &mut W,
format: F
) -> ImageResult<()>
pub fn write_to<W: Write, F: Into<ImageOutputFormat>>(
&self,
w: &mut W,
format: F
) -> ImageResult<()>
Encode this image and write it to w
Trait Implementations
sourceimpl Clone for DynamicImage
impl Clone for DynamicImage
sourcefn clone(&self) -> DynamicImage
fn clone(&self) -> DynamicImage
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl GenericImage for DynamicImage
impl GenericImage for DynamicImage
sourcefn 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.
sourcefn 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!