Various user-contributed fixes (Issue 701, Issue 710, Issue 714, Issue 718)

git-svn-id: https://zxing.googlecode.com/svn/trunk@1717 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2011-02-15 13:23:14 +00:00
parent 71ddbf6f08
commit 7a6cc4c3d0
8 changed files with 38 additions and 24 deletions

View file

@ -42,8 +42,11 @@ public final class WhiteRectangleDetector {
private final int rightInit;
private final int downInit;
private final int upInit;
public WhiteRectangleDetector(BitMatrix image) {
/**
* @throws NotFoundException if image is too small
*/
public WhiteRectangleDetector(BitMatrix image) throws NotFoundException {
this.image = image;
height = image.getHeight();
width = image.getWidth();
@ -51,17 +54,26 @@ public final class WhiteRectangleDetector {
rightInit = (width + INIT_SIZE) >> 1;
upInit = (height - INIT_SIZE) >> 1;
downInit = (height + INIT_SIZE) >> 1;
if (upInit < 0 || leftInit < 0 || downInit >= height || rightInit >= width) {
throw NotFoundException.getNotFoundInstance();
}
}
public WhiteRectangleDetector(BitMatrix image, int INIT_SIZE, int x, int y) {
this.image = image;
height = image.getHeight();
width = image.getWidth();
int halfsize = INIT_SIZE >> 1;
leftInit = x - halfsize;
rightInit = x + halfsize;
upInit = y - halfsize;
downInit = y + halfsize;
/**
* @throws NotFoundException if image is too small
*/
public WhiteRectangleDetector(BitMatrix image, int initSize, int x, int y) throws NotFoundException {
this.image = image;
height = image.getHeight();
width = image.getWidth();
int halfsize = initSize >> 1;
leftInit = x - halfsize;
rightInit = x + halfsize;
upInit = y - halfsize;
downInit = y + halfsize;
if (upInit < 0 || leftInit < 0 || downInit >= height || rightInit >= width) {
throw NotFoundException.getNotFoundInstance();
}
}
/**
@ -71,7 +83,7 @@ public final class WhiteRectangleDetector {
* region until it finds a white rectangular region.
* </p>
*
* @return {@link ResultPoint}[] describing the corners of the rectangular
* @return {@link ResultPoint[]} describing the corners of the rectangular
* region. The first and last points are opposed on the diagonal, as
* are the second and third. The first point will be the topmost
* point and the last, the bottommost. The second point will be

View file

@ -401,7 +401,7 @@ final class DecodedBitStreamParser {
int edifactValue = bits.readBits(6);
// Check for the unlatch character
if (edifactValue == 0x2B67) { // 011111
if (edifactValue == 0x1F) { // 011111
unlatch = true;
// If we encounter the unlatch code then continue reading because the Codeword triple
// is padded with 0's
@ -423,14 +423,15 @@ final class DecodedBitStreamParser {
private static void decodeBase256Segment(BitSource bits, StringBuffer result, Vector byteSegments)
throws FormatException {
// Figure out how long the Base 256 Segment is.
int d1 = bits.readBits(8);
int codewordPosition = 2;
int d1 = unrandomize255State(bits.readBits(8), codewordPosition++);
int count;
if (d1 == 0) { // Read the remainder of the symbol
count = bits.available() / 8;
} else if (d1 < 250) {
count = d1;
} else {
count = 250 * (d1 - 249) + bits.readBits(8);
count = 250 * (d1 - 249) + unrandomize255State(bits.readBits(8), codewordPosition++);
}
byte[] bytes = new byte[count];
for (int i = 0; i < count; i++) {
@ -439,7 +440,7 @@ final class DecodedBitStreamParser {
if (bits.available() < 8) {
throw FormatException.getFormatInstance();
}
bytes[i] = unrandomize255State(bits.readBits(8), i);
bytes[i] = unrandomize255State(bits.readBits(8), codewordPosition++);
}
byteSegments.addElement(bytes);
try {

View file

@ -46,7 +46,7 @@ public final class Detector {
private final BitMatrix image;
private final WhiteRectangleDetector rectangleDetector;
public Detector(BitMatrix image) {
public Detector(BitMatrix image) throws NotFoundException {
this.image = image;
rectangleDetector = new WhiteRectangleDetector(image);
}

View file

@ -252,7 +252,7 @@ final class DecodedBitStreamParser {
} else {
if (subModeCh == 26) {
ch = ' ';
} else if (subModeCh == AL) {
} else if (subModeCh == AS) {
subMode = ALPHA;
} else if (subModeCh == ML) {
subMode = MIXED;

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View file

@ -0,0 +1 @@
0123456789

View file

@ -27,10 +27,10 @@ public final class DataMatrixBlackBox1TestCase extends AbstractBlackBoxTestCase
public DataMatrixBlackBox1TestCase() {
super("test/data/blackbox/datamatrix-1", new MultiFormatReader(), BarcodeFormat.DATA_MATRIX);
addTest(16, 16, 0.0f);
addTest(16, 16, 90.0f);
addTest(16, 16, 180.0f);
addTest(16, 16, 270.0f);
addTest(17, 17, 0.0f);
addTest(17, 17, 90.0f);
addTest(17, 17, 180.0f);
addTest(17, 17, 270.0f);
}
}

View file

@ -17,7 +17,7 @@ if env['PIC']:
flags.append("-fPIC")
compile_options['CXXFLAGS'] = ' '.join(flags)
compile_options['LINKFLAGS'] = "-ldl"
def all_files(dir, ext='.cpp', level=5):
files = []