Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ members = [
resolver = "3"

[workspace.package]
version = "0.0.8"
version = "0.0.9"

[profile.release]
codegen-units = 1
Expand Down
6 changes: 3 additions & 3 deletions rxing-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fn fetch_url(url: &str) -> Result<Vec<u8>> {
Ok(buf)
}

fn decode_image_bytes(bytes: &[u8]) -> Result<(Vec<u8>, u32, u32)> {
fn decode_image_bytes(bytes: &[u8]) -> Result<(Vec<u8>, usize, usize)> {
let mut reader = ImageReader::new(Cursor::new(bytes))
.with_guessed_format()
.context("could not guess image format")?;
Expand All @@ -103,11 +103,11 @@ fn decode_image_bytes(bytes: &[u8]) -> Result<(Vec<u8>, u32, u32)> {
limits.max_alloc = Some(512 * 1024 * 1024);
reader.limits(limits);
let rgba = reader.decode().context("image decode failed")?.into_rgba8();
let (w, h) = (rgba.width(), rgba.height());
let (w, h) = (rgba.width() as usize, rgba.height() as usize);
Ok((rgba.into_raw(), w, h))
}

fn decode_payloads(rgba: &[u8], w: u32, h: u32, max: u32) -> Result<Vec<Vec<u8>>> {
fn decode_payloads(rgba: &[u8], w: usize, h: usize, max: usize) -> Result<Vec<Vec<u8>>> {
let luma = rgba_to_luma(rgba, w, h).map_err(anyhow::Error::msg)?;
let primary = decode_qr_codes_luma(&luma, w, h, true, true, true, max)?;
if !primary.is_empty() {
Expand Down
2 changes: 1 addition & 1 deletion rxing-reader/src/binarizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use anyhow::Result;

use crate::{LuminanceSource, common::BitMatrix};

/// Converts greyscale luminance data into one-bit black/white barcode data.
/// Converts greyscale luminance data into one-bit black/white QR image data.
///
/// Implementations can choose different thresholding strategies while exposing
/// the same row, line, and matrix accessors to readers.
Expand Down
6 changes: 3 additions & 3 deletions rxing-reader/src/binary_bitmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::{Binarizer, common::BitMatrix};

/// One-bit view of an image produced by a [`Binarizer`].
///
/// Readers consume `BinaryBitmap` values when searching for barcodes.
/// Readers consume `BinaryBitmap` values when searching for QR symbols.
pub struct BinaryBitmap<B: Binarizer> {
binarizer: B,
}
Expand All @@ -49,7 +49,7 @@ impl<B: Binarizer> BinaryBitmap<B> {
/// any pixel whose 3×3 neighborhood contains at least one black pixel),
/// then erode (keep only pixels whose 3×3 neighborhood is entirely
/// black). Useful as a post-binarization denoise step for marginal
/// photos (cf. zxing-cpp's `tryDenoise`). The 1-pixel border is left
/// photos. The 1-pixel border is left
/// unchanged. No-op if the matrix is smaller than 3×3.
pub fn close(&mut self) -> Result<()> {
let matrix = self.black_matrix_mut()?;
Expand All @@ -72,7 +72,7 @@ fn sum_filter_3x3<F: Fn(u8) -> bool>(input: &BitMatrix, output: &mut BitMatrix,
for row in 1..h - 1 {
for col in 1..w - 1 {
let mut sum: u8 = 0;
for dx in 0..3u32 {
for dx in 0..3 {
sum += input.try_get(col + dx - 1, row - 1).unwrap_or(false) as u8
+ input.try_get(col + dx - 1, row).unwrap_or(false) as u8
+ input.try_get(col + dx - 1, row + 1).unwrap_or(false) as u8;
Expand Down
Loading
Loading