pub struct Image { /* private fields */ }
Expand description
The Image struct is at the heart of Kodak. You’ll be using functions on this 95% of the time.
Note that the maximum image size is 2^32 - 1 by 2^32 - 1 pixels. This limit was chosen because it is also the maximum of the PNG format.
Implementations
sourceimpl Image
impl Image
sourcepub fn get_dimensions(&self) -> Dim
pub fn get_dimensions(&self) -> Dim
Returns the dimensions of the image.
sourceimpl Image
impl Image
sourcepub fn fill_region(self, region: Region, colour: Colour) -> Image
pub fn fill_region(self, region: Region, colour: Colour) -> Image
Fills a region.
sourcepub fn crop_unclamped(self, region: Region) -> Image
pub fn crop_unclamped(self, region: Region) -> Image
Crop a region out of the image and return it. This method is mainly used internally and panics; the safer crop()
should be used instead.
The corner from which to crop is assumed to be the top left corner.
Panics
- if the corner from which to crop is outside of the image,
- if the cropped image would reach outside of the image (by specifying new dimensions which are too large).
sourcepub fn crop(self, region: Region) -> Result<Image, &'static str>
pub fn crop(self, region: Region) -> Result<Image, &'static str>
Crop a region out of the image and return it. This method (unlike crop_unclamped()
) will adjust the
size of the region if it is too big. It will return an Err<&str>
if the corner to begin with falls outside of the image.
Arguments
region
- the region to crop out (inclusive).
Examples
let img = Image::blank( Dim { w: 20, h: 30 } )
.crop( Region { l: Loc { x: 10, y: 10 }, d: Dim { w: 10, h: 10 } } )
.unwrap();
assert_eq!(img.width, 10);
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more