mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 20:32:34 +00:00
qr_code partially working
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
use std::fmt;
|
||||
|
||||
use crate::common::BitMatrix;
|
||||
|
||||
/**
|
||||
* JAVAPORT: The original code was a 2D array of ints, but since it only ever gets assigned
|
||||
* -1, 0, and 1, I'm going to use less memory and go with bytes.
|
||||
@@ -110,3 +112,17 @@ impl fmt::Display for ByteMatrix {
|
||||
write!(f, "{}", result)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ByteMatrix> for BitMatrix {
|
||||
fn from(bm: ByteMatrix) -> Self {
|
||||
let mut bit_matrix = BitMatrix::new(bm.getWidth(), bm.getHeight()).unwrap();
|
||||
for y in 0..bm.getHeight() {
|
||||
for x in 0..bm.getWidth() {
|
||||
if bm.get(x, y) > 0 {
|
||||
bit_matrix.set(x as u32, y as u32);
|
||||
}
|
||||
}
|
||||
}
|
||||
bit_matrix
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user