pub struct Offscreen {
pub attribute: Attribute,
pub parameter: Parameter,
pub data: Option<BlockData>,
}Expand description
A decoded offscreen.
Fields§
§attribute: AttributeThe attribute.
parameter: ParameterIts Parameter section.
data: Option<BlockData>The block data, when the payload is stored.
Implementations§
Source§impl Offscreen
impl Offscreen
Sourcepub fn parse(attribute: &[u8], payload: Option<&[u8]>) -> Result<Self>
pub fn parse(attribute: &[u8], payload: Option<&[u8]>) -> Result<Self>
Parses an attribute and, if given, its block data payload, and checks they agree.
Sourcepub fn for_each_block(
&self,
visit: impl FnMut(usize, &[u8]) -> Result<()>,
) -> Result<()>
pub fn for_each_block( &self, visit: impl FnMut(usize, &[u8]) -> Result<()>, ) -> Result<()>
Visit every stored block decompressed: (block index, raw bytes).
Sourcepub fn to_rgba(&self) -> Result<RgbaImage>
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).
Sourcepub fn stored_boxes(&self) -> Vec<(u32, u32, u32, u32)>
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.
Sourcepub fn to_rgba_region(&self, region: (i64, i64, i64, i64)) -> Result<RgbaImage>
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.
Sourcepub fn to_rgba_halved(&self, halvings: u32) -> Result<RgbaImage>
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.
Sourcepub fn to_mask_rgba_halved(&self, halvings: u32) -> Result<RgbaImage>
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.