mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
fix mirrored and remove unsuported test case
This commit is contained in:
@@ -263,6 +263,14 @@ impl BitMatrix {
|
|||||||
self.bits[offset] |= 1 << (x & 0x1f);
|
self.bits[offset] |= 1 << (x & 0x1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_bool(&mut self, x: u32, y: u32, value: bool) {
|
||||||
|
if value {
|
||||||
|
self.set(x, y)
|
||||||
|
}else {
|
||||||
|
self.unset(x, y)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn unset(&mut self, x: u32, y: u32) {
|
pub fn unset(&mut self, x: u32, y: u32) {
|
||||||
let offset = self.get_offset(y, x);
|
let offset = self.get_offset(y, x);
|
||||||
self.bits[offset] &= !(1 << (x & 0x1f));
|
self.bits[offset] &= !(1 << (x & 0x1f));
|
||||||
|
|||||||
@@ -50,9 +50,24 @@ impl Decoder {
|
|||||||
* @throws ChecksumException if error correction fails
|
* @throws ChecksumException if error correction fails
|
||||||
*/
|
*/
|
||||||
pub fn decode(&self, bits: &BitMatrix) -> Result<DecoderRXingResult, Exceptions> {
|
pub fn decode(&self, bits: &BitMatrix) -> Result<DecoderRXingResult, Exceptions> {
|
||||||
self.perform_decode(bits, false)
|
let decoded = self.perform_decode(bits, false);
|
||||||
|
if decoded.is_ok() {
|
||||||
|
return decoded
|
||||||
|
}
|
||||||
|
|
||||||
|
self.perform_decode(&Self::flip_bitmatrix(bits)?, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn flip_bitmatrix( bits:&BitMatrix) -> Result<BitMatrix,Exceptions>
|
||||||
|
{
|
||||||
|
let mut res = BitMatrix::new(bits.getHeight(), bits.getWidth())?;
|
||||||
|
for y in 0..res.getHeight() {
|
||||||
|
for x in 0..res.getWidth() {
|
||||||
|
{res.set_bool(x, y, bits.get(bits.getWidth() - 1 - y, bits.getHeight() - 1 - x));}}}
|
||||||
|
|
||||||
|
Ok(res)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Convenience method that can decode a Data Matrix Code represented as a 2D array of booleans.
|
* <p>Convenience method that can decode a Data Matrix Code represented as a 2D array of booleans.
|
||||||
* "true" is taken to mean a black module.</p>
|
* "true" is taken to mean a black module.</p>
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 132 B |
@@ -1,2 +0,0 @@
|
|||||||
symbologyIdentifier=]d1
|
|
||||||
readerInit=true
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
$I
|
|
||||||
@@ -29,10 +29,10 @@ fn data_matrix_black_box1_test_case() {
|
|||||||
rxing::BarcodeFormat::DATA_MATRIX,
|
rxing::BarcodeFormat::DATA_MATRIX,
|
||||||
);
|
);
|
||||||
// super("src/test/resources/blackbox/datamatrix-1", new MultiFormatReader(), BarcodeFormat.DATA_MATRIX);
|
// super("src/test/resources/blackbox/datamatrix-1", new MultiFormatReader(), BarcodeFormat.DATA_MATRIX);
|
||||||
tester.add_test(27, 29, 0.0);
|
tester.add_test(27, 28, 0.0);
|
||||||
tester.add_test(21, 27, 90.0);
|
tester.add_test(21, 26, 90.0);
|
||||||
tester.add_test(21, 27, 180.0);
|
tester.add_test(21, 26, 180.0);
|
||||||
tester.add_test(21, 27, 270.0);
|
tester.add_test(21, 26, 270.0);
|
||||||
|
|
||||||
tester.test_black_box();
|
tester.test_black_box();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user