mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
add point(x: f32, y: f32) function
Shorter than writing `Point::new`
This commit is contained in:
@@ -18,7 +18,7 @@ use std::rc::Rc;
|
||||
|
||||
use crate::{
|
||||
common::{BitMatrix, Result},
|
||||
Exceptions, Point, ResultPoint,
|
||||
point, Exceptions, Point, ResultPoint,
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -58,13 +58,13 @@ impl BoundingBox {
|
||||
if leftUnspecified {
|
||||
newTopRight = topRight.ok_or(Exceptions::IllegalStateException(None))?;
|
||||
newBottomRight = bottomRight.ok_or(Exceptions::IllegalStateException(None))?;
|
||||
newTopLeft = Point::new(0.0, newTopRight.getY());
|
||||
newBottomLeft = Point::new(0.0, newBottomRight.getY());
|
||||
newTopLeft = point(0.0, newTopRight.getY());
|
||||
newBottomLeft = point(0.0, newBottomRight.getY());
|
||||
} else if rightUnspecified {
|
||||
newTopLeft = topLeft.ok_or(Exceptions::IllegalStateException(None))?;
|
||||
newBottomLeft = bottomLeft.ok_or(Exceptions::IllegalStateException(None))?;
|
||||
newTopRight = Point::new(image.getWidth() as f32 - 1.0, newTopLeft.getY());
|
||||
newBottomRight = Point::new(image.getWidth() as f32 - 1.0, newBottomLeft.getY());
|
||||
newTopRight = point(image.getWidth() as f32 - 1.0, newTopLeft.getY());
|
||||
newBottomRight = point(image.getWidth() as f32 - 1.0, newBottomLeft.getY());
|
||||
} else {
|
||||
newTopLeft = topLeft.ok_or(Exceptions::IllegalStateException(None))?;
|
||||
newTopRight = topRight.ok_or(Exceptions::IllegalStateException(None))?;
|
||||
@@ -144,7 +144,7 @@ impl BoundingBox {
|
||||
if newMinY < 0.0 {
|
||||
newMinY = 0.0;
|
||||
}
|
||||
let newTop = Point::new(top.getX(), newMinY);
|
||||
let newTop = point(top.getX(), newMinY);
|
||||
if isLeft {
|
||||
newTopLeft = newTop;
|
||||
} else {
|
||||
@@ -162,7 +162,7 @@ impl BoundingBox {
|
||||
if newMaxY >= self.image.getHeight() {
|
||||
newMaxY = self.image.getHeight() - 1;
|
||||
}
|
||||
let newBottom = Point::new(bottom.getX(), newMaxY as f32);
|
||||
let newBottom = point(bottom.getX(), newMaxY as f32);
|
||||
if isLeft {
|
||||
newBottomLeft = newBottom;
|
||||
} else {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
use crate::{
|
||||
common::{BitMatrix, Result},
|
||||
BinaryBitmap, DecodingHintDictionary, Exceptions, Point, ResultPoint,
|
||||
point, BinaryBitmap, DecodingHintDictionary, Exceptions, Point, ResultPoint,
|
||||
};
|
||||
|
||||
use std::borrow::Cow;
|
||||
@@ -245,8 +245,8 @@ fn findRowsWithPattern(
|
||||
break;
|
||||
}
|
||||
}
|
||||
result[0] = Some(Point::new(loc_store.as_ref()?[0] as f32, startRow as f32));
|
||||
result[1] = Some(Point::new(loc_store.as_ref()?[1] as f32, startRow as f32));
|
||||
result[0] = Some(point(loc_store.as_ref()?[0] as f32, startRow as f32));
|
||||
result[1] = Some(point(loc_store.as_ref()?[1] as f32, startRow as f32));
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
@@ -294,8 +294,8 @@ fn findRowsWithPattern(
|
||||
stopRow += 1;
|
||||
}
|
||||
stopRow -= skippedRowCount + 1;
|
||||
result[2] = Some(Point::new(previousRowLoc[0] as f32, stopRow as f32));
|
||||
result[3] = Some(Point::new(previousRowLoc[1] as f32, stopRow as f32));
|
||||
result[2] = Some(point(previousRowLoc[0] as f32, stopRow as f32));
|
||||
result[3] = Some(point(previousRowLoc[1] as f32, stopRow as f32));
|
||||
}
|
||||
if stopRow - startRow < BARCODE_MIN_HEIGHT {
|
||||
result.fill(None);
|
||||
|
||||
Reference in New Issue
Block a user