[−][src]Struct image::ImageBuffer
Generic image buffer
Methods
impl<P, Container> ImageBuffer<P, Container> where
P: Pixel + 'static,
P::Subpixel: 'static,
Container: Deref<Target = [P::Subpixel]>,
[src]
impl<P, Container> ImageBuffer<P, Container> where
P: Pixel + 'static,
P::Subpixel: 'static,
Container: Deref<Target = [P::Subpixel]>,
pub fn from_raw(
width: u32,
height: u32,
buf: Container
) -> Option<ImageBuffer<P, Container>>
[src]
pub fn from_raw(
width: u32,
height: u32,
buf: Container
) -> Option<ImageBuffer<P, Container>>
Contructs a buffer from a generic container
(for example a Vec
or a slice)
Returns None if the container is not big enough
pub fn into_raw(self) -> Container
[src]
pub fn into_raw(self) -> Container
Returns the underlying raw buffer
pub fn dimensions(&self) -> (u32, u32)
[src]
pub fn dimensions(&self) -> (u32, u32)
The width and height of this image.
pub fn width(&self) -> u32
[src]
pub fn width(&self) -> u32
The width of this image.
pub fn height(&self) -> u32
[src]
pub fn height(&self) -> u32
The height of this image.
pub fn pixels(&self) -> Pixels<P>
[src]
pub fn pixels(&self) -> Pixels<P>
Returns an iterator over the pixels of this image.
pub fn enumerate_pixels(&self) -> EnumeratePixels<P>
[src]
pub fn enumerate_pixels(&self) -> EnumeratePixels<P>
Enumerates over the pixels of the image. The iterator yields the coordinates of each pixel along with a reference to them.
pub fn get_pixel(&self, x: u32, y: u32) -> &P
[src]
pub fn get_pixel(&self, x: u32, y: u32) -> &P
Gets a reference to the pixel at location (x, y)
Panics
Panics if (x, y)
is out of the bounds (width, height)
.
impl<P, Container> ImageBuffer<P, Container> where
P: Pixel + 'static,
P::Subpixel: 'static,
Container: Deref<Target = [P::Subpixel]> + DerefMut,
[src]
impl<P, Container> ImageBuffer<P, Container> where
P: Pixel + 'static,
P::Subpixel: 'static,
Container: Deref<Target = [P::Subpixel]> + DerefMut,
pub fn pixels_mut(&mut self) -> PixelsMut<P>
[src]
pub fn pixels_mut(&mut self) -> PixelsMut<P>
Returns an iterator over the mutable pixels of this image.
pub fn enumerate_pixels_mut(&mut self) -> EnumeratePixelsMut<P>
[src]
pub fn enumerate_pixels_mut(&mut self) -> EnumeratePixelsMut<P>
Enumerates over the pixels of the image. The iterator yields the coordinates of each pixel along with a mutable reference to them.
pub fn get_pixel_mut(&mut self, x: u32, y: u32) -> &mut P
[src]
pub fn get_pixel_mut(&mut self, x: u32, y: u32) -> &mut P
Gets a reference to the mutable pixel at location (x, y)
Panics
Panics if (x, y)
is out of the bounds (width, height)
.
pub fn put_pixel(&mut self, x: u32, y: u32, pixel: P)
[src]
pub fn put_pixel(&mut self, x: u32, y: u32, pixel: P)
impl<P, Container> ImageBuffer<P, Container> where
P: Pixel<Subpixel = u8> + 'static,
Container: Deref<Target = [u8]>,
[src]
impl<P, Container> ImageBuffer<P, Container> where
P: Pixel<Subpixel = u8> + 'static,
Container: Deref<Target = [u8]>,
pub fn save<Q>(&self, path: Q) -> Result<()> where
Q: AsRef<Path>,
[src]
pub fn save<Q>(&self, path: Q) -> Result<()> where
Q: AsRef<Path>,
Saves the buffer to a file at the path specified.
The image format is derived from the file extension. Currently only jpeg and png files are supported.
impl<P: Pixel + 'static> ImageBuffer<P, Vec<P::Subpixel>> where
P::Subpixel: 'static,
[src]
impl<P: Pixel + 'static> ImageBuffer<P, Vec<P::Subpixel>> where
P::Subpixel: 'static,
pub fn new(width: u32, height: u32) -> ImageBuffer<P, Vec<P::Subpixel>>
[src]
pub fn new(width: u32, height: u32) -> ImageBuffer<P, Vec<P::Subpixel>>
Creates a new image buffer based on a Vec<P::Subpixel>
.
pub fn from_pixel(
width: u32,
height: u32,
pixel: P
) -> ImageBuffer<P, Vec<P::Subpixel>>
[src]
pub fn from_pixel(
width: u32,
height: u32,
pixel: P
) -> ImageBuffer<P, Vec<P::Subpixel>>
Constructs a new ImageBuffer by copying a pixel
pub fn from_fn<F>(
width: u32,
height: u32,
f: F
) -> ImageBuffer<P, Vec<P::Subpixel>> where
F: FnMut(u32, u32) -> P,
[src]
pub fn from_fn<F>(
width: u32,
height: u32,
f: F
) -> ImageBuffer<P, Vec<P::Subpixel>> where
F: FnMut(u32, u32) -> P,
Constructs a new ImageBuffer by repeated application of the supplied function. The arguments to the function are the pixel's x and y coordinates.
pub fn from_vec(
width: u32,
height: u32,
buf: Vec<P::Subpixel>
) -> Option<ImageBuffer<P, Vec<P::Subpixel>>>
[src]
pub fn from_vec(
width: u32,
height: u32,
buf: Vec<P::Subpixel>
) -> Option<ImageBuffer<P, Vec<P::Subpixel>>>
Creates an image buffer out of an existing buffer. Returns None if the buffer is not big enough.
pub fn into_vec(self) -> Vec<P::Subpixel>
[src]
pub fn into_vec(self) -> Vec<P::Subpixel>
Consumes the image buffer and returns the underlying data as an owned buffer
Trait Implementations
impl<P, Container> GenericImage for ImageBuffer<P, Container> where
P: Pixel + 'static,
Container: Deref<Target = [P::Subpixel]> + DerefMut,
P::Subpixel: 'static,
[src]
impl<P, Container> GenericImage for ImageBuffer<P, Container> where
P: Pixel + 'static,
Container: Deref<Target = [P::Subpixel]> + DerefMut,
P::Subpixel: 'static,
type Pixel = P
The type of pixel.
fn dimensions(&self) -> (u32, u32)
[src]
fn dimensions(&self) -> (u32, u32)
The width and height of this image.
fn bounds(&self) -> (u32, u32, u32, u32)
[src]
fn bounds(&self) -> (u32, u32, u32, u32)
The bounding rectangle of this image.
fn get_pixel(&self, x: u32, y: u32) -> P
[src]
fn get_pixel(&self, x: u32, y: u32) -> P
Returns the pixel located at (x, y) Read more
fn get_pixel_mut(&mut self, x: u32, y: u32) -> &mut P
[src]
fn get_pixel_mut(&mut self, x: u32, y: u32) -> &mut P
Puts a pixel at location (x, y) Read more
unsafe fn unsafe_get_pixel(&self, x: u32, y: u32) -> P
[src]
unsafe fn unsafe_get_pixel(&self, x: u32, y: u32) -> P
Returns the pixel located at (x, y), ignoring bounds checking.
fn put_pixel(&mut self, x: u32, y: u32, pixel: P)
[src]
fn put_pixel(&mut self, x: u32, y: u32, pixel: P)
Put a pixel at location (x, y) Read more
unsafe fn unsafe_put_pixel(&mut self, x: u32, y: u32, pixel: P)
[src]
unsafe fn unsafe_put_pixel(&mut self, x: u32, y: u32, pixel: P)
Puts a pixel at location (x, y), ignoring bounds checking.
fn blend_pixel(&mut self, x: u32, y: u32, p: P)
[src]
fn blend_pixel(&mut self, x: u32, y: u32, p: P)
Put a pixel at location (x, y), taking into account alpha channels
DEPRECATED: This method will be removed. Blend the pixel directly instead.
fn width(&self) -> u32
[src]
fn width(&self) -> u32
The width of this image.
fn height(&self) -> u32
[src]
fn height(&self) -> u32
The height of this image.
fn in_bounds(&self, x: u32, y: u32) -> bool
[src]
fn in_bounds(&self, x: u32, y: u32) -> bool
Returns true if this x, y coordinate is contained inside the image.
ⓘImportant traits for Pixels<'a, I>fn pixels(&self) -> Pixels<Self>
[src]
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 Read more
ⓘImportant traits for MutPixels<'a, I>fn pixels_mut(&mut self) -> MutPixels<Self>
[src]
fn pixels_mut(&mut self) -> MutPixels<Self>
: 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. Read more
fn copy_from<O>(&mut self, other: &O, x: u32, y: u32) -> bool where
O: GenericImage<Pixel = Self::Pixel>,
[src]
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
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,
[src]
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.
impl<'a, 'b, Container, FromType: Pixel + 'static, ToType: Pixel + 'static> ConvertBuffer<ImageBuffer<ToType, Vec<<ToType as Pixel>::Subpixel>>> for ImageBuffer<FromType, Container> where
Container: Deref<Target = [FromType::Subpixel]>,
ToType: FromColor<FromType>,
FromType::Subpixel: 'static,
ToType::Subpixel: 'static,
[src]
impl<'a, 'b, Container, FromType: Pixel + 'static, ToType: Pixel + 'static> ConvertBuffer<ImageBuffer<ToType, Vec<<ToType as Pixel>::Subpixel>>> for ImageBuffer<FromType, Container> where
Container: Deref<Target = [FromType::Subpixel]>,
ToType: FromColor<FromType>,
FromType::Subpixel: 'static,
ToType::Subpixel: 'static,
fn convert(&self) -> ImageBuffer<ToType, Vec<ToType::Subpixel>>
[src]
fn convert(&self) -> ImageBuffer<ToType, Vec<ToType::Subpixel>>
Converts self
to a buffer of type T Read more
impl<P, Container> Clone for ImageBuffer<P, Container> where
P: Pixel,
Container: Deref<Target = [P::Subpixel]> + Clone,
[src]
impl<P, Container> Clone for ImageBuffer<P, Container> where
P: Pixel,
Container: Deref<Target = [P::Subpixel]> + Clone,
fn clone(&self) -> ImageBuffer<P, Container>
[src]
fn clone(&self) -> ImageBuffer<P, Container>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<P: Debug + Pixel, Container: Debug> Debug for ImageBuffer<P, Container>
[src]
impl<P: Debug + Pixel, Container: Debug> Debug for ImageBuffer<P, Container>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<P, Container> Deref for ImageBuffer<P, Container> where
P: Pixel + 'static,
P::Subpixel: 'static,
Container: Deref<Target = [P::Subpixel]>,
[src]
impl<P, Container> Deref for ImageBuffer<P, Container> where
P: Pixel + 'static,
P::Subpixel: 'static,
Container: Deref<Target = [P::Subpixel]>,
type Target = [P::Subpixel]
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
fn deref(&self) -> &Self::Target
Dereferences the value.
impl<P, Container> DerefMut for ImageBuffer<P, Container> where
P: Pixel + 'static,
P::Subpixel: 'static,
Container: Deref<Target = [P::Subpixel]> + DerefMut,
[src]
impl<P, Container> DerefMut for ImageBuffer<P, Container> where
P: Pixel + 'static,
P::Subpixel: 'static,
Container: Deref<Target = [P::Subpixel]> + DerefMut,
impl<P, Container> Index<(u32, u32)> for ImageBuffer<P, Container> where
P: Pixel + 'static,
P::Subpixel: 'static,
Container: Deref<Target = [P::Subpixel]>,
[src]
impl<P, Container> Index<(u32, u32)> for ImageBuffer<P, Container> where
P: Pixel + 'static,
P::Subpixel: 'static,
Container: Deref<Target = [P::Subpixel]>,
type Output = P
The returned type after indexing.
fn index(&self, (x, y): (u32, u32)) -> &P
[src]
fn index(&self, (x, y): (u32, u32)) -> &P
Performs the indexing (container[index]
) operation.
impl<P, Container> IndexMut<(u32, u32)> for ImageBuffer<P, Container> where
P: Pixel + 'static,
P::Subpixel: 'static,
Container: Deref<Target = [P::Subpixel]> + DerefMut,
[src]
impl<P, Container> IndexMut<(u32, u32)> for ImageBuffer<P, Container> where
P: Pixel + 'static,
P::Subpixel: 'static,
Container: Deref<Target = [P::Subpixel]> + DerefMut,
Auto Trait Implementations
impl<P, Container> Send for ImageBuffer<P, Container> where
Container: Send,
P: Send,
impl<P, Container> Send for ImageBuffer<P, Container> where
Container: Send,
P: Send,
impl<P, Container> Sync for ImageBuffer<P, Container> where
Container: Sync,
P: Sync,
impl<P, Container> Sync for ImageBuffer<P, Container> where
Container: Sync,
P: Sync,
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
type Owned = T
fn to_owned(&self) -> T
[src]
fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
fn clone_into(&self, target: &mut T)
[src]
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more