#[repr(C)]pub struct State {
pub decoder: DecoderSettings,
pub encoder: EncoderSettings,
pub info_raw: ColorMode,
pub info_png: Info,
pub error: ErrorCode,
}
Expand description
The settings, state and information for extended encoding and decoding
Fields
decoder: DecoderSettings
encoder: EncoderSettings
info_raw: ColorMode
specifies the format in which you would like to get the raw pixel buffer
info_png: Info
info of the PNG image obtained after decoding
error: ErrorCode
Implementations
sourceimpl State
impl State
pub fn new() -> Self
Use Decoder or Encoder type instead
pub fn set_auto_convert(&mut self, mode: bool)
pub fn set_filter_strategy(
&mut self,
mode: FilterStrategy,
palette_filter_zero: bool
)
sourcepub fn set_custom_zlib(
&mut self,
callback: custom_compress_callback,
context: *const c_void
)
👎 Deprecated: Use Encoder type instead of State
pub fn set_custom_zlib(
&mut self,
callback: custom_compress_callback,
context: *const c_void
)
Use Encoder type instead of State
See `Encoder’
sourcepub fn set_custom_deflate(
&mut self,
callback: custom_compress_callback,
context: *const c_void
)
👎 Deprecated: Use Encoder type instead of State
pub fn set_custom_deflate(
&mut self,
callback: custom_compress_callback,
context: *const c_void
)
Use Encoder type instead of State
See `Encoder’
pub fn info_raw(&self) -> &ColorMode
pub fn info_raw_mut(&mut self) -> &mut ColorMode
pub fn info_png(&self) -> &Info
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>
👎 Deprecated: Use Decoder type instead of State
pub fn decode<Bytes: AsRef<[u8]>>(
&mut self,
input: Bytes
) -> Result<Image, Error>
Use Decoder type instead of State
Load PNG from buffer using State’s settings
state.info_raw_mut().colortype = ColorType::RGBA;
match state.decode(&slice) {
Ok(Image::RGBA(with_alpha)) => do_stuff(with_alpha),
_ => panic!("¯\\_(ツ)_/¯")
}
pub fn decode_file<P: AsRef<Path>>(
&mut self,
filepath: P
) -> Result<Image, Error>
Use Decoder type instead of State
sourcepub fn inspect(&mut self, input: &[u8]) -> Result<(usize, usize), Error>
👎 Deprecated: Use Decoder type instead of State
pub fn inspect(&mut self, input: &[u8]) -> Result<(usize, usize), Error>
Use Decoder type instead of State
Updates info_png
. Returns (width, height)
pub fn encode<PixelType: Pod>(
&mut self,
image: &[PixelType],
w: usize,
h: usize
) -> Result<Vec<u8>, Error>
Use Encoder type instead of State
pub fn encode_file<PixelType: Pod, P: AsRef<Path>>(
&mut self,
filepath: P,
image: &[PixelType],
w: usize,
h: usize
) -> Result<(), Error>
Use Encoder type instead of State
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for State
impl !Send for State
impl !Sync for State
impl Unpin for State
impl UnwindSafe for State
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more