port qrcode metadata struct

This commit is contained in:
Henry Schimke
2022-10-05 14:02:53 -05:00
parent 4c51e2611c
commit 2e39ac061d
3 changed files with 154 additions and 155 deletions

View File

@@ -3,6 +3,7 @@ mod mode;
mod error_correction_level;
mod format_information;
mod data_block;
mod qr_code_decoder_metaData;
#[cfg(test)]
mod ErrorCorrectionLevelTestCase;
@@ -15,4 +16,5 @@ pub use version::*;
pub use mode::*;
pub use error_correction_level::*;
pub use format_information::*;
pub use data_block::*;
pub use data_block::*;
pub use qr_code_decoder_metaData::*;

View File

@@ -14,9 +14,7 @@
* limitations under the License.
*/
package com.google.zxing.qrcode.decoder;
import com.google.zxing.RXingResultPoint;
use crate::RXingResultPoint;
/**
* Meta-data container for QR Code decoding. Instances of this class may be used to convey information back to the
@@ -24,19 +22,18 @@ import com.google.zxing.RXingResultPoint;
*
* @see com.google.zxing.common.DecoderRXingResult#getOther()
*/
public final class QRCodeDecoderMetaData {
pub struct QRCodeDecoderMetaData(bool);
private final boolean mirrored;
QRCodeDecoderMetaData(boolean mirrored) {
this.mirrored = mirrored;
impl QRCodeDecoderMetaData {
pub fn new( mirrored:bool) -> Self {
Self(mirrored)
}
/**
* @return true if the QR Code was mirrored.
*/
public boolean isMirrored() {
return mirrored;
pub fn isMirrored(&self) -> bool{
self.0
}
/**
@@ -44,13 +41,13 @@ public final class QRCodeDecoderMetaData {
*
* @param points Array of points to apply mirror correction to.
*/
public void applyMirroredCorrection(RXingResultPoint[] points) {
if (!mirrored || points == null || points.length < 3) {
return;
pub fn applyMirroredCorrection(&self, points : &mut [RXingResultPoint]) {
if !self.0 || points.is_empty() || points.len() < 3 {
return
}
RXingResultPoint bottomLeft = points[0];
let bottom_left = points[0];
points[0] = points[2];
points[2] = bottomLeft;
points[2] = bottom_left;
// No need to 'fix' top-left and alignment pattern.
}