Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve RXingResultPoint usage #13

Merged
merged 19 commits into from
Feb 17, 2023
Merged
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 src/aztec/DecoderTest.rs
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@
// import com.google.zxing.aztec.encoder.EncoderTest;

// import com.google.zxing.FormatException;
// import com.google.zxing.RXingResultPoint;
// import com.google.zxing.Point;
// import com.google.zxing.aztec.AztecDetectorRXingResult;
// import com.google.zxing.common.BitArray;
// import com.google.zxing.common.BitMatrix;
@@ -29,7 +29,7 @@
use crate::{
aztec::shared_test_methods::{stripSpace, toBitArray, toBooleanArray},
common::BitMatrix,
RXingResultPoint,
Point,
};

use super::{aztec_detector_result::AztecDetectorRXingResult, decoder};
@@ -38,7 +38,7 @@ use super::{aztec_detector_result::AztecDetectorRXingResult, decoder};
* Tests {@link Decoder}.
*/

const NO_POINTS: [RXingResultPoint; 4] = [RXingResultPoint { x: 0.0, y: 0.0 }; 4];
const NO_POINTS: [Point; 4] = [Point { x: 0.0, y: 0.0 }; 4];

#[test]
fn test_high_level_decode() {
13 changes: 8 additions & 5 deletions src/aztec/DetectorTest.rs
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ use rand::Rng;
use crate::{aztec::decoder, common::BitMatrix, exceptions::Exceptions};

use super::{
detector::{self, Detector, Point},
detector::{self, AztecPoint, Detector},
encoder::{self, AztecCode},
};

@@ -261,7 +261,7 @@ fn clone(input: &BitMatrix) -> BitMatrix {
result
}

fn get_orientation_points(code: &AztecCode) -> Vec<Point> {
fn get_orientation_points(code: &AztecCode) -> Vec<AztecPoint> {
let center = code.getMatrix().getWidth() as i32 / 2;
let offset = if code.isCompact() { 5 } else { 7 };
let mut result = Vec::new();
@@ -271,12 +271,15 @@ fn get_orientation_points(code: &AztecCode) -> Vec<Point> {
let mut ySign: i32 = -1;
while ySign <= 1 {
// for (int ySign = -1; ySign <= 1; ySign += 2) {
result.push(Point::new(center + xSign * offset, center + ySign * offset));
result.push(Point::new(
result.push(AztecPoint::new(
center + xSign * offset,
center + ySign * offset,
));
result.push(AztecPoint::new(
center + xSign * (offset - 1),
center + ySign * offset,
));
result.push(Point::new(
result.push(AztecPoint::new(
center + xSign * offset,
center + ySign * (offset - 1),
));
4 changes: 2 additions & 2 deletions src/aztec/EncoderTest.rs
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ use crate::{
encoder::HighLevelEncoder,
shared_test_methods::{stripSpace, toBitArray, toBooleanArray},
},
BarcodeFormat, EncodeHintType, EncodeHintValue, RXingResultPoint,
BarcodeFormat, EncodeHintType, EncodeHintValue, Point,
};

use super::{encoder::aztec_encoder, AztecWriter};
@@ -50,7 +50,7 @@ const WINDOWS_1252: EncodingRef = encoding::all::WINDOWS_1252; //Charset.forName

// const DOTX: &str = "[^.X]";
// const SPACES: &str = "\\s+";
const NO_POINTS: [RXingResultPoint; 4] = [RXingResultPoint { x: 0.0, y: 0.0 }; 4];
const NO_POINTS: [Point; 4] = [Point { x: 0.0, y: 0.0 }; 4];

// real life tests

10 changes: 5 additions & 5 deletions src/aztec/aztec_detector_result.rs
Original file line number Diff line number Diff line change
@@ -16,13 +16,13 @@

// package com.google.zxing.aztec;

// import com.google.zxing.RXingResultPoint;
// import com.google.zxing.Point;
// import com.google.zxing.common.BitMatrix;
// import com.google.zxing.common.DetectorRXingResult;

use crate::{
common::{BitMatrix, DetectorRXingResult},
RXingResultPoint,
Point,
};

/**
@@ -33,7 +33,7 @@ use crate::{
*/
pub struct AztecDetectorRXingResult {
bits: BitMatrix,
points: [RXingResultPoint; 4],
points: [Point; 4],
compact: bool,
nbDatablocks: u32,
nbLayers: u32,
@@ -44,15 +44,15 @@ impl DetectorRXingResult for AztecDetectorRXingResult {
&self.bits
}

fn getPoints(&self) -> &[RXingResultPoint] {
fn getPoints(&self) -> &[Point] {
&self.points
}
}

impl AztecDetectorRXingResult {
pub fn new(
bits: BitMatrix,
points: [RXingResultPoint; 4],
points: [Point; 4],
compact: bool,
nbDatablocks: u32,
nbLayers: u32,
2 changes: 1 addition & 1 deletion src/aztec/aztec_reader.rs
Original file line number Diff line number Diff line change
@@ -92,7 +92,7 @@ impl Reader for AztecReader {
{
// if let DecodeHintValue::NeedResultPointCallback(cb) = rpcb {
for point in points {
cb(point);
cb(*point);
}
// }
}
Loading