mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
fix rotate issue & fix size of pdf417_compact
This commit is contained in:
@@ -31,13 +31,18 @@ impl BarcodeMatrix {
|
|||||||
/**
|
/**
|
||||||
* @param height the height of the matrix (Rows)
|
* @param height the height of the matrix (Rows)
|
||||||
* @param width the width of the matrix (Cols)
|
* @param width the width of the matrix (Cols)
|
||||||
|
* @param compact if true, enables compaction
|
||||||
*/
|
*/
|
||||||
pub fn new(height: usize, width: usize) -> Self {
|
pub fn new(height: usize, width: usize, compact: bool) -> Self {
|
||||||
//Initializes the array to the correct width
|
//Initializes the array to the correct width
|
||||||
let mut matrix = Vec::with_capacity(height);
|
let mut matrix = Vec::with_capacity(height);
|
||||||
|
|
||||||
for _i in 0..height {
|
for _i in 0..height {
|
||||||
|
if !compact {
|
||||||
matrix.push(BarcodeRow::new((width + 4) * 17 + 1));
|
matrix.push(BarcodeRow::new((width + 4) * 17 + 1));
|
||||||
|
} else {
|
||||||
|
matrix.push(BarcodeRow::new((width + 2) * 17 + 1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Self {
|
Self {
|
||||||
matrix,
|
matrix,
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ impl PDF417 {
|
|||||||
)?;
|
)?;
|
||||||
|
|
||||||
//4. step: low-level encoding
|
//4. step: low-level encoding
|
||||||
let mut barcode_matrix = BarcodeMatrix::new(rows as usize, cols as usize);
|
let mut barcode_matrix = BarcodeMatrix::new(rows as usize, cols as usize, self.compact);
|
||||||
self.encodeLowLevel(
|
self.encodeLowLevel(
|
||||||
&format!("{dataCodewords}{ec}"),
|
&format!("{dataCodewords}{ec}"),
|
||||||
cols,
|
cols,
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ impl PDF417Writer {
|
|||||||
* Takes and rotates the it 90 degrees
|
* Takes and rotates the it 90 degrees
|
||||||
*/
|
*/
|
||||||
fn rotateArray(bitarray: &Vec<Vec<u8>>) -> Vec<Vec<u8>> {
|
fn rotateArray(bitarray: &Vec<Vec<u8>>) -> Vec<Vec<u8>> {
|
||||||
let mut temp = vec![vec![0; bitarray[0].len()]; bitarray.len()];
|
let mut temp = vec![vec![0; bitarray.len()]; bitarray[0].len()];
|
||||||
|
|
||||||
for ii in 0..bitarray.len() {
|
for ii in 0..bitarray.len() {
|
||||||
// This makes the direction consistent on screen when rotating the screen;
|
// This makes the direction consistent on screen when rotating the screen;
|
||||||
|
|||||||
Reference in New Issue
Block a user