[−][src]Struct icns::Image
A decoded icon image.
An Image
struct consists of a width, a height, a
PixelFormat
, and a data array encoding the image
pixels in that format.
Regardless of format, pixel data for an image is always stored one complete pixel at a time, in row-major order (that is, the top-left pixel comes first, followed by the rest of the top row from left to right; then comes the second row down, again from left to right, and so on until finally the bottom-right pixel comes last).
Implementations
impl Image
[src]
pub fn read_png<R: Read>(input: R) -> Result<Image>
[src]
Reads an image from a PNG file.
pub fn write_png<W: Write>(&self, output: W) -> Result<()>
[src]
Writes the image to a PNG file.
impl Image
[src]
pub fn new(format: PixelFormat, width: u32, height: u32) -> Image
[src]
Creates a new image with all pixel data set to zero.
pub fn from_data(
format: PixelFormat,
width: u32,
height: u32,
data: Vec<u8>
) -> Result<Image>
[src]
format: PixelFormat,
width: u32,
height: u32,
data: Vec<u8>
) -> Result<Image>
Creates a new image using the given pixel data. Returns an error if the data array is not the correct length.
pub fn pixel_format(&self) -> PixelFormat
[src]
Returns the format in which this image's pixel data is stored.
pub fn width(&self) -> u32
[src]
Returns the width of the image, in pixels.
pub fn height(&self) -> u32
[src]
Returns the height of the image, in pixels.
pub fn data(&self) -> &[u8]
[src]
Returns a reference to the image's pixel data.
pub fn data_mut(&mut self) -> &mut [u8]
[src]
Returns a mutable reference to the image's pixel data.
pub fn into_data(self) -> Box<[u8]>
[src]
Consumes the image, returning the pixel data without cloning it.
pub fn convert_to(&self, format: PixelFormat) -> Image
[src]
Creates a copy of this image by converting to the specified pixel
format. This operation always succeeds, but may lose information (e.g.
converting from RGBA to RGB will silently drop the alpha channel). If
the source image is already in the requested format, this is equivalant
to simply calling clone()
.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Image
impl Send for Image
impl Sync for Image
impl Unpin for Image
impl UnwindSafe for Image
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,