Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format code using 'cargo fmt' #154

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions benches/decoding_benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ fn read_metadata(image: &[u8]) -> ImageInfo {

fn main() {
let mut c = Criterion::default().configure_from_args();
c.bench_function("decode a 512x512 JPEG", |b| b.iter(|| {
read_image(include_bytes!("tower.jpg"))
}));
c.bench_function("decode a 512x512 JPEG", |b| {
b.iter(|| read_image(include_bytes!("tower.jpg")))
});

c.bench_function("decode a 512x512 progressive JPEG", |b| b.iter(|| {
read_image(include_bytes!("tower_progressive.jpg"))
}));
c.bench_function("decode a 512x512 progressive JPEG", |b| {
b.iter(|| read_image(include_bytes!("tower_progressive.jpg")))
});

c.bench_function("decode a 512x512 grayscale JPEG", |b| b.iter(|| {
read_image(include_bytes!("tower_grayscale.jpg"))
}));
c.bench_function("decode a 512x512 grayscale JPEG", |b| {
b.iter(|| read_image(include_bytes!("tower_grayscale.jpg")))
});

c.bench_function("extract metadata from an image", |b| b.iter(|| {
read_metadata(include_bytes!("tower.jpg"))
}));
c.bench_function("extract metadata from an image", |b| {
b.iter(|| read_metadata(include_bytes!("tower.jpg")))
});
c.final_summary();
}
}
15 changes: 8 additions & 7 deletions examples/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,19 @@ fn main() {
encoder.set_depth(png::BitDepth::Eight);

match info.pixel_format {
jpeg::PixelFormat::L8 => encoder.set_color(png::ColorType::Grayscale),
jpeg::PixelFormat::RGB24 => encoder.set_color(png::ColorType::RGB),
jpeg::PixelFormat::L8 => encoder.set_color(png::ColorType::Grayscale),
jpeg::PixelFormat::RGB24 => encoder.set_color(png::ColorType::RGB),
jpeg::PixelFormat::CMYK32 => {
data = cmyk_to_rgb(&mut data);
encoder.set_color(png::ColorType::RGB)
},
}
};

encoder.write_header()
.expect("writing png header failed")
.write_image_data(&data)
.expect("png encoding failed");
encoder
.write_header()
.expect("writing png header failed")
.write_image_data(&data)
.expect("png encoding failed");
}

fn cmyk_to_rgb(input: &[u8]) -> Vec<u8> {
Expand Down
Loading