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:
14
Cargo.toml
14
Cargo.toml
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "rxing"
|
name = "rxing"
|
||||||
version = "0.4.8"
|
version = "0.4.9"
|
||||||
description="A rust port of the zxing barcode library."
|
description="A rust port of the zxing barcode library."
|
||||||
license="Apache-2.0"
|
license="Apache-2.0"
|
||||||
repository="https://github.com/rxing-core/rxing"
|
repository="https://github.com/rxing-core/rxing"
|
||||||
@@ -13,11 +13,11 @@ exclude = [
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
regex = "1.8.0"
|
regex = "1.9.0"
|
||||||
fancy-regex = "0.11"
|
fancy-regex = "0.11"
|
||||||
once_cell = "1.17.2"
|
once_cell = "1.18"
|
||||||
encoding = "0.2"
|
encoding = "0.2"
|
||||||
urlencoding = "2.1.2"
|
urlencoding = "2.1.3"
|
||||||
uriparse = "0.6.4"
|
uriparse = "0.6.4"
|
||||||
chrono = "0.4.26"
|
chrono = "0.4.26"
|
||||||
chrono-tz = "0.8"
|
chrono-tz = "0.8"
|
||||||
@@ -28,9 +28,9 @@ codepage-437 = "0.1.0"
|
|||||||
rxing-one-d-proc-derive = {version = "0.5", path ="./crates/one-d-proc-derive"}
|
rxing-one-d-proc-derive = {version = "0.5", path ="./crates/one-d-proc-derive"}
|
||||||
num = "0.4.0"
|
num = "0.4.0"
|
||||||
svg = {version = "0.13", optional = true}
|
svg = {version = "0.13", optional = true}
|
||||||
resvg = {version = "0.29.0", optional = true, default-features=false}
|
resvg = {version = "0.35", optional = true, default-features=false}
|
||||||
serde = { version = "1.0", features = ["derive", "rc"], optional = true }
|
serde = { version = "1.0", features = ["derive", "rc"], optional = true }
|
||||||
thiserror = "1.0.38"
|
thiserror = "1.0.44"
|
||||||
multimap = "0.9"
|
multimap = "0.9"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
@@ -40,7 +40,7 @@ rand = "0.8.5"
|
|||||||
criterion = "0.5"
|
criterion = "0.5"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["image"]
|
default = ["image", "svg_read"]
|
||||||
#/// Enable features required for image manipulation and reading.
|
#/// Enable features required for image manipulation and reading.
|
||||||
image = ["dep:image", "dep:imageproc"]
|
image = ["dep:image", "dep:imageproc"]
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "rxing-cli"
|
name = "rxing-cli"
|
||||||
version = "0.1.15"
|
version = "0.1.16"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "A command line interface for rxing supporting encoding and decoding of multiple barcode formats"
|
description = "A command line interface for rxing supporting encoding and decoding of multiple barcode formats"
|
||||||
license="Apache-2.0"
|
license="Apache-2.0"
|
||||||
@@ -11,4 +11,4 @@ keywords = ["barcode", "2d_barcode", "1d_barcode", "barcode_reader", "barcode_wr
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.2.0", features = ["derive"] }
|
clap = { version = "4.2.0", features = ["derive"] }
|
||||||
rxing = {path = "../../", version = "~0.4.6", features = ["image", "svg_read", "svg_write"] }
|
rxing = {path = "../../", version = "~0.4.9", features = ["image", "svg_read", "svg_write"] }
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use crate::common::Result;
|
use crate::common::Result;
|
||||||
use crate::{BufferedImageLuminanceSource, Exceptions, LuminanceSource};
|
use crate::{BufferedImageLuminanceSource, Exceptions, LuminanceSource};
|
||||||
use image::{DynamicImage, RgbaImage};
|
use image::{DynamicImage, RgbaImage};
|
||||||
|
use resvg::usvg::TreeParsing;
|
||||||
use resvg::{self, usvg::Options};
|
use resvg::{self, usvg::Options};
|
||||||
|
|
||||||
pub struct SVGLuminanceSource(BufferedImageLuminanceSource);
|
pub struct SVGLuminanceSource(BufferedImageLuminanceSource);
|
||||||
@@ -58,12 +59,9 @@ impl SVGLuminanceSource {
|
|||||||
return Err(Exceptions::format_with("could not create pixmap"));
|
return Err(Exceptions::format_with("could not create pixmap"));
|
||||||
};
|
};
|
||||||
|
|
||||||
resvg::render(
|
let tree_resvg = resvg::Tree::from_usvg(&tree);
|
||||||
&tree,
|
|
||||||
resvg::usvg::FitTo::Original,
|
tree_resvg.render(resvg::tiny_skia::Transform::default(), &mut pixmap.as_mut());
|
||||||
resvg::tiny_skia::Transform::default(),
|
|
||||||
pixmap.as_mut(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let Some(buffer) = RgbaImage::from_raw(tree.size.width() as u32, tree.size.height() as u32, pixmap.data().to_vec()) else {
|
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"));
|
return Err(Exceptions::format_with("could not create image buffer"));
|
||||||
|
|||||||
Reference in New Issue
Block a user