pub struct SubImage<I> { /* private fields */ }
Expand description

A View into another image

Instances of this struct can be created using:

Note that this does not implement GenericImage, but it dereferences to one which allows you to use it as if it did. See Design Considerations below for details.

Design Considerations

For reasons relating to coherence, this is not itself a GenericImage or a GenericImageView. In short, we want to reserve the ability of adding traits implemented for all generic images but in a different manner for SubImage. This may be required to ensure that stacking sub-images comes at no double indirect cost.

If, ultimately, this is not needed then a directly implementation of GenericImage can and will get added. This inconvenience may alternatively get resolved if Rust allows some forms of specialization, which might make this trick unnecessary and thus also allows for a direct implementation.

Implementations

Construct a new subimage The coordinates set the position of the top left corner of the SubImage.

Change the coordinates of this subimage.

Convert this subimage to an ImageBuffer

Methods for readable images.

Create a sub-view of the image.

The coordinates given are relative to the current view on the underlying image.

Note that this method is preferred to the one from GenericImageView. This is accessible with the explicit method call syntax but it should rarely be needed due to causing an extra level of indirection.

use image::{GenericImageView, RgbImage, SubImage};
let buffer = RgbImage::new(10, 10);

let subimage: SubImage<&RgbImage> = buffer.view(0, 0, 10, 10);
let subview: SubImage<&RgbImage> = subimage.view(0, 0, 10, 10);

// Less efficient and NOT &RgbImage
let _: SubImage<&_> = GenericImageView::view(&*subimage, 0, 0, 10, 10);

Get a reference to the underlying image.

Create a mutable sub-view of the image.

The coordinates given are relative to the current view on the underlying image.

Get a mutable reference to the underlying image.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
The resulting type after dereferencing.
Dereferences the value.
Mutably dereferences the value.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.