-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't render jpg pictures with ghostscript
- Loading branch information
Showing
5 changed files
with
38 additions
and
36 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,41 @@ | ||
use tiny_skia_path::Rect; | ||
use usvg::ImageKind; | ||
use crate::FillRule; | ||
use crate::image::Image; | ||
use crate::surface::Surface; | ||
use crate::svg::ProcessContext; | ||
use crate::svg::{group, ProcessContext}; | ||
use crate::util::RectExt; | ||
|
||
/// Render an image into a surface. | ||
pub fn render(image: &usvg::Image, surface: &mut Surface, process_context: &mut ProcessContext) { | ||
if !image.is_visible() { | ||
return; | ||
} | ||
|
||
unimplemented!(); | ||
// match image.kind() { | ||
// ImageKind::JPEG(d) => { | ||
// let dynamic_image = | ||
// image::load_from_memory_with_format(d.as_slice(), ImageFormat::Jpeg).unwrap(); | ||
// let d_image = Image::new(&dynamic_image); | ||
// surface.draw_image(d_image, image.size()); | ||
// } | ||
// ImageKind::PNG(d) => { | ||
// let dynamic_image = | ||
// image::load_from_memory_with_format(d.as_slice(), ImageFormat::Png).unwrap(); | ||
// let d_image = Image::new(&dynamic_image); | ||
// surface.draw_image(d_image, image.size()); | ||
// } | ||
// ImageKind::GIF(d) => { | ||
// let dynamic_image = | ||
// image::load_from_memory_with_format(d.as_slice(), ImageFormat::Gif).unwrap(); | ||
// let d_image = Image::new(&dynamic_image); | ||
// surface.draw_image(d_image, image.size()); | ||
// } | ||
// ImageKind::SVG(t) => { | ||
// surface.push_clip_path( | ||
// &Rect::from_xywh(0.0, 0.0, t.size().width(), t.size().height()) | ||
// .unwrap() | ||
// .to_clip_path(), | ||
// &FillRule::NonZero, | ||
// ); | ||
// group::render(t.root(), surface, process_context); | ||
// surface.pop(); | ||
// } | ||
// _ => unimplemented!(), | ||
// } | ||
match image.kind() { | ||
ImageKind::JPEG(d) => { | ||
// TODO: Remove unwraps | ||
let d_image = Image::from_jpeg(&d).unwrap(); | ||
surface.draw_image(d_image, image.size()); | ||
} | ||
ImageKind::PNG(d) => { | ||
let d_image = Image::from_png(&d).unwrap(); | ||
surface.draw_image(d_image, image.size()); | ||
} | ||
ImageKind::GIF(d) => { | ||
let d_image = Image::from_gif(&d).unwrap(); | ||
surface.draw_image(d_image, image.size()); | ||
} | ||
ImageKind::SVG(t) => { | ||
surface.push_clip_path( | ||
&Rect::from_xywh(0.0, 0.0, t.size().width(), t.size().height()) | ||
.unwrap() | ||
.to_clip_path(), | ||
&FillRule::NonZero, | ||
); | ||
group::render(t.root(), surface, process_context); | ||
surface.pop(); | ||
} | ||
_ => unimplemented!(), | ||
} | ||
} |
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
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