-
-
Save Shnatsel/ec75b05205ef55c96b9d256fdc36c2ec to your computer and use it in GitHub Desktop.
Profiling harness for palette expansion in `png` crate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::fs::File; | |
fn main() { | |
// loop 10 times to get lots of samples and a more clear profile | |
for i in 0..10 { | |
let filename = std::env::args_os().nth(1).expect("No input file provided"); | |
let mut decoder = png::Decoder::new(File::open(filename).unwrap()); | |
// Set the decoder to expand palletted images into RGBA instead of simply outputting palette indices | |
// Without this the | |
decoder.set_transformations(png::Transformations::EXPAND); | |
let mut reader = decoder.read_info().unwrap(); | |
// Allocate the output buffer. | |
let mut buf = vec![0; reader.output_buffer_size()]; | |
// Read the next frame. An APNG might contain multiple frames. | |
let _info = reader.next_frame(&mut buf).unwrap(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment