Skip to content

Commit

Permalink
Reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurenzV committed Nov 26, 2024
1 parent 003ac3d commit 23dd5ab
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions crates/resvg/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,20 @@ mod raster_images {
let mut decoder = zune_jpeg::JpegDecoder::new_with_options(data, options);
decoder.decode_headers().ok()?;
let output_cs = decoder.get_output_colorspace()?;

let img_data = {
let data = decoder.decode().ok()?;
match output_cs {
ColorSpace::RGBA => data,
// For some reason zune jpeg won't coerce luma JPEGs into RGBA, so we do it manually.
ColorSpace::Luma => data.into_iter().flat_map(|p| [p, p, p, 255]).collect::<Vec<_>>(),
_ => return None
ColorSpace::Luma => data
.into_iter()
.flat_map(|p| [p, p, p, 255])
.collect::<Vec<_>>(),
_ => return None,
}
};

let info = decoder.info()?;

let size = tiny_skia::IntSize::from_wh(info.width as u32, info.height as u32)?;
Expand Down

0 comments on commit 23dd5ab

Please sign in to comment.