GitHub project page

Function lodepng::decode_file [-]  [+] [src]

pub fn decode_file(filepath: &Path, colortype: ColorType, bitdepth: c_uint) -> Result<Image, Error>

Load PNG from disk, from file with given name. Same as the other decode functions, but instead takes a file path as input.

decode32_file and decode24_file are more convenient if you want specific image format.

There's also ffi::State::decode() if you'd like to set more settings.

match try!(decode_file(filepath, LCT_RGBA, 8)) {
    Image::RGBA(with_alpha) => do_stuff(with_alpha),
    Image::RGB(without_alpha) => do_stuff(without_alpha),
    _ => panic!("¯\\_(ツ)_/¯")
}