Struct spng::raw::RawContext[][src]

pub struct RawContext<R> { /* fields omitted */ }

Implementations

impl<R> RawContext<R>[src]

pub fn new() -> Result<RawContext<R>, Error>[src]

pub fn with_flags(flags: ContextFlags) -> Result<RawContext<R>, Error>[src]

pub fn set_crc_action(
    &mut self,
    critical: CrcAction,
    ancillary: CrcAction
) -> Result<(), Error>
[src]

Set how chunk CRC errors should be handled for critical and ancillary chunks.

pub fn get_image_limits(&self) -> Result<(u32, u32), Error>[src]

Get image width and height limits.

Returns (width, height)

pub fn set_image_limits(
    &mut self,
    max_width: u32,
    max_height: u32
) -> Result<(), Error>
[src]

Set image width and height limits, these may not be larger than (2^31)-1.

pub fn get_chunk_limits(&self) -> Result<(usize, usize), Error>[src]

Get chunk size and chunk cache limits.

Returns (chunk_size, cache_size)

pub fn set_chunk_limits(
    &mut self,
    chunk_size: usize,
    cache_size: usize
) -> Result<(), Error>
[src]

Set chunk size and chunk cache limits, the default chunk size limit is (2^31)-1, the default chunk cache limit is SIZE_MAX.

pub fn get_ihdr(&self) -> Result<Ihdr, Error>[src]

Get the image header.

pub fn get_plte(&self) -> Result<Ref<'_, Plte>, Error>[src]

Get the image palette.

pub fn get_trns(&self) -> Result<Trns, Error>[src]

Get the image transparency.

pub fn get_chrm(&self) -> Result<Chrm, Error>[src]

Get primary chromacities and white point as floating point numbers.

pub fn get_chrm_int(&self) -> Result<ChrmInt, Error>[src]

Get primary chromacities and white point in the PNG’s internal representation.

pub fn get_gama(&self) -> Result<f64, Error>[src]

Get the image gamma.

pub fn get_iccp(&self) -> Result<Ref<'_, Iccp>, Error>[src]

Get the ICC profile.

Note

ICC profiles are not validated.

pub fn get_sbit(&self) -> Result<Sbit, Error>[src]

Get the significant bits.

pub fn get_srgb(&self) -> Result<u8, Error>[src]

Get the sRGB rendering intent.

pub fn get_text(&self) -> Result<Ref<'_, Vec<Text>>, Error>[src]

Get text information.

Note

Due to the structure of PNG files it is recommended to call this function after decode_image to retrieve all text chunks.

Safety

Text data is freed after the context is dropped.

pub fn get_bkgd(&self) -> Result<Bkgd, Error>[src]

Get the image background color.

pub fn get_phys(&self) -> Result<Phys, Error>[src]

Get physical pixel dimensions.

pub fn get_splt(&self) -> Result<Ref<'_, Vec<Splt>>, Error>[src]

Get the suggested palettes.

Safety

Suggested palettes are freed when the context is dropped.

pub fn get_time(&self) -> Result<Time, Error>[src]

Get the modification time.

Note

Due to the structure of PNG files it is recommended to call this function after decode_image.

pub fn get_offs(&self) -> Result<Offs, Error>[src]

Get the image offset.

pub fn get_exif(&self) -> Result<Ref<'_, Exif>, Error>[src]

Get the EXIF data.

Note

Due to the structure of PNG files it is recommended to call this function after decode_image.

Safety

exif.data is freed when the context is dropped.

pub fn get_row_info(&self) -> Result<RowInfo, Error>[src]

Get the current, to-be-decoded row’s information.

pub fn decoded_image_size(&self, out_format: Format) -> Result<usize, Error>[src]

Calculates decoded image buffer size for the given output format.

PNG data must have been set prior with set_png_stream or set_png_buffer.

pub fn decode_image(
    &mut self,
    out: &mut [u8],
    out_format: Format,
    flags: DecodeFlags
) -> Result<(), Error>
[src]

Decodes the PNG file and writes the image to out. The image is converted from any PNG format to the destination format out_format. Interlaced images are deinterlaced and 16-bit images are converted to host-endian.

The out buffer must have a length greater or equal to the size returned by decoded_image_size with the same out_format.

If the SPNG_DECODE_PROGRESSIVE flag is set, the context will be initialied with out_format for progressive decoding. The image is not immediately decoded and the out buffer is ignored.

The SPNG_DECODE_TRNS flag is ignored if the PNG has an alpha channel or does not contain a TRNS chunk. It is also ignored for gray 1/2/4-bit images.

The function may only be called once per context.

pub fn decode_row(&mut self, out: &mut [u8]) -> Result<(), Error>[src]

Decodes and deinterlaces a scanline to out.

This function requires the decoder to be initialized by calling decode_image with the SPNG_DECODE_PROGRESSIVE flag set.

The widest scanline is the decoded image size divided by ihdr.height.

For the last scanline and subsequent calls the return value is SPNG_EOI.

If the image is not interlaced this function’s behavior is identical to decode_scanline.

pub fn decode_scanline(&mut self, output: &mut [u8]) -> Result<(), Error>[src]

Decodes a scanline to out.

This function requires the decoder to be initialized by calling decode_image with the SPNG_DECODE_PROGRESSIVE flag set.

The widest scanline is the decoded image size divided by ihdr.height.

For the last scanline and subsequent calls the return value is SPNG_EOI.

impl<R: Read> RawContext<R>[src]

pub fn set_png_stream(&mut self, reader: R) -> Result<(), Error>[src]

Set the input png stream reader. The input buffer or stream may only be set once per context.

impl<'a> RawContext<&'a [u8]>[src]

pub fn set_png_buffer(&mut self, buf: &'a [u8]) -> Result<(), Error>[src]

Set the input png buffer. The input buffer or stream may only be set once per context.

Trait Implementations

impl<R: Debug> Debug for RawContext<R>[src]

impl<R> Drop for RawContext<R>[src]

Auto Trait Implementations

impl<R> RefUnwindSafe for RawContext<R> where
    R: RefUnwindSafe

impl<R> !Send for RawContext<R>

impl<R> !Sync for RawContext<R>

impl<R> Unpin for RawContext<R>

impl<R> UnwindSafe for RawContext<R> where
    R: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.