DynamicImage

Enum DynamicImage 

Source
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

Source

pub fn new_luma8(w: u32, h: u32) -> DynamicImage

Creates a dynamic image backed by a buffer of grey pixels.

Source

pub fn new_luma_a8(w: u32, h: u32) -> DynamicImage

Creates a dynamic image backed by a buffer of grey pixels with transparency.

Source

pub fn new_rgb8(w: u32, h: u32) -> DynamicImage

Creates a dynamic image backed by a buffer of RGB pixels.

Source

pub fn new_rgba8(w: u32, h: u32) -> DynamicImage

Creates a dynamic image backed by a buffer of RGBA pixels.

Source

pub fn to_rgb(&self) -> ImageBuffer<Rgb<u8>, Vec<u8>>

Returns a copy of this image as an RGB image.

Source

pub fn to_rgba(&self) -> ImageBuffer<Rgba<u8>, Vec<u8>>

Returns a copy of this image as an RGBA image.

Source

pub fn to_luma(&self) -> ImageBuffer<Luma<u8>, Vec<u8>>

Returns a copy of this image as a Luma image.

Source

pub fn to_luma_alpha(&self) -> ImageBuffer<LumaA<u8>, Vec<u8>>

Returns a copy of this image as a LumaA image.

Source

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.

Source

pub fn as_rgb8(&self) -> Option<&ImageBuffer<Rgb<u8>, Vec<u8>>>

Return a reference to an 8bit RGB image

Source

pub fn as_mut_rgb8(&mut self) -> Option<&mut ImageBuffer<Rgb<u8>, Vec<u8>>>

Return a mutable reference to an 8bit RGB image

Source

pub fn as_rgba8(&self) -> Option<&ImageBuffer<Rgba<u8>, Vec<u8>>>

Return a reference to an 8bit RGBA image

Source

pub fn as_mut_rgba8(&mut self) -> Option<&mut ImageBuffer<Rgba<u8>, Vec<u8>>>

Return a mutable reference to an 8bit RGBA image

Source

pub fn as_luma8(&self) -> Option<&ImageBuffer<Luma<u8>, Vec<u8>>>

Return a reference to an 8bit Grayscale image

Source

pub fn as_mut_luma8(&mut self) -> Option<&mut ImageBuffer<Luma<u8>, Vec<u8>>>

Return a mutable reference to an 8bit Grayscale image

Source

pub fn as_luma_alpha8(&self) -> Option<&ImageBuffer<LumaA<u8>, Vec<u8>>>

Return a reference to an 8bit Grayscale image with an alpha channel

Source

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

Source

pub fn raw_pixels(&self) -> Vec<u8>

Return this image’s pixels as a byte vector.

Source

pub fn color(&self) -> ColorType

Return this image’s color type.

Source

pub fn grayscale(&self) -> DynamicImage

Return a grayscale version of this image.

Source

pub fn invert(&mut self)

Invert the colors of this image. This method operates inplace.

Source

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.

Source

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

Source

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.

Source

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.

Source

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.

Source

pub fn blur(&self, sigma: f32) -> DynamicImage

Performs a Gaussian blur on this image. sigma is a measure of how much to blur by.

Source

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

Source

pub fn filter3x3(&self, kernel: &[f32]) -> DynamicImage

Filters this image with the specified 3x3 kernel.

Source

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.

Source

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.

Source

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)

Source

pub fn flipv(&self) -> DynamicImage

Flip this image vertically

Source

pub fn fliph(&self) -> DynamicImage

Flip this image horizontally

Source

pub fn rotate90(&self) -> DynamicImage

Rotate this image 90 degrees clockwise.

Source

pub fn rotate180(&self) -> DynamicImage

Rotate this image 180 degrees clockwise.

Source

pub fn rotate270(&self) -> DynamicImage

Rotate this image 270 degrees clockwise.

Source

pub fn write_to<W, F>(&self, w: &mut W, format: F) -> Result<(), ImageError>

Encode this image and write it to w

Source

pub fn save<Q>(&self, path: Q) -> Result<(), Error>
where Q: AsRef<Path>,

Saves the buffer to a file at the path specified.

The image format is derived from the file extension.

Trait Implementations§

Source§

impl Clone for DynamicImage

Source§

fn clone(&self) -> DynamicImage

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl GenericImage for DynamicImage

Source§

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>

DEPRECATED: Do not use is function: It is unimplemented!

Source§

type Pixel = Rgba<u8>

The type of pixel.
Source§

fn dimensions(&self) -> (u32, u32)

The width and height of this image.
Source§

fn bounds(&self) -> (u32, u32, u32, u32)

The bounding rectangle of this image.
Source§

fn get_pixel(&self, x: u32, y: u32) -> Rgba<u8>

Returns the pixel located at (x, y) Read more
Source§

fn put_pixel(&mut self, x: u32, y: u32, pixel: Rgba<u8>)

Put a pixel at location (x, y) Read more
Source§

fn width(&self) -> u32

The width of this image.
Source§

fn height(&self) -> u32

The height of this image.
Source§

fn in_bounds(&self, x: u32, y: u32) -> bool

Returns true if this x, y coordinate is contained inside the image.
Source§

unsafe fn unsafe_get_pixel(&self, x: u32, y: u32) -> Self::Pixel

Returns the pixel located at (x, y) Read more
Source§

unsafe fn unsafe_put_pixel(&mut self, x: u32, y: u32, pixel: Self::Pixel)

Puts a pixel at location (x, y) Read more
Source§

fn pixels(&self) -> Pixels<'_, Self>

Returns an Iterator over the pixels of this image. The iterator yields the coordinates of each pixel along with their value
Source§

fn pixels_mut(&mut self) -> MutPixels<'_, Self>

👎Deprecated: This cannot be implemented safely in Rust. Please use the image buffer directly.
Returns an Iterator over mutable pixels of this image. The iterator yields the coordinates of each pixel along with a mutable reference to them.
Source§

fn copy_from<O>(&mut self, other: &O, x: u32, y: u32) -> bool
where O: GenericImage<Pixel = Self::Pixel>,

Copies all of the pixels from another image into this image. Read more
Source§

fn sub_image( &mut self, x: u32, y: u32, width: u32, height: u32, ) -> SubImage<'_, Self>
where Self: 'static, <Self::Pixel as Pixel>::Subpixel: 'static, Self::Pixel: 'static,

Returns a subimage that is a view into this image.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> SetParameter for T

Source§

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result
where T: Parameter<Self>,

Sets value as a parameter of self.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.