Skip to main content

Image

Struct Image 

Source
pub struct Image { /* private fields */ }
Expand description

A decoded image: rows top to bottom, each pixel its mode’s bytes, red first. It holds the Charge for its pixels, returned when it drops, after the pixels’ buffer is freed.

Implementations§

Source§

impl Image

Source

pub fn mode(&self) -> Mode

The mode.

Source

pub fn width(&self) -> u32

The width in pixels.

Source

pub fn height(&self) -> u32

The height in pixels.

Source

pub fn pixels(&self) -> &[u8] ⓘ

The pixels: what Pillow’s tobytes() gives for the image UnityPy returns. One exception: tobytes(), and so a PNG save, raises MemoryError for an image wider than INT_MAX / bits - 7 pixels, bits its mode’s (its raw encoder’s cap, src/encode.c:260-262): 67,108,856 for RGBA, 89,478,478 for RGB. The images that wide that decode, in UnityPy as here, are a BCn texture’s in RGBA: 67,108,857 to 67,108,864 wide at a height of 1 or 2, and 67,108,860 or 67,108,864 wide at a height of 4 (a height of 3, or another width at 4, is a DecodeError::DecompressionBomb); and a raw texture’s whose raw mode takes fewer bits a pixel than its image’s mode, up to that raw mode’s cap (step 5): Alpha8’s, ARGB4444’s and RGBA4444’s in RGBA, R8’s and RGB565’s in RGB. A PNG writer mirrors that cap.

Source

pub fn charge(&self) -> &Charge

The charge the pixels hold.

Source

pub fn into_parts(self) -> (Vec<u8>, Charge)

The pixels and their charge, which must live as long as the pixels’ allocation does: drop the charge last. Beware let (pixels, charge) = image.into_parts();: a pattern’s bindings drop in reverse order, so that drops charge first, returning its bytes while the buffer still holds them. Drop the pixels first (drop(pixels)), or keep the charge in an owner that outlives them.

Trait Implementations§

Source§

impl Debug for Image

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Image

§

impl !UnwindSafe for Image

§

impl Forget for Image

§

impl Freeze for Image

§

impl Move for Image

§

impl Send for Image

§

impl Sync for Image

§

impl Unpin for Image

§

impl UnsafeUnpin for Image

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.