@@ -52,21 +52,28 @@ impl Decoder {
52
52
pub fn decode ( & self , bits : & BitMatrix ) -> Result < DecoderRXingResult , Exceptions > {
53
53
let decoded = self . perform_decode ( bits, false ) ;
54
54
if decoded. is_ok ( ) {
55
- return decoded
55
+ return decoded;
56
56
}
57
57
58
- self . perform_decode ( & Self :: flip_bitmatrix ( bits) ?, false )
58
+ self . perform_decode ( & Self :: flip_bitmatrix ( bits) ?, false )
59
59
}
60
60
61
- fn flip_bitmatrix ( bits : & BitMatrix ) -> Result < BitMatrix , Exceptions >
62
- {
63
- let mut res = BitMatrix :: new ( bits. getHeight ( ) , bits. getWidth ( ) ) ?;
64
- for y in 0 ..res. getHeight ( ) {
65
- for x in 0 ..res. getWidth ( ) {
66
- { res. set_bool ( x, y, bits. get ( bits. getWidth ( ) - 1 - y, bits. getHeight ( ) - 1 - x) ) ; } } }
67
-
68
- Ok ( res)
69
- }
61
+ fn flip_bitmatrix ( bits : & BitMatrix ) -> Result < BitMatrix , Exceptions > {
62
+ let mut res = BitMatrix :: new ( bits. getHeight ( ) , bits. getWidth ( ) ) ?;
63
+ for y in 0 ..res. getHeight ( ) {
64
+ for x in 0 ..res. getWidth ( ) {
65
+ {
66
+ res. set_bool (
67
+ x,
68
+ y,
69
+ bits. get ( bits. getWidth ( ) - 1 - y, bits. getHeight ( ) - 1 - x) ,
70
+ ) ;
71
+ }
72
+ }
73
+ }
74
+
75
+ Ok ( res)
76
+ }
70
77
71
78
/**
72
79
* <p>Convenience method that can decode a Data Matrix Code represented as a 2D array of booleans.
@@ -78,7 +85,7 @@ impl Decoder {
78
85
* @throws ChecksumException if error correction fails
79
86
*/
80
87
pub fn decode_bools ( & self , image : & Vec < Vec < bool > > ) -> Result < DecoderRXingResult , Exceptions > {
81
- self . perform_decode ( & BitMatrix :: parse_bools ( image) , false )
88
+ self . perform_decode ( & BitMatrix :: parse_bools ( image) , false )
82
89
}
83
90
84
91
/**
@@ -90,7 +97,11 @@ impl Decoder {
90
97
* @throws FormatException if the Data Matrix Code cannot be decoded
91
98
* @throws ChecksumException if error correction fails
92
99
*/
93
- fn perform_decode ( & self , bits : & BitMatrix , fix259 : bool ) -> Result < DecoderRXingResult , Exceptions > {
100
+ fn perform_decode (
101
+ & self ,
102
+ bits : & BitMatrix ,
103
+ fix259 : bool ,
104
+ ) -> Result < DecoderRXingResult , Exceptions > {
94
105
// Construct a parser and read version, error-correction level
95
106
let mut parser = BitMatrixParser :: new ( bits) ?;
96
107
@@ -119,8 +130,8 @@ impl Decoder {
119
130
let errors_corrected = self . correctErrors ( & mut codewordBytes, numDataCodewords as u32 ) ;
120
131
if errors_corrected. is_err ( ) && !fix259 {
121
132
return self . perform_decode ( bits, true ) ;
122
- } else if errors_corrected. is_err ( ) {
123
- return Err ( errors_corrected. err ( ) . unwrap ( ) )
133
+ } else if errors_corrected. is_err ( ) {
134
+ return Err ( errors_corrected. err ( ) . unwrap ( ) ) ;
124
135
}
125
136
for i in 0 ..numDataCodewords {
126
137
// for (int i = 0; i < numDataCodewords; i++) {
0 commit comments