mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Small tweak to last commit and test count, enable explicit conversion everywhere and patch a strange Java 7-only (JIT?) issue
git-svn-id: https://zxing.googlecode.com/svn/trunk@2495 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
33cb6a0745
commit
0636cb7b08
|
@ -116,6 +116,7 @@
|
||||||
<enable/>
|
<enable/>
|
||||||
</assertions>
|
</assertions>
|
||||||
<jvmarg value="-Djava.awt.headless=true"/>
|
<jvmarg value="-Djava.awt.headless=true"/>
|
||||||
|
<jvmarg value="-DexplicitLuminanceConversion=true"/>
|
||||||
<batchtest>
|
<batchtest>
|
||||||
<fileset dir="test/src">
|
<fileset dir="test/src">
|
||||||
<include name="**/*TestCase.java"/>
|
<include name="**/*TestCase.java"/>
|
||||||
|
|
|
@ -25,6 +25,7 @@ import com.google.zxing.Result;
|
||||||
import com.google.zxing.ResultPoint;
|
import com.google.zxing.ResultPoint;
|
||||||
import com.google.zxing.common.BitArray;
|
import com.google.zxing.common.BitArray;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -171,6 +172,9 @@ public final class Code39Reader extends OneDReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int[] findAsteriskPattern(BitArray row, int[] counters) throws NotFoundException {
|
private static int[] findAsteriskPattern(BitArray row, int[] counters) throws NotFoundException {
|
||||||
|
// Should not be needed, but appears to work around a Java 7 JIT bug? This comes in corrupted
|
||||||
|
Arrays.fill(counters, 0);
|
||||||
|
|
||||||
int width = row.getSize();
|
int width = row.getSize();
|
||||||
int rowOffset = row.getNextSet(0);
|
int rowOffset = row.getNextSet(0);
|
||||||
|
|
||||||
|
@ -223,7 +227,7 @@ public final class Code39Reader extends OneDReader {
|
||||||
int pattern = 0;
|
int pattern = 0;
|
||||||
for (int i = 0; i < numCounters; i++) {
|
for (int i = 0; i < numCounters; i++) {
|
||||||
int counter = counters[i];
|
int counter = counters[i];
|
||||||
if (counters[i] > maxNarrowCounter) {
|
if (counter > maxNarrowCounter) {
|
||||||
pattern |= 1 << (numCounters - 1 - i);
|
pattern |= 1 << (numCounters - 1 - i);
|
||||||
wideCounters++;
|
wideCounters++;
|
||||||
totalWideCountersWidth += counter;
|
totalWideCountersWidth += counter;
|
||||||
|
@ -235,7 +239,7 @@ public final class Code39Reader extends OneDReader {
|
||||||
// counter is more than 1.5 times the average:
|
// counter is more than 1.5 times the average:
|
||||||
for (int i = 0; i < numCounters && wideCounters > 0; i++) {
|
for (int i = 0; i < numCounters && wideCounters > 0; i++) {
|
||||||
int counter = counters[i];
|
int counter = counters[i];
|
||||||
if (counters[i] > maxNarrowCounter) {
|
if (counter > maxNarrowCounter) {
|
||||||
wideCounters--;
|
wideCounters--;
|
||||||
// totalWideCountersWidth = 3 * average, so this checks if counter >= 3/2 * average
|
// totalWideCountersWidth = 3 * average, so this checks if counter >= 3/2 * average
|
||||||
if ((counter << 1) >= totalWideCountersWidth) {
|
if ((counter << 1) >= totalWideCountersWidth) {
|
||||||
|
|
|
@ -77,13 +77,12 @@ public final class BufferedImageLuminanceSource extends LuminanceSource {
|
||||||
pixel = 0xFFFFFFFF; // = white
|
pixel = 0xFFFFFFFF; // = white
|
||||||
}
|
}
|
||||||
|
|
||||||
int luminance = 0;
|
|
||||||
// .229R + 0.587G + 0.114B (YUV/YIQ for PAL and NTSC)
|
// .229R + 0.587G + 0.114B (YUV/YIQ for PAL and NTSC)
|
||||||
luminance = (306 * ((pixel >> 16) & 0xFF) +
|
buffer[x] =
|
||||||
|
(306 * ((pixel >> 16) & 0xFF) +
|
||||||
601 * ((pixel >> 8) & 0xFF) +
|
601 * ((pixel >> 8) & 0xFF) +
|
||||||
117 * (pixel & 0xFF) +
|
117 * (pixel & 0xFF) +
|
||||||
(0x200)) >> 10; // 0x200 = 1<<9, half an lsb of the result to force rounding
|
0x200) >> 10;
|
||||||
buffer[x] = luminance;
|
|
||||||
}
|
}
|
||||||
raster.setPixels(left, y, width, 1, buffer);
|
raster.setPixels(left, y, width, 1, buffer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ public final class RSS14BlackBox2TestCase extends AbstractBlackBoxTestCase {
|
||||||
|
|
||||||
public RSS14BlackBox2TestCase() {
|
public RSS14BlackBox2TestCase() {
|
||||||
super("test/data/blackbox/rss14-2", new MultiFormatReader(), BarcodeFormat.RSS_14);
|
super("test/data/blackbox/rss14-2", new MultiFormatReader(), BarcodeFormat.RSS_14);
|
||||||
addTest(3, 8, 1, 1, 0.0f);
|
addTest(4, 8, 1, 1, 0.0f);
|
||||||
addTest(2, 8, 0, 1, 180.0f);
|
addTest(2, 8, 0, 1, 180.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,13 +79,12 @@ public final class BufferedImageLuminanceSource extends LuminanceSource {
|
||||||
pixel = 0xFFFFFFFF; // = white
|
pixel = 0xFFFFFFFF; // = white
|
||||||
}
|
}
|
||||||
|
|
||||||
int luminance = 0;
|
|
||||||
// .229R + 0.587G + 0.114B (YUV/YIQ for PAL and NTSC)
|
// .229R + 0.587G + 0.114B (YUV/YIQ for PAL and NTSC)
|
||||||
luminance = (306 * ((pixel >> 16) & 0xFF) +
|
buffer[x] =
|
||||||
|
(306 * ((pixel >> 16) & 0xFF) +
|
||||||
601 * ((pixel >> 8) & 0xFF) +
|
601 * ((pixel >> 8) & 0xFF) +
|
||||||
117 * (pixel & 0xFF) +
|
117 * (pixel & 0xFF) +
|
||||||
(0x200)) >> 10; // 0x200 = 1<<9, half an lsb of the result to force rounding
|
0x200) >> 10;
|
||||||
buffer[x] = luminance;
|
|
||||||
}
|
}
|
||||||
raster.setPixels(left, y, width, 1, buffer);
|
raster.setPixels(left, y, width, 1, buffer);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue