Struct png::Decoder

source ·
pub struct Decoder<R: Read> { /* private fields */ }
Expand description

PNG Decoder

Implementations

Images that are considered too big

use std::fs::File;
use png::{Decoder, Limits};
// This image is 32x32 pixels, so it's more than four pixels in size.
let mut limits = Limits::default();
limits.pixels = 4;
let mut decoder = Decoder::new_with_limits(File::open("tests/pngsuite/basi0g01.png").unwrap(), limits);
assert!(decoder.read_info().is_err());
// This image is 32x32 pixels, so it's exactly 1024 pixels in size.
let mut limits = Limits::default();
limits.pixels = 1024;
let mut decoder = Decoder::new_with_limits(File::open("tests/pngsuite/basi0g01.png").unwrap(), limits);
assert!(decoder.read_info().is_ok());

Reads all meta data until the first IDAT chunk

Trait Implementations

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.