mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 12:22: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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
use std::fmt;
|
||||
|
||||
use crate::qrcode::decoder::{Mode, ErrorCorrectionLevel, Version};
|
||||
use crate::qrcode::decoder::{Mode, ErrorCorrectionLevel, Version, VersionRef};
|
||||
|
||||
use super::ByteMatrix;
|
||||
|
||||
@@ -25,13 +25,14 @@ use super::ByteMatrix;
|
||||
* @author satorux@google.com (Satoru Takabayashi) - creator
|
||||
* @author dswitkin@google.com (Daniel Switkin) - ported from C++
|
||||
*/
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct QRCode {
|
||||
|
||||
// public static final int NUM_MASK_PATTERNS = 8;
|
||||
|
||||
mode:Option<Mode>,
|
||||
ecLevel:Option<ErrorCorrectionLevel>,
|
||||
version:Option<&'static Version>,
|
||||
version:Option<VersionRef>,
|
||||
maskPattern:i32,
|
||||
matrix:Option<ByteMatrix>,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user