mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
Merge branch 'main' into pr/point_refactor
This commit is contained in:
@@ -80,7 +80,7 @@ impl Reader for QRCodeReader {
|
||||
// if (decoderRXingResult.getOther() instanceof QRCodeDecoderMetaData) {
|
||||
other
|
||||
.downcast_ref::<QRCodeDecoderMetaData>()
|
||||
.ok_or(Exceptions::IllegalStateException(None))?
|
||||
.ok_or(Exceptions::illegalState)?
|
||||
.applyMirroredCorrection(&mut points);
|
||||
}
|
||||
}
|
||||
@@ -150,12 +150,11 @@ impl QRCodeReader {
|
||||
let leftTopBlack = image.getTopLeftOnBit();
|
||||
let rightBottomBlack = image.getBottomRightOnBit();
|
||||
if leftTopBlack.is_none() || rightBottomBlack.is_none() {
|
||||
return Err(Exceptions::NotFoundException(None));
|
||||
return Err(Exceptions::notFound);
|
||||
}
|
||||
|
||||
let leftTopBlack = leftTopBlack.ok_or(Exceptions::IndexOutOfBoundsException(None))?;
|
||||
let rightBottomBlack =
|
||||
rightBottomBlack.ok_or(Exceptions::IndexOutOfBoundsException(None))?;
|
||||
let leftTopBlack = leftTopBlack.ok_or(Exceptions::indexOutOfBounds)?;
|
||||
let rightBottomBlack = rightBottomBlack.ok_or(Exceptions::indexOutOfBounds)?;
|
||||
|
||||
let moduleSize = Self::moduleSize(&leftTopBlack, image)?;
|
||||
|
||||
@@ -166,7 +165,7 @@ impl QRCodeReader {
|
||||
|
||||
// Sanity check!
|
||||
if left >= right || top >= bottom {
|
||||
return Err(Exceptions::NotFoundException(None));
|
||||
return Err(Exceptions::notFound);
|
||||
}
|
||||
|
||||
if bottom - top != right - left {
|
||||
@@ -175,17 +174,17 @@ impl QRCodeReader {
|
||||
right = left + (bottom - top);
|
||||
if right >= image.getWidth() as i32 {
|
||||
// Abort if that would not make sense -- off image
|
||||
return Err(Exceptions::NotFoundException(None));
|
||||
return Err(Exceptions::notFound);
|
||||
}
|
||||
}
|
||||
let matrixWidth = ((right as f32 - left as f32 + 1.0) / moduleSize).round() as u32;
|
||||
let matrixHeight = ((bottom as f32 - top as f32 + 1.0) / moduleSize).round() as u32;
|
||||
if matrixWidth == 0 || matrixHeight == 0 {
|
||||
return Err(Exceptions::NotFoundException(None));
|
||||
return Err(Exceptions::notFound);
|
||||
}
|
||||
if matrixHeight != matrixWidth {
|
||||
// Only possibly decode square regions
|
||||
return Err(Exceptions::NotFoundException(None));
|
||||
return Err(Exceptions::notFound);
|
||||
}
|
||||
|
||||
// Push in the "border" by half the module width so that we start
|
||||
@@ -203,7 +202,7 @@ impl QRCodeReader {
|
||||
if nudgedTooFarRight > 0 {
|
||||
if nudgedTooFarRight > nudge as i32 {
|
||||
// Neither way fits; abort
|
||||
return Err(Exceptions::NotFoundException(None));
|
||||
return Err(Exceptions::notFound);
|
||||
}
|
||||
left -= nudgedTooFarRight;
|
||||
}
|
||||
@@ -212,7 +211,7 @@ impl QRCodeReader {
|
||||
if nudgedTooFarDown > 0 {
|
||||
if nudgedTooFarDown > nudge as i32 {
|
||||
// Neither way fits; abort
|
||||
return Err(Exceptions::NotFoundException(None));
|
||||
return Err(Exceptions::notFound);
|
||||
}
|
||||
top -= nudgedTooFarDown;
|
||||
}
|
||||
@@ -249,7 +248,7 @@ impl QRCodeReader {
|
||||
y += 1;
|
||||
}
|
||||
if x == width || y == height {
|
||||
return Err(Exceptions::NotFoundException(None));
|
||||
return Err(Exceptions::notFound);
|
||||
}
|
||||
Ok((x - leftTopBlack[0]) as f32 / 7.0)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user