[−][src]Struct spng::raw::RawContext
The raw decoding context.
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]
&mut self,
critical: CrcAction,
ancillary: CrcAction
) -> Result<(), Error>
Set how chunk CRC errors should be handled for critical and ancillary chunks.
Note
Partially implemented, SPNG_CRC_DISCARD
has no effect.
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]
&mut self,
max_width: u32,
max_height: u32
) -> Result<(), Error>
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]
&mut self,
chunk_size: usize,
cache_size: usize
) -> Result<(), Error>
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<spng_ihdr, Error>
[src]
Get the image header.
pub fn get_plte(&self) -> Result<Plte, Error>
[src]
Get the image palette.
pub fn get_trns(&self) -> Result<spng_trns, Error>
[src]
Get the image transparency.
pub fn get_chrm(&self) -> Result<spng_chrm, Error>
[src]
Get primary chromacities and white point as floating point numbers.
pub fn get_chrm_int(&self) -> Result<spng_chrm_int, 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]
pub fn get_sbit(&self) -> Result<spng_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<spng_bkgd, Error>
[src]
Get the image background color.
pub fn get_phys(&self) -> Result<spng_phys, Error>
[src]
Get physical pixel dimensions.
pub fn get_splt(&self) -> Result<Ref<Vec<Splt>>, Error>
[src]
pub fn get_time(&self) -> Result<spng_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<spng_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<spng_row_info, 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]
&mut self,
out: &mut [u8],
out_format: Format,
flags: DecodeFlags
) -> Result<(), Error>
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,
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,
R: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,