Skip to content

Commit

Permalink
Update resvg and use re-export of tiny-skia from resvg
Browse files Browse the repository at this point in the history
  • Loading branch information
AldaronLau committed May 29, 2023
1 parent 2f5f456 commit 5e8e2da
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 77 deletions.
113 changes: 43 additions & 70 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions alloy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ lexical-sort = "0.3"
trash = { version = "3.0", default-features = false }
kamadak-exif = "0.5"
arboard = "3.2"
resvg = "0.33"
tiny-skia = "0.9"
resvg = "0.34"
log = "0.4"
env_logger = "0.10"
pico-args = "0.5"
Expand Down
8 changes: 3 additions & 5 deletions alloy/src/image_cache/image_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use gelatin::image::{
AnimationDecoder, ImageFormat,
};
use resvg::{
tiny_skia::{Pixmap, Transform},
usvg::{self, TreeParsing},
Tree,
};
Expand Down Expand Up @@ -190,12 +191,9 @@ pub fn load_svg(path: &std::path::Path) -> Result<image::RgbaImage> {
let (width, height) = ((width * zoom) as u32, (height * zoom) as u32);
let zoom = zoom as f32;
// These unwrapped Options are fine as long as the dimensions are correct
let mut pixmap = tiny_skia::Pixmap::new(width, height).unwrap();
let mut pixmap = Pixmap::new(width, height).unwrap();

tree.render(
tiny_skia::Transform::from_scale(zoom, zoom),
&mut pixmap.as_mut(),
);
tree.render(Transform::from_scale(zoom, zoom), &mut pixmap.as_mut());

Ok(image::RgbaImage::from_raw(width, height, pixmap.take()).unwrap())
}
Expand Down

0 comments on commit 5e8e2da

Please sign in to comment.