Struct zune_psd::decoder::PSDDecoder
source · pub struct PSDDecoder<T>where
T: ZReaderTrait,{ /* private fields */ }
Expand description
A simple Photoshop PSD reader.
This currently doesn’t support layer flattening but it’s useful enough in that we can extract images from it.
Further work will go onto adding a renderer that flattens image pixels. But for now this is a good basis.
Implementations§
source§impl<T> PSDDecoder<T>where
T: ZReaderTrait,
impl<T> PSDDecoder<T>where T: ZReaderTrait,
sourcepub fn new(data: T) -> PSDDecoder<T>
pub fn new(data: T) -> PSDDecoder<T>
Create a new decoder that reads a photoshop encoded file
from T
and returns pixels
Arguments
- data: Data source, it has to implement the `ZReaderTrait
sourcepub fn new_with_options(data: T, options: DecoderOptions) -> PSDDecoder<T>
pub fn new_with_options(data: T, options: DecoderOptions) -> PSDDecoder<T>
Creates a new decoder with options that influence decoding routines
Arguments
- data: Data source
- options: Custom options for the decoder
sourcepub fn decode_headers(&mut self) -> Result<(), PSDDecodeErrors>
pub fn decode_headers(&mut self) -> Result<(), PSDDecodeErrors>
Decode headers from the encoded image
This confirms whether the image is a photoshop image and extracts relevant information from the image including width,height and extra information.
sourcepub fn decode_raw(&mut self) -> Result<Vec<u8>, PSDDecodeErrors>
pub fn decode_raw(&mut self) -> Result<Vec<u8>, PSDDecodeErrors>
Decode an image to bytes without regard to depth or endianness
Returns
Ok(bytes): Raw bytes of the image Err(E): An error if it occurred during decoding
sourcepub fn decode(&mut self) -> Result<DecodingResult, PSDDecodeErrors>
pub fn decode(&mut self) -> Result<DecodingResult, PSDDecodeErrors>
Decode a PSD file extracting the image only
Currently this does it without respect to layers and such, only extracting the PSD image, hence might not be the most useful one.
sourcepub const fn get_bit_depth(&self) -> Option<BitDepth>
pub const fn get_bit_depth(&self) -> Option<BitDepth>
Get image bit depth or None if the headers haven’t been decoded
sourcepub fn get_dimensions(&self) -> Option<(usize, usize)>
pub fn get_dimensions(&self) -> Option<(usize, usize)>
Get image width and height respectively or None if the headers haven’t been decoded
sourcepub fn get_colorspace(&self) -> Option<ColorSpace>
pub fn get_colorspace(&self) -> Option<ColorSpace>
Get image colorspace or None if the image header hasn’t been decoded