Struct SubImage
pub struct SubImage<I> { /* private fields */ }
A View into another image
Instances of this struct can be created using:
GenericImage::sub_imageto create a mutable view,GenericImageView::viewto create an immutable view,SubImage::newto instantiate the struct directly.
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
impl<I> SubImage<I>
fn new(image: I, x: u32, y: u32, width: u32, height: u32) -> SubImage<I>Construct a new subimage The coordinates set the position of the top left corner of the
SubImage.fn change_bounds(&mut self, x: u32, y: u32, width: u32, height: u32)Change the coordinates of this subimage.
fn offsets(&self) -> (u32, u32)The offsets of this subimage relative to the underlying image.
fn to_image(&self) -> ImageBuffer<<<I as Deref>::Target as GenericImageView>::Pixel, Vec<<<<I as Deref>::Target as GenericImageView>::Pixel as Pixel>::Subpixel>> where I: Deref, I::Target: GenericImageView + 'static,Convert this subimage to an
ImageBuffer
impl<I> SubImage<I>
where
I: Deref,
I::Target: GenericImageView,
fn view(&self, x: u32, y: u32, width: u32, height: u32) -> SubImage<&I::Target>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 ; let buffer = new; let subimage: = buffer.view; let subview: = subimage.view; // Less efficient and NOT &RgbImage let _: = view;fn inner(&self) -> &I::TargetGet a reference to the underlying image.
impl<I> SubImage<I>
where
I: DerefMut,
I::Target: GenericImage,
fn sub_image(&mut self, x: u32, y: u32, width: u32, height: u32) -> SubImage<&mut I::Target>Create a mutable sub-view of the image.
The coordinates given are relative to the current view on the underlying image.
fn inner_mut(&mut self) -> &mut I::TargetGet a mutable reference to the underlying image.
Trait Implementations
impl<I> Deref for SubImage<I>
where
I: Deref,
type Target = SubImageInner<I>;fn deref(&self) -> &Self::Target
impl<I> DerefMut for SubImage<I>
where
I: DerefMut,
fn deref_mut(&mut self) -> &mut Self::Target
impl<I: Clone> Clone for SubImage<I>
fn clone(&self) -> SubImage<I>
impl<I: Copy> Copy for SubImage<I>
Auto Trait Implementations
impl<I> Freeze for SubImage<I>
where
SubImageInner<I>: Freeze,
impl<I> RefUnwindSafe for SubImage<I>
where
SubImageInner<I>: RefUnwindSafe,
impl<I> Send for SubImage<I>
where
SubImageInner<I>: Send,
impl<I> Sync for SubImage<I>
where
SubImageInner<I>: Sync,
impl<I> Unpin for SubImage<I>
where
SubImageInner<I>: Unpin,
impl<I> UnsafeUnpin for SubImage<I>
where
SubImageInner<I>: UnsafeUnpin,
impl<I> UnwindSafe for SubImage<I>
where
SubImageInner<I>: UnwindSafe,
Blanket Implementations
impl<P, T> Receiver for SubImage<I>
where
P: Deref<Target = T> + ?Sized,
T: ?Sized,
type Target = T;
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for SubImage<I>
where
ST: ?Sized,
DT: ?Sized,
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for SubImage<I>
where
ST: ?Sized,
DT: ?Sized,
impl<T> Any for SubImage<I>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for SubImage<I>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for SubImage<I>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for SubImage<I>
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for SubImage<I>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> IntoEither for SubImage<I>
impl<T> Pointable for SubImage<I>
const ALIGN: usize = _;type Init = T;unsafe fn init(init: <T as Pointable>::Init) -> usizeunsafe fn deref<'a>(ptr: usize) -> &'a Tunsafe fn deref_mut<'a>(ptr: usize) -> &'a mut Tunsafe fn drop(ptr: usize)
impl<T> Read<Exclusive, BecauseExclusive> for SubImage<I>
where
T: ?Sized,
impl<T> ToOwned for SubImage<I>
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for SubImage<I>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for SubImage<I>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for SubImage<I>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>