mirror of
https://github.com/zxing/zxing.git
synced 2025-01-13 04:07:27 -08:00
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:
parent
eed790a0bf
commit
5c17a1ad71
|
@ -54,6 +54,8 @@ public interface MonochromeBitmapSource {
|
|||
*/
|
||||
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
|
||||
*/
|
||||
|
@ -110,7 +112,7 @@ public interface MonochromeBitmapSource {
|
|||
* @param y The y coordinate in the image.
|
||||
* @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
|
||||
|
@ -123,7 +125,7 @@ public interface MonochromeBitmapSource {
|
|||
* 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.
|
||||
*/
|
||||
public abstract int[] getLuminanceRow(int y, int[] row);
|
||||
int[] getLuminanceRow(int y, int[] row);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @return The array containing the luminance data.
|
||||
*/
|
||||
public abstract int[] getLuminanceColumn(int x, int[] column);
|
||||
int[] getLuminanceColumn(int x, int[] column);
|
||||
|
||||
}
|
||||
|
|
|
@ -106,6 +106,22 @@ public abstract class BaseMonochromeBitmapSource implements MonochromeBitmapSour
|
|||
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)
|
||||
throws ReaderException {
|
||||
if (!method.equals(lastMethod) || argument != lastArgument) {
|
||||
|
|
|
@ -21,7 +21,7 @@ import com.google.zxing.MonochromeBitmapSource;
|
|||
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
|
||||
*/
|
||||
|
@ -72,6 +72,10 @@ public final class CroppedMonochromeBitmapSource implements MonochromeBitmapSour
|
|||
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)
|
||||
throws ReaderException {
|
||||
// Hmm, the delegate will probably base this on the whole image though...
|
||||
|
|
Loading…
Reference in a new issue