Struct Image

Source
pub struct Image<P: Pixel> {
    pub data: Vec<P>,
    /* private fields */
}
Expand description

A high-level image representation.

This represents a static, single-frame image. See crate::ImageSequence for information on opening animated or multi-frame images.

Fields§

§data: Vec<P>

A 1-dimensional vector of pixels representing all pixels in the image. This is shaped according to the image’s width and height to form the image.

This data is a low-level, raw representation of the image. You can see the various pixel mapping functions, or use the pixels method directly for higher level representations of the data.

Implementations§

Source§

impl<P: Pixel> Image<P>

Source

pub fn new(width: u32, height: u32, fill: P) -> Self

Creates a new image with the given width and height, with all pixels being set intially to fill.

Both the width and height must be non-zero, or else this will panic. You should validate the width and height before calling this function.

§Panics
  • width or height is zero.
§Example
// 16x16 RGB image with all pixels set to white
let image = Image::new(16, 16, Rgb::white());

assert_eq!(image.width(), 16);
assert_eq!(image.height(), 16);
assert_eq!(image.pixel(0, 0), &Rgb::white());
Source

pub fn from_fn(width: u32, height: u32, f: impl Fn(u32, u32) -> P) -> Self

Creates a new image with the given width and height. The pixels are then resolved through then given callback function which takes two parameters (the x and y coordinates of each pixel) and returns a pixel.

§Example
let gradient = Image::from_fn(256, 256, |x, _y| L(x as u8));

assert_eq!(gradient.pixel(0, 0), &L(0));
assert_eq!(gradient.pixel(255, 0), &L(255));
Source

pub fn from_pixels(width: u32, pixels: impl AsRef<[P]>) -> Self

Creates a new image shaped with the given width and a 1-dimensional sequence of pixels which will be shaped according to the width.

§Panics
  • The length of the pixels is not a multiple of the width.
§Example
let image = Image::from_pixels(2, &[L(0), L(1), L(2), L(3)]);

assert_eq!(image.width(), 2);
assert_eq!(image.height(), 2);
assert_eq!(image.pixel(1, 1), &L(3));
Source

pub fn from_paletted_pixels<'p>( width: u32, palette: impl ToOwned<Owned = Vec<P::Color>> + 'p, pixels: impl AsRef<[P::Subpixel]>, ) -> Self
where P: Paletted<'p>,

Creates a new image shaped with the given width and a 1-dimensional sequence of paletted pixels which will be shaped according to the width.

§Panics
  • The length of the pixels is not a multiple of the width.
  • The palette is empty.
  • The a pixel index is out of bounds with regards to the palette.
§Example
let image = Image::<PalettedRgb>::from_paletted_pixels(
    2,
    vec![Rgb::white(), Rgb::black()],
    &[0, 1, 0, 1],
);
assert_eq!(image.pixel(1, 1).color(), Rgb::black());
Source

pub fn from_reader(format: ImageFormat, bytes: impl Read) -> Result<Self>

Decodes an image with the explicitly given image encoding from the raw byte stream.

§Errors
  • DecodingError: The image could not be decoded, maybe it is corrupt.
§Example
let file = std::fs::File::open("image.png")?;
let image = Image::<Rgb>::from_reader(ImageFormat::Png, file)?;
Source

pub fn from_reader_inferred(bytes: impl Read) -> Result<Self>

Decodes an image from the given read stream of bytes, inferring its encoding.

§Errors
  • DecodingError: The image could not be decoded, maybe it is corrupt.
  • UnknownEncodingFormat: Could not infer the encoding from the image. Try explicitly specifying it.
§Panics
  • No decoder implementation for the given encoding format.
§Example
let file = std::fs::File::open("image.png")?;
let image = Image::<Rgb>::from_reader_inferred(file)?;
Source

pub fn from_bytes(format: ImageFormat, bytes: impl AsRef<[u8]>) -> Result<Self>

Decodes an image with the explicitly given image encoding from the given bytes. Could be useful in conjunction with the include_bytes! macro.

Currently, this is not any different from [from_reader].

§Errors
  • DecodingError: The image could not be decoded, maybe it is corrupt.
§Panics
  • No decoder implementation for the given encoding format.
§Examples
let bytes = include_bytes!("sample.png") as &[u8];
let image = Image::<Rgb>::from_bytes(ImageFormat::Png, bytes)?;
Source

pub fn from_bytes_inferred(bytes: impl AsRef<[u8]>) -> Result<Self>

Decodes an image from the given bytes, inferring its encoding. Could be useful in conjunction with the include_bytes! macro.

This is more efficient than [from_reader_inferred].

§Errors
  • DecodingError: The image could not be decoded, maybe it is corrupt.
  • UnknownEncodingFormat: Could not infer the encoding from the image. Try explicitly specifying it.
§Panics
  • No decoder implementation for the given encoding format.
§Examples
let bytes = include_bytes!("sample.png") as &[u8];
let image = Image::<Rgb>::from_bytes_inferred(bytes)?;
Source

pub fn open(path: impl AsRef<Path>) -> Result<Self>

Opens a file from the given path and decodes it into an image.

The encoding of the image is automatically inferred. You can explicitly pass in an encoding by using the [from_reader] method.

§Errors
  • DecodingError: The image could not be decoded, maybe it is corrupt.
  • UnknownEncodingFormat: Could not infer the encoding from the image. Try explicitly specifying it.
  • IoError: The file could not be opened.
§Panics
  • No decoder implementation for the given encoding format.
§Example
let image = Image::<Rgb>::open("sample.png")?;
println!("Image dimensions: {}x{}", image.width(), image.height());
Source

pub fn encode(&self, encoding: ImageFormat, dest: &mut impl Write) -> Result<()>

Encodes the image with the given encoding and writes it to the given write buffer.

§Errors
  • An error occured during encoding.
§Panics
  • No encoder implementation for the given encoding format.
§Example
let image = Image::new(100, 100, Rgb::new(255, 0, 0));
let mut out = Vec::new();
image.encode(ImageFormat::Png, &mut out)?;
Source

pub fn save(&self, encoding: ImageFormat, path: impl AsRef<Path>) -> Result<()>

Saves the image with the given encoding to the given path. You can try saving to a memory buffer by using the Self::encode method.

§Errors
  • An error occured during encoding.
§Panics
  • No encoder implementation for the given encoding format.
§Example
let image = Image::new(100, 100, Rgb::new(255, 0, 0));
image.save(ImageFormat::Png, "out.png")?;
Source

pub fn save_inferred(&self, path: impl AsRef<Path>) -> Result<()>

Saves the image to the given path, inferring the encoding from the path/filename extension.

This is obviously slower than Self::save since this method itself uses it. You should only use this method if the filename is dynamic, or if you do not know the desired encoding before runtime.

§See Also
  • Self::save for more information on how saving works.
§Errors
  • Could not infer encoding format.
  • An error occured during encoding.
§Panics
  • No encoder implementation for the given encoding format.
§Example
let image = Image::new(100, 100, Rgb::new(255, 0, 0));
image.save_inferred("out.png")?;
Source

pub const fn width(&self) -> u32

Returns the width of the image.

Source

pub const fn height(&self) -> u32

Returns the height of the image.

Source

pub const fn center(&self) -> (u32, u32)

Returns the nearest pixel coordinates to the center of the image.

This uses integer division which means if an image dimension is not even, then the value is rounded down - e.g. a 5x5 image returns (2, 2), rounded down from (2.5, 2.5).

Source

pub fn pixels(&self) -> impl Iterator<Item = &[P]>

Returns an iterator of slices representing the pixels of the image. Each slice in the Vec is a row. The returned slice should be of Vec<&[P; width]>.

Source

pub const fn format(&self) -> ImageFormat

Returns the encoding format of the image. This is nothing more but metadata about the image. When saving the image, you will still have to explicitly specify the encoding format.

Source

pub const fn overlay_mode(&self) -> OverlayMode

Returns the overlay mode of the image.

Source

pub const fn with_overlay_mode(self, mode: OverlayMode) -> Self

Returns the same image with its overlay mode set to the given value.

Source

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

Returns the dimensions of the image.

Source

pub const fn len(&self) -> u32

Returns the amount of pixels in the image.

Source

pub const fn is_empty(&self) -> bool

Returns true if the image contains no pixels.

Source

pub fn pixel(&self, x: u32, y: u32) -> &P

Returns a reference of the pixel at the given coordinates.

Source

pub fn get_pixel(&self, x: u32, y: u32) -> Option<&P>

Returns a reference of the pixel at the given coordinates, but only if it exists.

Source

pub fn pixel_mut(&mut self, x: u32, y: u32) -> &mut P

Returns a mutable reference to the pixel at the given coordinates.

Source

pub fn set_pixel(&mut self, x: u32, y: u32, pixel: P)

Sets the pixel at the given coordinates to the given pixel.

Source

pub fn overlay_pixel(&mut self, x: u32, y: u32, pixel: P)

Overlays the pixel at the given coordinates with the given pixel according to the overlay mode.

Source

pub fn overlay_pixel_with_mode( &mut self, x: u32, y: u32, pixel: P, mode: OverlayMode, )

Overlays the pixel at the given coordinates with the given pixel according to the specified overlay mode.

If the pixel is out of bounds, nothing occurs: the method will fail silently. This is expected, use Self::set_pixel if you want this to panic, or to use a custom overlay mode use Self::pixel_mut.

Source

pub fn overlay_pixel_with_alpha( &mut self, x: u32, y: u32, pixel: P, mode: OverlayMode, alpha: u8, )

Overlays the pixel at the given coordinates with the given alpha intensity. This does not regard the overlay mode, since this is usually used for anti-aliasing.

If the pixel is out of bounds, nothing occurs: this method will fail silently. This is expected, use Self::set_pixel if you want this to panic, or to use a custom overlay mode use Self::pixel_mut.

Source

pub fn invert(&mut self)

Inverts this image in place.

Equivalent to:

image.map_in_place(|_x, _y, pixel| *pixel = !*pixel);
Source

pub fn inverted(self) -> Self

👎Deprecated: use the Not trait instead (e.g. !image)

Takes this image and inverts it. Useful for method chaining.

Source

pub fn brighten(&mut self, amount: P::Subpixel)

Brightens the image by increasing all pixels by the specified amount of subpixels in place. See Self::darken to darken the image, since this usually does not take any negative values.

A subpixel is a value of a pixel’s component, for example in RGB, each subpixel is a value of either R, G, or B.

For anything with alpha, alpha is not brightened.

Source

pub fn darken(&mut self, amount: P::Subpixel)

Darkens the image by decreasing all pixels by the specified amount of subpixels in place. See Self::brighten to brighten the image, since this usually does not take any negative values.

A subpixel is a value of a pixel’s component, for example in RGB, each subpixel is a value of either R, G, or B.

For anything with alpha, alpha is not brightened.

Source

pub fn brightened(self, amount: P::Subpixel) -> Self

Takes this image and brightens it by increasing all pixels by the specified amount of subpixels. Negative values will darken the image. Useful for method chaining.

See Self::darkened to darken the image, since this usually does not take any negative values.

A subpixel is a value of a pixel’s component, for example in RGB, each subpixel is a value.

For anything with alpha, alpha is not brightened.

Source

pub fn darkened(self, amount: P::Subpixel) -> Self

Takes this image and darkens it by decreasing all pixels by the specified amount of subpixels. Negative values will brighten the image. Useful for method chaining.

See Self::brightened to brighten the image, since this usually does not take any negative values.

A subpixel is a value of a pixel’s component, for example in RGB, each subpixel is a value.

For anything with alpha, alpha is not brightened.

Source

pub fn hue_rotate(&mut self, degrees: i32)
where P: TrueColor,

Hue rotates the image by the specified amount of degrees in place.

The hue is a standard angle degree, that is a value between 0 and 360, although values below and above will be wrapped using the modulo operator.

For anything with alpha, alpha is not rotated.

Source

pub fn hue_rotated(self, degrees: i32) -> Self
where P: TrueColor,

Takes this image and hue rotates it by the specified amount of degrees. Useful for method chaining.

See Self::hue_rotate for more information.

Source

pub fn map_data<T: Pixel>(self, f: impl FnOnce(Vec<P>) -> Vec<T>) -> Image<T>

Returns the image replaced with the given data. It is up to you to make sure the data is the correct size.

The function should take the current image data and return the new data.

§Note

This will not work for paletted images, nor will it work for conversion to paletted images. For conversion from paletted images, see the [Self::flatten] method to flatten the palette fist. For conversion to paletted images, try quantizing the image.

Source

pub fn set_data(&mut self, data: Vec<P>)

Sets the data of this image to the new data. This is used a lot internally, but should rarely be used by you.

§Panics
  • Panics if the data is malformed.
Source

pub fn map_pixels<T: Pixel>(self, f: impl FnMut(P) -> T) -> Image<T>

Returns the image with each pixel in the image mapped to the given function.

The function should take the pixel and return another pixel.

Source

pub fn map_pixels_with_coords<T: Pixel>( self, f: impl Fn(u32, u32, P) -> T, ) -> Image<T>

Returns the image with the each pixel in the image mapped to the given function, with the function taking additional data of the pixel.

The function should take the x and y coordinates followed by the pixel and return the new pixel.

Source

pub fn map_in_place(&mut self, f: impl Fn(u32, u32, &mut P))

Similar to Self::map_pixels_with_coords, but this maps the pixels in place.

This means that the output pixel type must be the same.

Source

pub fn map_rows<I, T: Pixel>(self, f: impl Fn(u32, &[P]) -> I) -> Image<T>
where I: IntoIterator<Item = T>,

Returns the image with each row of pixels represented as a slice mapped to the given function.

The function should take the y coordinate followed by the row of pixels (represented as a slice) and return an Iterator of pixels.

Source

pub fn rows(&self) -> impl Iterator<Item = &[P]>

Iterates over each row of pixels in the image.

Source

pub fn convert<T: Pixel + From<P>>(self) -> Image<T>

Converts the image into an image with the given pixel type.

§Note

Currently there is a slight inconsistency with paletted images - if you would like to convert from a paletted image to a paletted image with a different pixel type, you cannot use this method and must instead use the From/Into trait instead.

That said, you can also use the From/Into trait regardless of the pixel type.

Source

pub fn set_format(&mut self, format: ImageFormat)

Sets the encoding format of this image. Note that when saving the file, an encoding format will still have to be explicitly specified. This is more or less image metadata.

Source

pub fn crop(&mut self, x1: u32, y1: u32, x2: u32, y2: u32)

Crops this image in place to the given bounding box.

§Panics
  • The width or height of the bounding box is less than 1.
Source

pub fn cropped(self, x1: u32, y1: u32, x2: u32, y2: u32) -> Self

Takes this image and crops it to the given box. Useful for method chaining.

Source

pub fn mirror(&mut self)

Mirrors, or flips this image horizontally (about the y-axis) in place.

Source

pub fn mirrored(self) -> Self

Takes this image and flips it horizontally (about the y-axis). Useful for method chaining.

Source

pub fn flip(&mut self)

Flips this image vertically (about the x-axis) in place.

Source

pub fn flipped(self) -> Self

Takes this image and flips it vertically, or about the x-axis. Useful for method chaining.

Source

pub fn rotate_90(&mut self)

Rotates this image by 90 degrees clockwise, or 270 degrees counterclockwise, in place.

§See Also
  • Self::rotate for a version that can take any arbitrary amount of degrees
  • Self::rotated for the above method which does operate in-place - useful for method chaining
Source

pub fn rotate_180(&mut self)

Rotates this image by 180 degrees in place.

§See Also
  • Self::rotate for a version that can take any arbitrary amount of degrees
  • Self::rotated for the above method which does operate in-place - useful for method chaining
Source

pub fn rotate_270(&mut self)

Rotates this image by 270 degrees clockwise, or 90 degrees counterclockwise, in place.

§See Also
  • Self::rotate for a version that can take any arbitrary amount of degrees
  • Self::rotated for the above method which does operate in-place - useful for method chaining
Source

pub fn rotate(&mut self, degrees: i32)

Rotates this image in place about its center. There are optimized rotating algorithms for 90, 180, and 270 degree rotations (clockwise).

As mentioned, the argument is specified in degrees.

§See Also
  • Self::rotated for this method which does operate in-place - useful for method chaining
Source

pub fn rotated(self, degrees: i32) -> Self

Takes the image and rotates it by the specified amount of degrees about its center. Useful for method chaining. There are optimized rotating algorithms for 90, 180, and 270 degree rotations.

Source

pub fn resize(&mut self, width: u32, height: u32, algorithm: ResizeAlgorithm)

Resizes this image in place to the given dimensions using the given resizing algorithm in place.

width and height must be greater than 0, otherwise this method will panic. You should validate user input before calling this method.

§Panics
  • width or height is zero.
§Example
let mut image = Image::new(256, 256, Rgb::white());
assert_eq!(image.dimensions(), (256, 256));

image.resize(64, 64, ResizeAlgorithm::Lanczos3);
assert_eq!(image.dimensions(), (64, 64));
Source

pub fn resized( self, width: u32, height: u32, algorithm: ResizeAlgorithm, ) -> Self

Takes this image and resizes this image to the given dimensions using the given resizing algorithm. Useful for method chaining.

width and height must be greater than 0, otherwise this method will panic. You should validate user input before calling this method.

§Panics
  • width or height is zero.
§See Also
Source

pub fn draw(&mut self, entity: &impl Draw<P>)

Draws an object or shape onto this image.

§Example
let mut image = Image::new(256, 256, Rgb::white());
let rectangle = Rectangle::at(64, 64)
    .with_size(128, 128)
    .with_fill(Rgb::black());

image.draw(&rectangle);
Source

pub fn with(self, entity: &impl Draw<P>) -> Self

Takes this image, draws the given object or shape onto it, and returns it. Useful for method chaining and drawing multiple objects at once.

§See Also
Source

pub fn paste(&mut self, x: u32, y: u32, image: &Self)

Pastes the given image onto this image at the given x and y coordinates. This is a shorthand for using the Self::draw method with crate::Paste.

§Example
let mut image = Image::new(256, 256, Rgb::white());
let overlay_image = Image::open("overlay.png")?;

image.paste(64, 64, &overlay_image);
Source

pub fn paste_with_mask( &mut self, x: u32, y: u32, image: &Self, mask: &Image<BitPixel>, )

Pastes the given image onto this image at the given x and y coordinates, masked with the given masking image.

Currently, only BitPixel images are supported for the masking image.

This is a shorthand for using the Self::draw method with crate::Paste.

§Example
let mut image = Image::new(256, 256, Rgb::white());
let overlay_image = Image::open("overlay.png")?;

let (w, h) = overlay_image.dimensions();
let mut mask = Image::new(w, h, BitPixel::off());
mask.draw(&Ellipse::from_bounding_box(0, 0, w, h).with_fill(BitPixel::on()));

image.paste_with_mask(64, 64, &overlay_image, &mask);
Source

pub fn mask_alpha(&mut self, mask: &Image<L>)
where P: Alpha,

Masks the alpha values of this image with the luminance values of the given single-channel L image.

If you want to mask using the alpha values of the image instead of providing an L image, you can split the bands of the image and extract the alpha band.

This masking image must have the same dimensions as this image. If it doesn’t, you will receive a panic.

§Panics
  • The masking image has different dimensions from this image.
Source

pub fn palette(&self) -> Option<&[P::Color]>

Returns the palette associated with this image as a slice. If there is no palette, this returns None.

Source

pub fn palette_mut(&mut self) -> Option<&mut [P::Color]>

Returns the palette associated with this image as a mutable slice. If there is no palette, this returns None.

Source

pub unsafe fn palette_unchecked(&self) -> &[P::Color]

Returns the palette associated with this image as a slice. You must uphold the guarantee that the image is paletted, otherwise this will result in undefined behaviour.

§Safety
  • The image must always be paletted.
§See Also
Source

pub unsafe fn palette_mut_unchecked(&mut self) -> &mut [P::Color]

Returns the palette associated with this image as a mutable slice. You must uphold the guarantee that the image is paletted, otherwise this will result in undefined behaviour.

§Safety
  • The image must always be paletted.
§See Also
Source

pub fn map_palette<'a, U, F, C: TrueColor>(self, f: F) -> Image<U>
where Self: 'a, P: Paletted<'a>, U: Paletted<'a> + Pixel<Subpixel = P::Subpixel, Color = C>, F: FnMut(P::Color) -> C,

Maps the palette of this image using the given function. If this image has no palette, this will do nothing.

§Panics
  • Safe conversion of palette references failed.
Source

pub fn flatten_palette<'a>(self) -> Image<P::Color>
where Self: 'a, P: Paletted<'a>,

Takes this image and flattens this paletted image into an unpaletted image. This is similar to Self::convert but the output type is automatically resolved.

Source

pub fn quantize<'p, T>(self, palette_size: u8) -> Image<T>
where Self: 'p, P: TrueColor, T: Pixel<Color = P> + Paletted<'p, Subpixel = u8>,

Quantizes this image using its colors and turns it into its paletted counterpart. This currently only works with 8-bit palettes.

This is similar to Self::convert but the output type is automatically resolved. This is also the inverse conversion of Self::flatten_palette.

§Errors
  • The palette could not be created.
§Panics
  • Unable to quantize the image.
§See Also
  • [Quantizer] - Implementation of the core quantizer. Use this for more fine-grained control over the quantization process, such as adjusting the quantization speed.
Source§

impl Image<Rgba>

Source

pub fn split_rgb_and_alpha(self) -> (Image<Rgb>, Image<L>)

Splits this image into an Rgb image and an L image, where the Rgb image contains the red, green, and blue color channels and the L image contains the alpha channel.

There is a more optimized method available, Self::map_rgb_pixels, if you only need to perform operations on individual RGB pixels. If you can, you should use that instead.

§Example

Rotating the image by 90 degrees but keeping the alpha channel untouched:

use ril::prelude::*;

let image = Image::<Rgba>::open("image.png")?;
let (rgb, alpha) = image.split_rgb_and_alpha();
let inverted = Image::from_rgb_and_alpha(rgb.rotated(90), alpha);
§See Also
Source

pub fn from_rgb_and_alpha(rgb: Image<Rgb>, alpha: Image<L>) -> Self

Creates an Rgba image from an Rgb image and an L image, where the Rgb image contains the red, green, and blue color channels and the L image contains the alpha channel.

§Panics
  • The dimensions of the two images do not match.
§See Also
Source

pub fn map_rgb_pixels(self, f: impl FnMut(Rgb) -> Rgb) -> Self

Performs the given operation f on every pixel in this image, ignoring the alpha channel. The alpha channel is left untouched.

§Example

Inverting the image but keeping the alpha channel untouched:

use ril::prelude::*;

let image = Image::<Rgba>::open("image.png")?;
let inverted = image.map_rgb_pixels(|rgb| !rgb);
§See Also
Source

pub fn map_alpha_pixels(self, f: impl FnMut(L) -> L) -> Self

Performs the given operation f on every pixel in the alpha channel of this image. The RGB channels are left untouched.

§See Also

Trait Implementations§

Source§

impl Banded<(Image<L>, Image<L>, Image<L>)> for Image<Rgb>

Source§

fn bands(&self) -> (Image<L>, Image<L>, Image<L>)

Takes this image and returns its bands.
Source§

fn from_bands((r, g, b): (Image<L>, Image<L>, Image<L>)) -> Self

Creates a new image from the given bands.
Source§

impl Banded<(Image<L>, Image<L>, Image<L>, Image<L>)> for Image<Rgba>

Source§

fn bands(&self) -> (Image<L>, Image<L>, Image<L>, Image<L>)

Takes this image and returns its bands.
Source§

fn from_bands((r, g, b, a): (Image<L>, Image<L>, Image<L>, Image<L>)) -> Self

Creates a new image from the given bands.
Source§

impl<P: Clone + Pixel> Clone for Image<P>
where P::Color: Clone,

Source§

fn clone(&self) -> Image<P>

Returns a copy 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<'a, P: Pixel> From<&'a Image<P>> for EncoderMetadata<P>

Source§

fn from(metadata: &'a Image<P>) -> Self

Converts to this type from the input type.
Source§

impl<P: Pixel> From<Frame<P>> for Image<P>

Source§

fn from(frame: Frame<P>) -> Self

Converts to this type from the input type.
Source§

impl From<Image<BitPixel>> for Image<Dynamic>

Source§

fn from(f: Image<BitPixel>) -> Self

Converts to this type from the input type.
Source§

impl From<Image<BitPixel>> for Image<L>

Source§

fn from(f: Image<BitPixel>) -> Self

Converts to this type from the input type.
Source§

impl From<Image<BitPixel>> for Image<Rgb>

Source§

fn from(f: Image<BitPixel>) -> Self

Converts to this type from the input type.
Source§

impl From<Image<BitPixel>> for Image<Rgba>

Source§

fn from(f: Image<BitPixel>) -> Self

Converts to this type from the input type.
Source§

impl From<Image<Dynamic>> for Image<BitPixel>

Source§

fn from(f: Image<Dynamic>) -> Self

Converts to this type from the input type.
Source§

impl From<Image<Dynamic>> for Image<L>

Source§

fn from(f: Image<Dynamic>) -> Self

Converts to this type from the input type.
Source§

impl From<Image<Dynamic>> for Image<Rgb>

Source§

fn from(f: Image<Dynamic>) -> Self

Converts to this type from the input type.
Source§

impl From<Image<Dynamic>> for Image<Rgba>

Source§

fn from(f: Image<Dynamic>) -> Self

Converts to this type from the input type.
Source§

impl From<Image<L>> for Image<BitPixel>

Source§

fn from(f: Image<L>) -> Self

Converts to this type from the input type.
Source§

impl From<Image<L>> for Image<Dynamic>

Source§

fn from(f: Image<L>) -> Self

Converts to this type from the input type.
Source§

impl From<Image<L>> for Image<Rgb>

Source§

fn from(f: Image<L>) -> Self

Converts to this type from the input type.
Source§

impl From<Image<L>> for Image<Rgba>

Source§

fn from(f: Image<L>) -> Self

Converts to this type from the input type.
Source§

impl<P: Pixel> From<Image<P>> for Frame<P>

Source§

fn from(image: Image<P>) -> Self

Converts to this type from the input type.
Source§

impl From<Image<PalettedRgb<'_>>> for Image<BitPixel>

Source§

fn from(f: Image<PalettedRgb<'_>>) -> Self

Converts to this type from the input type.
Source§

impl From<Image<PalettedRgb<'_>>> for Image<Dynamic>

Source§

fn from(f: Image<PalettedRgb<'_>>) -> Self

Converts to this type from the input type.
Source§

impl From<Image<PalettedRgb<'_>>> for Image<L>

Source§

fn from(f: Image<PalettedRgb<'_>>) -> Self

Converts to this type from the input type.
Source§

impl From<Image<PalettedRgb<'_>>> for Image<Rgb>

Source§

fn from(f: Image<PalettedRgb<'_>>) -> Self

Converts to this type from the input type.
Source§

impl From<Image<PalettedRgb<'_>>> for Image<Rgba>

Source§

fn from(f: Image<PalettedRgb<'_>>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<Image<PalettedRgb<'a>>> for Image<PalettedRgba<'a>>

Source§

fn from(image: Image<PalettedRgb<'a>>) -> Self

Converts to this type from the input type.
Source§

impl From<Image<PalettedRgba<'_>>> for Image<BitPixel>

Source§

fn from(f: Image<PalettedRgba<'_>>) -> Self

Converts to this type from the input type.
Source§

impl From<Image<PalettedRgba<'_>>> for Image<Dynamic>

Source§

fn from(f: Image<PalettedRgba<'_>>) -> Self

Converts to this type from the input type.
Source§

impl From<Image<PalettedRgba<'_>>> for Image<L>

Source§

fn from(f: Image<PalettedRgba<'_>>) -> Self

Converts to this type from the input type.
Source§

impl From<Image<PalettedRgba<'_>>> for Image<Rgb>

Source§

fn from(f: Image<PalettedRgba<'_>>) -> Self

Converts to this type from the input type.
Source§

impl From<Image<PalettedRgba<'_>>> for Image<Rgba>

Source§

fn from(f: Image<PalettedRgba<'_>>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<Image<PalettedRgba<'a>>> for Image<PalettedRgb<'a>>

Source§

fn from(image: Image<PalettedRgba<'a>>) -> Self

Converts to this type from the input type.
Source§

impl From<Image<Rgb>> for Image<BitPixel>

Source§

fn from(f: Image<Rgb>) -> Self

Converts to this type from the input type.
Source§

impl From<Image<Rgb>> for Image<Dynamic>

Source§

fn from(f: Image<Rgb>) -> Self

Converts to this type from the input type.
Source§

impl From<Image<Rgb>> for Image<L>

Source§

fn from(f: Image<Rgb>) -> Self

Converts to this type from the input type.
Source§

impl From<Image<Rgb>> for Image<PalettedRgb<'_>>

Source§

fn from(image: Image<Rgb>) -> Self

Converts to this type from the input type.
Source§

impl From<Image<Rgb>> for Image<Rgba>

Source§

fn from(f: Image<Rgb>) -> Self

Converts to this type from the input type.
Source§

impl From<Image<Rgba>> for Image<BitPixel>

Source§

fn from(f: Image<Rgba>) -> Self

Converts to this type from the input type.
Source§

impl From<Image<Rgba>> for Image<Dynamic>

Source§

fn from(f: Image<Rgba>) -> Self

Converts to this type from the input type.
Source§

impl From<Image<Rgba>> for Image<L>

Source§

fn from(f: Image<Rgba>) -> Self

Converts to this type from the input type.
Source§

impl From<Image<Rgba>> for Image<PalettedRgba<'_>>

Source§

fn from(image: Image<Rgba>) -> Self

Converts to this type from the input type.
Source§

impl From<Image<Rgba>> for Image<Rgb>

Source§

fn from(f: Image<Rgba>) -> Self

Converts to this type from the input type.
Source§

impl<'a, P: Pixel> IntoFill for &'a Image<P>

Source§

type Pixel = P

The pixel type of the fill.
Source§

type Fill = ImageFill<'a, <&'a Image<P> as IntoFill>::Pixel>

The fill type.
Source§

fn into_fill(self) -> Self::Fill

Converts the fill into a fill type.
Source§

impl<P: Pixel> Not for Image<P>

Source§

type Output = Image<P>

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more

Auto Trait Implementations§

§

impl<P> Freeze for Image<P>

§

impl<P> RefUnwindSafe for Image<P>

§

impl<P> Send for Image<P>
where P: Send, <P as Pixel>::Color: Send,

§

impl<P> Sync for Image<P>
where P: Sync, <P as Pixel>::Color: Sync,

§

impl<P> Unpin for Image<P>
where P: Unpin,

§

impl<P> UnwindSafe for Image<P>
where P: UnwindSafe, <P as Pixel>::Color: UnwindSafe,

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> 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.