boolean inBlack = image.isBlack(steep ? fromY : fromX, steep ? fromX : fromY);
for (int x = fromX, y = fromY; x != toX; x += xstep) {
boolean isBlack = image.isBlack(steep ? y : x, steep ? x : y);
- if (isBlack == !inBlack) {
+ if (isBlack != inBlack) {
transitions++;
inBlack = isBlack;
}
int i = start;
while (i < end) {
boolean pixel = row.get(i);
- if ((!pixel && isWhite) || (pixel && !isWhite)) {
+ if (pixel ^ isWhite) { // that is, exactly one is true
counters[counterPosition]++;
} else {
counterPosition++;
break;
} else {
counters[counterPosition] = 1;
- isWhite = !isWhite;
+ isWhite ^= true; // isWhite = !isWhite; Is this too clever? shorter byte code, no conditional
}
}
i++;
int patternStart = rowOffset;
for (int x = rowOffset; x < width; x++) {
boolean pixel = row.get(x);
- if ((!pixel && isWhite) || (pixel && !isWhite)) {
+ if (pixel ^ isWhite) {
counters[counterPosition]++;
} else {
if (counterPosition == patternLength - 1) {
counterPosition++;
}
counters[counterPosition] = 1;
- isWhite = !isWhite;
+ isWhite ^= true; // isWhite = !isWhite;
}
}
throw ReaderException.getInstance();
for (int i = rowOffset; i < width; i++) {
boolean pixel = row.get(i);
- if ((!pixel && isWhite) || (pixel && !isWhite)) {
+ if (pixel ^ isWhite) {
counters[counterPosition]++;
} else {
if (counterPosition == patternLength - 1) {
counterPosition++;
}
counters[counterPosition] = 1;
- isWhite = !isWhite;
+ isWhite ^= true; // isWhite = !isWhite;
}
}
throw ReaderException.getInstance();
for (int i = rowOffset; i < width; i++) {
boolean pixel = row.get(i);
- if ((!pixel && isWhite) || (pixel && !isWhite)) {
+ if (pixel ^ isWhite) {
counters[counterPosition]++;
} else {
if (counterPosition == patternLength - 1) {
counterPosition++;
}
counters[counterPosition] = 1;
- isWhite = !isWhite;
+ isWhite ^= true; // isWhite = !isWhite;
}
}
throw ReaderException.getInstance();
int patternStart = rowOffset;\r
for (int x = rowOffset; x < width; x++) {\r
boolean pixel = row.get(x);\r
- if ((!pixel && isWhite) || (pixel && !isWhite)) {\r
+ if (pixel ^ isWhite) {\r
counters[counterPosition]++;\r
} else {\r
if (counterPosition == patternLength - 1) {\r
counterPosition++;\r
}\r
counters[counterPosition] = 1;\r
- isWhite = !isWhite;\r
+ isWhite ^= true; // isWhite = !isWhite;\r
}\r
}\r
throw ReaderException.getInstance();\r
}\r
}\r
}\r
- readingUp = !readingUp; // switch directions\r
+ readingUp ^= true; // readingUp = !readingUp; // switch directions\r
}\r
if (resultOffset != version.getTotalCodewords()) {\r
throw ReaderException.getInstance();\r