Skip to main content

Offscreen

Struct Offscreen 

Source
pub struct Offscreen {
    pub attribute: Attribute,
    pub parameter: Parameter,
    pub data: Option<BlockData>,
}
Expand description

A decoded offscreen.

Fields§

§attribute: Attribute

The attribute.

§parameter: Parameter

Its Parameter section.

§data: Option<BlockData>

The block data, when the payload is stored.

Implementations§

Source§

impl Offscreen

Source

pub fn parse(attribute: &[u8], payload: Option<&[u8]>) -> Result<Self>

Parses an attribute and, if given, its block data payload, and checks they agree.

Source

pub fn kind(&self) -> PixelKind

The pixel layout.

Source

pub fn for_each_block( &self, visit: impl FnMut(usize, &[u8]) -> Result<()>, ) -> Result<()>

Visit every stored block decompressed: (block index, raw bytes).

Source

pub fn to_rgba(&self) -> Result<RgbaImage>

Colour, gray and monochrome offscreens as RGBA (not premultiplied). Blocks that are not stored are transparent (or the init colour).

Source

pub fn stored_boxes(&self) -> Vec<(u32, u32, u32, u32)>

Boxes (x0, y0, x1, y1) in offscreen pixels of the blocks that store data. Nothing is decompressed; edge blocks end at the offscreen’s size.

Source

pub fn to_rgba_region(&self, region: (i64, i64, i64, i64)) -> Result<RgbaImage>

Offscreen::to_rgba of the box (x0, y0, x1, y1) in offscreen pixels, which may reach outside the offscreen (that part is transparent). Only the blocks the box overlaps are decompressed, so part of a large sheet can be read without decoding all of it.

Source

pub fn to_rgba_halved(&self, halvings: u32) -> Result<RgbaImage>

Offscreen::to_rgba halved halvings times with RgbaImage::halve, one block at a time, so a large offscreen read at a small scale never exists at full size. Blocks are 256 pixels and aligned, so up to 8 halvings give exactly the result of halving the whole image; more are done on the reduced image.

Source

pub fn to_mask_rgba_halved(&self, halvings: u32) -> Result<RgbaImage>

The mask plane as opaque grey pixels (v, v, v, 255), halved like Offscreen::to_rgba_halved.

Source

pub fn to_alpha(&self) -> Result<GrayImage>

The first plane as an 8-bit image (masks: 0 = hidden, 255 = shown).

Source

pub fn reencode_check(&self) -> Result<(usize, usize, usize)>

Re-encode the decoded pixels and compare with the stored blocks: (blocks equal byte for byte, blocks with equal pixels, stored blocks).

Trait Implementations§

Source§

impl Clone for Offscreen

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Offscreen

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.