Issue 511

git-svn-id: https://zxing.googlecode.com/svn/trunk@1522 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2010-08-12 20:18:08 +00:00
parent b7f70012ca
commit 6c9812e9bb
5 changed files with 36 additions and 18 deletions

View file

@ -266,9 +266,9 @@ public class Detector {
if (otherToX < 0) {
scale = (float) fromX / (float) (fromX - otherToX);
otherToX = 0;
} else if (otherToX >= image.getWidth()) {
scale = (float) (image.getWidth() - 1 - fromX) / (float) (otherToX - fromX);
otherToX = image.getWidth() - 1;
} else if (otherToX > image.getWidth()) {
scale = (float) (image.getWidth() - fromX) / (float) (otherToX - fromX);
otherToX = image.getWidth();
}
int otherToY = (int) (fromY - (toY - fromY) * scale);
@ -276,14 +276,14 @@ public class Detector {
if (otherToY < 0) {
scale = (float) fromY / (float) (fromY - otherToY);
otherToY = 0;
} else if (otherToY >= image.getHeight()) {
scale = (float) (image.getHeight() - 1 - fromY) / (float) (otherToY - fromY);
otherToY = image.getHeight() - 1;
} else if (otherToY > image.getHeight()) {
scale = (float) (image.getHeight() - fromY) / (float) (otherToY - fromY);
otherToY = image.getHeight();
}
otherToX = (int) (fromX + (otherToX - fromX) * scale);
result += sizeOfBlackWhiteBlackRun(fromX, fromY, otherToX, otherToY);
return result - 1.0f; // -1 because we counted the middle pixel twice
return result;
}
/**
@ -330,6 +330,9 @@ public class Detector {
if (state == 3) { // Found black, white, black, and stumbled back onto white; done
int diffX = x - fromX;
int diffY = y - fromY;
if (xstep < 0) {
diffX++;
}
return (float) Math.sqrt((double) (diffX * diffX + diffY * diffY));
}
error += dy;

Binary file not shown.

After

Width:  |  Height:  |  Size: 708 B

View file

@ -0,0 +1,12 @@
BEGIN:VCARD
N:Kennedy;Steve
TEL:+44 (0)7775 755503
ADR;HOME:;;Flat 2, 43 Howitt Road, Belsize Park;London;;NW34LU;UK
ORG:NetTek Ltd;
TITLE:Consultant
EMAIL:steve@nettek.co.uk
URL:www.nettek.co.uk
EMAIL;IM:MSN:steve@gbnet.net
NOTE:Testing 1 2 3
BDAY:19611105
END:VCARD

View file

@ -27,10 +27,10 @@ public final class QRCodeBlackBox2TestCase extends AbstractBlackBoxTestCase {
public QRCodeBlackBox2TestCase() {
super("test/data/blackbox/qrcode-2", new MultiFormatReader(), BarcodeFormat.QR_CODE);
addTest(23, 23, 0.0f);
addTest(21, 21, 90.0f);
addTest(23, 23, 180.0f);
addTest(20, 21, 270.0f);
addTest(26, 26, 0.0f);
addTest(24, 24, 90.0f);
addTest(24, 24, 180.0f);
addTest(22, 23, 270.0f);
}
}

View file

@ -185,9 +185,9 @@ float Detector::sizeOfBlackWhiteBlackRunBothWays(int fromX, int fromY, int toX,
if (otherToX < 0) {
scale = (float) fromX / (float) (fromX - otherToX);
otherToX = 0;
} else if (otherToX >= (int)image_->getWidth()) {
scale = (float) (image_->getWidth() - 1 - fromX) / (float) (otherToX - fromX);
otherToX = image_->getWidth() - 1;
} else if (otherToX > (int)image_->getWidth()) {
scale = (float) (image_->getWidth() - fromX) / (float) (otherToX - fromX);
otherToX = image_->getWidth();
}
int otherToY = (int) (fromY - (toY - fromY) * scale);
@ -195,14 +195,14 @@ float Detector::sizeOfBlackWhiteBlackRunBothWays(int fromX, int fromY, int toX,
if (otherToY < 0) {
scale = (float) fromY / (float) (fromY - otherToY);
otherToY = 0;
} else if (otherToY >= (int)image_->getHeight()) {
scale = (float) (image_->getHeight() - 1 - fromY) / (float) (otherToY - fromY);
otherToY = image_->getHeight() - 1;
} else if (otherToY > (int)image_->getHeight()) {
scale = (float) (image_->getHeight() - fromY) / (float) (otherToY - fromY);
otherToY = image_->getHeight();
}
otherToX = (int) (fromX + (otherToX - fromX) * scale);
result += sizeOfBlackWhiteBlackRun(fromX, fromY, otherToX, otherToY);
return result - 1.0f; // -1 because we counted the middle pixel twice
return result;
}
float Detector::sizeOfBlackWhiteBlackRun(int fromX, int fromY, int toX, int toY) {
@ -241,6 +241,9 @@ float Detector::sizeOfBlackWhiteBlackRun(int fromX, int fromY, int toX, int toY)
if (state == 3) { // Found black, white, black, and stumbled back onto white; done
int diffX = x - fromX;
int diffY = y - fromY;
if (xstep < 0) {
diffX++;
}
return (float)sqrt((double)(diffX * diffX + diffY * diffY));
}
error += dy;