mirror of
https://github.com/zxing/zxing.git
synced 2024-09-20 13:37:34 -07:00
Converted the last user of the old MonochromeBitmapSource-style calls over to BitMatrix, and removed these deprecated methods.
git-svn-id: https://zxing.googlecode.com/svn/trunk@1012 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
c31b489efe
commit
e44f00ba75
|
@ -77,7 +77,8 @@ public final class BinaryBitmap {
|
|||
public BitMatrix getBlackMatrix() throws ReaderException {
|
||||
// The matrix is created on demand the first time it is requested, then cached. There are two
|
||||
// reasons for this:
|
||||
// 1. This work will never be done if the caller only installs 1D Reader objects.
|
||||
// 1. This work will never be done if the caller only installs 1D Reader objects, or if a
|
||||
// 1D Reader finds a barcode before the 2D Readers run.
|
||||
// 2. This work will only be done once even if the caller installs multiple 2D Readers.
|
||||
if (matrix == null) {
|
||||
matrix = binarizer.getBlackMatrix();
|
||||
|
@ -124,78 +125,4 @@ public final class BinaryBitmap {
|
|||
return new BinaryBitmap(binarizer.createBinarizer(newSource));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*
|
||||
* FIXME: REMOVE!
|
||||
* These three methods are TEMPORARY and should be removed by the end of July 2009.
|
||||
* They are only here so the transition from MonochromeBitmapSource to BinaryBitmap
|
||||
* can be done in stages. We need to go through all the Reader objects and convert
|
||||
* these calls to getBlackRow() and getBlackMatrix() at the top of this file.
|
||||
*
|
||||
* TIP: Replace calls to isBlack() with a single call to getBlackMatrix(), then call
|
||||
* BitMatrix.get(x, y) per pixel.
|
||||
*/
|
||||
public boolean isBlack(int x, int y) throws ReaderException {
|
||||
if (matrix == null) {
|
||||
matrix = binarizer.getBlackMatrix();
|
||||
}
|
||||
return matrix.get(x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*
|
||||
* FIXME: REMOVE!
|
||||
*
|
||||
* TIP: 2D Readers should replace uses of this method with a single call to getBlackMatrix(),
|
||||
* then perform random access on that BitMatrix as needed. The version of getBlackRow() with
|
||||
* two arguments is only meant for 1D Readers, which I've already converted.
|
||||
*/
|
||||
public BitArray getBlackRow(int y, BitArray row, int startX, int getWidth)
|
||||
throws ReaderException {
|
||||
if (row == null || row.getSize() < getWidth) {
|
||||
row = new BitArray(getWidth);
|
||||
} else {
|
||||
row.clear();
|
||||
}
|
||||
|
||||
if (matrix == null) {
|
||||
matrix = binarizer.getBlackMatrix();
|
||||
}
|
||||
for (int x = 0; x < getWidth; x++) {
|
||||
if (matrix.get(startX + x, y)) {
|
||||
row.set(x);
|
||||
}
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*
|
||||
* FIXME: REMOVE!
|
||||
*
|
||||
* TIP: Replace calls to getBlackColumn() with a single call to getBlackMatrix(), then
|
||||
* perform random access on that BitMatrix as needed.
|
||||
*/
|
||||
public BitArray getBlackColumn(int x, BitArray column, int startY, int getHeight)
|
||||
throws ReaderException {
|
||||
if (column == null || column.getSize() < getHeight) {
|
||||
column = new BitArray(getHeight);
|
||||
} else {
|
||||
column.clear();
|
||||
}
|
||||
|
||||
if (matrix == null) {
|
||||
matrix = binarizer.getBlackMatrix();
|
||||
}
|
||||
for (int y = 0; y < getHeight; y++) {
|
||||
if (matrix.get(x, startY + y)) {
|
||||
column.set(y);
|
||||
}
|
||||
}
|
||||
return column;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -77,14 +77,14 @@ public final class PDF417Reader implements Reader {
|
|||
*/
|
||||
private static BitMatrix extractPureBits(BinaryBitmap image) throws ReaderException {
|
||||
// Now need to determine module size in pixels
|
||||
|
||||
int height = image.getHeight();
|
||||
int width = image.getWidth();
|
||||
BitMatrix matrix = image.getBlackMatrix();
|
||||
int height = matrix.getHeight();
|
||||
int width = matrix.getWidth();
|
||||
int minDimension = Math.min(height, width);
|
||||
|
||||
// First, skip white border by tracking diagonally from the top left down and to the right:
|
||||
int borderWidth = 0;
|
||||
while (borderWidth < minDimension && !image.isBlack(borderWidth, borderWidth)) {
|
||||
while (borderWidth < minDimension && !matrix.get(borderWidth, borderWidth)) {
|
||||
borderWidth++;
|
||||
}
|
||||
if (borderWidth == minDimension) {
|
||||
|
@ -93,7 +93,7 @@ public final class PDF417Reader implements Reader {
|
|||
|
||||
// And then keep tracking across the top-left black module to determine module size
|
||||
int moduleEnd = borderWidth;
|
||||
while (moduleEnd < minDimension && image.isBlack(moduleEnd, moduleEnd)) {
|
||||
while (moduleEnd < minDimension && matrix.get(moduleEnd, moduleEnd)) {
|
||||
moduleEnd++;
|
||||
}
|
||||
if (moduleEnd == minDimension) {
|
||||
|
@ -104,7 +104,7 @@ public final class PDF417Reader implements Reader {
|
|||
|
||||
// And now find where the rightmost black module on the first row ends
|
||||
int rowEndOfSymbol = width - 1;
|
||||
while (rowEndOfSymbol >= 0 && !image.isBlack(rowEndOfSymbol, borderWidth)) {
|
||||
while (rowEndOfSymbol >= 0 && !matrix.get(rowEndOfSymbol, borderWidth)) {
|
||||
rowEndOfSymbol--;
|
||||
}
|
||||
if (rowEndOfSymbol < 0) {
|
||||
|
@ -130,15 +130,14 @@ public final class PDF417Reader implements Reader {
|
|||
|
||||
// Now just read off the bits
|
||||
BitMatrix bits = new BitMatrix(dimension);
|
||||
for (int i = 0; i < dimension; i++) {
|
||||
int iOffset = borderWidth + i * moduleSize;
|
||||
for (int j = 0; j < dimension; j++) {
|
||||
if (image.isBlack(borderWidth + j * moduleSize, iOffset)) {
|
||||
bits.set(i, j);
|
||||
for (int y = 0; y < dimension; y++) {
|
||||
int iOffset = borderWidth + y * moduleSize;
|
||||
for (int x = 0; x < dimension; x++) {
|
||||
if (matrix.get(borderWidth + x * moduleSize, iOffset)) {
|
||||
bits.set(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
return bits;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue