Trait GenericImage
trait GenericImage: GenericImageView
A trait for manipulating images.
Required Methods
fn get_pixel_mut(self: &mut Self, x: u32, y: u32) -> &mut <Self as >::PixelGets a reference to the mutable pixel at location
(x, y). Indexed from top left.Panics
Panics if
(x, y)is out of bounds.Panics for dynamic images (this method is deprecated and will be removed).
Known issues
This requires the buffer to contain a unique set of continuous channels in the exact order and byte representation that the pixel type requires. This is somewhat restrictive.
TODO: Maybe use some kind of entry API? this would allow pixel type conversion on the fly while still doing only one array lookup:
let px = image.pixel_entry_at(x,y); px.set_from_rgba(rgba)fn put_pixel(self: &mut Self, x: u32, y: u32, pixel: <Self as >::Pixel)Put a pixel at location (x, y). Indexed from top left.
Panics
Panics if
(x, y)is out of bounds.fn blend_pixel(self: &mut Self, x: u32, y: u32, pixel: <Self as >::Pixel)Put a pixel at location (x, y), taking into account alpha channels
Provided Methods
unsafe fn unsafe_put_pixel(self: &mut Self, x: u32, y: u32, pixel: <Self as >::Pixel)Puts a pixel at location (x, y). Indexed from top left.
This function can be implemented in a way that ignores bounds checking.
Safety
The coordinates must be
in_boundsof the image.fn copy_from<O>(self: &mut Self, other: &O, x: u32, y: u32) -> ImageResult<()> where O: GenericImageView<Pixel = <Self as >::Pixel>Copies all of the pixels from another image into this image.
The other image is copied with the top-left corner of the other image placed at (x, y).
In order to copy only a piece of the other image, use
GenericImageView::view.You can use
FlatSamplesto source pixels from an arbitrary regular raster of channel values, for example from a foreign interface or a fixed image.Returns
Returns an error if the image is too large to be copied at the given position
fn copy_within(self: &mut Self, source: Rect, x: u32, y: u32) -> boolCopies all of the pixels from one part of this image to another part of this image.
The destination rectangle of the copy is specified with the top-left corner placed at (x, y).
Returns
trueif the copy was successful,falseif the image could not be copied due to size constraints.fn sub_image(self: &mut Self, x: u32, y: u32, width: u32, height: u32) -> SubImage<&mut Self> where Self: SizedReturns a mutable subimage that is a view into this image. If you want an immutable subimage instead, use
GenericImageView::viewThe coordinates set the position of the top left corner of theSubImage.
Implementors
impl<P, Container> GenericImage for ImageBuffer<P, Container>impl GenericImage for DynamicImageimpl<Buffer, P: Pixel> GenericImage for ViewMut<Buffer, P>