move to more modern SVG read methods

This commit is contained in:
Henry Schimke
2023-08-03 15:19:02 -05:00
parent bcb97f639e
commit 09673e2381
3 changed files with 13 additions and 15 deletions

View File

@@ -1,6 +1,7 @@
use crate::common::Result;
use crate::{BufferedImageLuminanceSource, Exceptions, LuminanceSource};
use image::{DynamicImage, RgbaImage};
use resvg::usvg::TreeParsing;
use resvg::{self, usvg::Options};
pub struct SVGLuminanceSource(BufferedImageLuminanceSource);
@@ -58,12 +59,9 @@ impl SVGLuminanceSource {
return Err(Exceptions::format_with("could not create pixmap"));
};
resvg::render(
&tree,
resvg::usvg::FitTo::Original,
resvg::tiny_skia::Transform::default(),
pixmap.as_mut(),
);
let tree_resvg = resvg::Tree::from_usvg(&tree);
tree_resvg.render(resvg::tiny_skia::Transform::default(), &mut pixmap.as_mut());
let Some(buffer) = RgbaImage::from_raw(tree.size.width() as u32, tree.size.height() as u32, pixmap.data().to_vec()) else {
return Err(Exceptions::format_with("could not create image buffer"));