mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
update details for v0.2.15
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "rxing"
|
||||
version = "0.2.14"
|
||||
version = "0.2.15"
|
||||
description="A rust port of the zxing barcode library."
|
||||
license="Apache-2.0"
|
||||
repository="https://github.com/hschimke/rxing"
|
||||
|
||||
@@ -51,6 +51,10 @@ fn main() {
|
||||
```
|
||||
|
||||
## Latest Release Notes
|
||||
* *v0.2.15* -> Support for reading and writing svg files through the feature flags `svg_read` and `svg_write`.
|
||||
|
||||
These flags are off by default.
|
||||
|
||||
* *v0.2.14* -> Support for more image output formats, many rustification changes to the codebase.
|
||||
|
||||
If you were using very deep, specific functions in the encoder/decoder sections this may require a function rename. For instance `qrcode::encoder::encoder` is now `qrcode::encoder::qrcode_encoder`.
|
||||
|
||||
@@ -98,27 +98,21 @@ impl BufferedImageLuminanceSource {
|
||||
|
||||
let mut raster: ImageBuffer<_, Vec<_>> = ImageBuffer::new(image.width(), image.height());
|
||||
|
||||
for x in 0..image.width() {
|
||||
for y in 0..image.height() {
|
||||
let pixel = img.get_pixel(x, y);
|
||||
let [red, green, blue, alpha] = pixel.0;
|
||||
if alpha == 0 {
|
||||
// white, so we know its luminance is 255
|
||||
raster.put_pixel(x, y, Luma([0xFF]))
|
||||
} else {
|
||||
// .299R + 0.587G + 0.114B (YUV/YIQ for PAL and NTSC),
|
||||
// (306*R) >> 10 is approximately equal to R*0.299, and so on.
|
||||
// 0x200 >> 10 is 0.5, it implements rounding.
|
||||
raster.put_pixel(
|
||||
x,
|
||||
y,
|
||||
Luma([((306 * (red as u64)
|
||||
+ 601 * (green as u64)
|
||||
+ 117 * (blue as u64)
|
||||
+ 0x200)
|
||||
>> 10) as u8]),
|
||||
);
|
||||
}
|
||||
for (x, y, new_pixel) in raster.enumerate_pixels_mut() {
|
||||
let pixel = img.get_pixel(x, y);
|
||||
let [red, green, blue, alpha] = pixel.0;
|
||||
if alpha == 0 {
|
||||
// white, so we know its luminance is 255
|
||||
*new_pixel = Luma([0xFF])
|
||||
} else {
|
||||
// .299R + 0.587G + 0.114B (YUV/YIQ for PAL and NTSC),
|
||||
// (306*R) >> 10 is approximately equal to R*0.299, and so on.
|
||||
// 0x200 >> 10 is 0.5, it implements rounding.
|
||||
*new_pixel = Luma([((306 * (red as u64)
|
||||
+ 601 * (green as u64)
|
||||
+ 117 * (blue as u64)
|
||||
+ 0x200)
|
||||
>> 10) as u8])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -680,7 +680,7 @@ impl From<&BitMatrix> for image::DynamicImage {
|
||||
let mut pixels = image::ImageBuffer::new(value.width, value.height);
|
||||
|
||||
for (x, y, pixel) in pixels.enumerate_pixels_mut() {
|
||||
let new_pixel = if value.get(x as u32, y as u32) {
|
||||
let new_pixel = if value.get(x, y) {
|
||||
image::Rgb([0, 0, 0])
|
||||
} else {
|
||||
image::Rgb([u8::MAX, u8::MAX, u8::MAX])
|
||||
@@ -698,12 +698,7 @@ impl From<&BitMatrix> for svg::Document {
|
||||
let block_size = 1;
|
||||
let mut document = svg::Document::new().set(
|
||||
"viewBox",
|
||||
(
|
||||
0,
|
||||
0,
|
||||
value.width as u32 * block_size,
|
||||
value.height as u32 * block_size,
|
||||
),
|
||||
(0, 0, value.width * block_size, value.height * block_size),
|
||||
);
|
||||
for x in 0..value.width {
|
||||
for y in 0..value.height {
|
||||
|
||||
Reference in New Issue
Block a user