mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
move to more modern SVG read methods
This commit is contained in:
@@ -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"));
|
||||
|
||||
Reference in New Issue
Block a user