Added getBlackDiagonal() which I likely want to use later

git-svn-id: https://zxing.googlecode.com/svn/trunk@968 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2009-06-11 13:42:39 +00:00
parent eed790a0bf
commit 5c17a1ad71
3 changed files with 26 additions and 4 deletions

View file

@ -54,6 +54,8 @@ public interface MonochromeBitmapSource {
*/ */
BitArray getBlackColumn(int x, BitArray column, int startY, int getHeight); BitArray getBlackColumn(int x, BitArray column, int startY, int getHeight);
BitArray getBlackDiagonal(int x, int y, int dx, int dy, BitArray diagonal, int size);
/** /**
* @return height of underlying image * @return height of underlying image
*/ */
@ -110,7 +112,7 @@ public interface MonochromeBitmapSource {
* @param y The y coordinate in the image. * @param y The y coordinate in the image.
* @return The luminance value between 0 and 255. * @return The luminance value between 0 and 255.
*/ */
public abstract int getLuminance(int x, int y); int getLuminance(int x, int y);
/** /**
* This is the main mechanism for retrieving luminance data. It is dramatically more efficient * This is the main mechanism for retrieving luminance data. It is dramatically more efficient
@ -123,7 +125,7 @@ public interface MonochromeBitmapSource {
* but then I will take pity on you and allocate a sufficient array internally. * but then I will take pity on you and allocate a sufficient array internally.
* @return The array containing the luminance data. This is the same as row if it was usable. * @return The array containing the luminance data. This is the same as row if it was usable.
*/ */
public abstract int[] getLuminanceRow(int y, int[] row); int[] getLuminanceRow(int y, int[] row);
/** /**
* The same as getLuminanceRow(), but for columns. * The same as getLuminanceRow(), but for columns.
@ -132,6 +134,6 @@ public interface MonochromeBitmapSource {
* @param column The array to write luminance values into. See above. * @param column The array to write luminance values into. See above.
* @return The array containing the luminance data. * @return The array containing the luminance data.
*/ */
public abstract int[] getLuminanceColumn(int x, int[] column); int[] getLuminanceColumn(int x, int[] column);
} }

View file

@ -106,6 +106,22 @@ public abstract class BaseMonochromeBitmapSource implements MonochromeBitmapSour
return column; return column;
} }
public BitArray getBlackDiagonal(int x, int y, int dx, int dy, BitArray diagonal, int size) {
if (diagonal == null || diagonal.getSize() < size) {
diagonal = new BitArray(size);
} else {
diagonal.clear();
}
for (int i = 0; i < size; i++) {
if (isBlack(x, y)) {
diagonal.set(i);
}
x += dx;
y += dy;
}
return diagonal;
}
public void estimateBlackPoint(BlackPointEstimationMethod method, int argument) public void estimateBlackPoint(BlackPointEstimationMethod method, int argument)
throws ReaderException { throws ReaderException {
if (!method.equals(lastMethod) || argument != lastArgument) { if (!method.equals(lastMethod) || argument != lastArgument) {

View file

@ -21,7 +21,7 @@ import com.google.zxing.MonochromeBitmapSource;
import com.google.zxing.ReaderException; import com.google.zxing.ReaderException;
/** /**
* Encapulates a cropped region of another {@link com.google.zxing.MonochromeBitmapSource}. * Encapulates a cropped region of another {@link MonochromeBitmapSource}.
* *
* @author Sean Owen * @author Sean Owen
*/ */
@ -72,6 +72,10 @@ public final class CroppedMonochromeBitmapSource implements MonochromeBitmapSour
return right - left; return right - left;
} }
public BitArray getBlackDiagonal(int x, int y, int dx, int dy, BitArray diagonal, int size) {
return delegate.getBlackDiagonal(left + x, top + y, dx, dy, diagonal, size);
}
public void estimateBlackPoint(BlackPointEstimationMethod method, int argument) public void estimateBlackPoint(BlackPointEstimationMethod method, int argument)
throws ReaderException { throws ReaderException {
// Hmm, the delegate will probably base this on the whole image though... // Hmm, the delegate will probably base this on the whole image though...