pub struct Decoder { /* private fields */ }
Expand description
Read an image with custom settings
Implementations§
Source§impl Decoder
impl Decoder
pub fn new() -> Self
pub fn info_raw(&self) -> &ColorMode
Sourcepub fn info_raw_mut(&mut self) -> &mut ColorMode
pub fn info_raw_mut(&mut self) -> &mut ColorMode
Preferred color mode for decoding
pub fn info_png_mut(&mut self) -> &mut Info
Sourcepub fn color_convert(&mut self, true_or_false: bool)
pub fn color_convert(&mut self, true_or_false: bool)
whether to convert the PNG to the color type you want. Default: yes
Sourcepub fn read_text_chunks(&mut self, true_or_false: bool)
pub fn read_text_chunks(&mut self, true_or_false: bool)
if false but remember_unknown_chunks
is true, they’re stored in the unknown chunks.
Sourcepub fn remember_unknown_chunks(&mut self, true_or_false: bool)
pub fn remember_unknown_chunks(&mut self, true_or_false: bool)
store all bytes from unknown chunks in the Info
(off by default, useful for a png editor)
Sourcepub fn get_icc(&self) -> Result<Vec<u8>, Error>
pub fn get_icc(&self) -> Result<Vec<u8>, Error>
Decompress ICC profile from iCCP
chunk. Only available if remember_unknown_chunks
was set.
Sourcepub fn decode<Bytes: AsRef<[u8]>>(
&mut self,
input: Bytes,
) -> Result<Image, Error>
pub fn decode<Bytes: AsRef<[u8]>>( &mut self, input: Bytes, ) -> Result<Image, Error>
Load PNG from buffer using Decoder’s settings
state.info_raw_mut().colortype = ColorType::RGBA;
match state.decode(&slice) {
Ok(Image::RGBA(with_alpha)) => do_stuff(with_alpha),
_ => panic!("¯\\_(ツ)_/¯")
}
Sourcepub fn decode_file<P: AsRef<Path>>(
&mut self,
filepath: P,
) -> Result<Image, Error>
pub fn decode_file<P: AsRef<Path>>( &mut self, filepath: P, ) -> Result<Image, Error>
Decode a file from disk using Decoder’s settings
Sourcepub fn inspect(&mut self, input: &[u8]) -> Result<(usize, usize), Error>
pub fn inspect(&mut self, input: &[u8]) -> Result<(usize, usize), Error>
Updates info_png
. Returns (width, height)
Sourcepub fn set_custom_zlib(
&mut self,
callback: custom_decompress_callback,
context: *const c_void,
)
pub fn set_custom_zlib( &mut self, callback: custom_decompress_callback, context: *const c_void, )
use custom zlib decoder instead of built in one
Sourcepub fn set_custom_inflate(
&mut self,
callback: custom_decompress_callback,
context: *const c_void,
)
pub fn set_custom_inflate( &mut self, callback: custom_decompress_callback, context: *const c_void, )
use custom deflate decoder instead of built in one.
If custom_zlib
is used, custom_inflate
is ignored since only the built in zlib function will call custom_inflate
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Decoder
impl RefUnwindSafe for Decoder
impl Send for Decoder
impl Sync for Decoder
impl Unpin for Decoder
impl UnwindSafe for Decoder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more