mirror of
https://github.com/zxing/zxing.git
synced 2025-01-12 19:57:27 -08:00
Workaround (I think) for bizarre array corruption problem on Sun WTK and some SE phones
git-svn-id: https://zxing.googlecode.com/svn/trunk@619 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
edcf34f0c5
commit
09ce5db11d
|
@ -30,7 +30,8 @@ public final class LCDUIImageMonochromeBitmapSource extends BaseMonochromeBitmap
|
||||||
private final Image image;
|
private final Image image;
|
||||||
private final int height;
|
private final int height;
|
||||||
private final int width;
|
private final int width;
|
||||||
private final int[] rgbRow;
|
// For why this isn't final, see below
|
||||||
|
private int[] rgbRow;
|
||||||
private final int[] pixelHolder;
|
private final int[] pixelHolder;
|
||||||
private int cachedRow;
|
private int cachedRow;
|
||||||
|
|
||||||
|
@ -52,8 +53,13 @@ public final class LCDUIImageMonochromeBitmapSource extends BaseMonochromeBitmap
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLuminance(int x, int y) {
|
public int getLuminance(int x, int y) {
|
||||||
|
|
||||||
|
// Below, why the check for rgbRow being the right size? it should never change size
|
||||||
|
// or need to be reallocated. But bizarrely we have seen a but on Sun's WTK, and on
|
||||||
|
// some phones, where the array becomes zero-sized somehow. So we keep making sure the
|
||||||
|
// array is OK.
|
||||||
int pixel;
|
int pixel;
|
||||||
if (cachedRow == y) {
|
if (cachedRow == y && rgbRow.length == width) {
|
||||||
pixel = rgbRow[x];
|
pixel = rgbRow[x];
|
||||||
} else {
|
} else {
|
||||||
image.getRGB(pixelHolder, 0, width, x, y, 1, 1);
|
image.getRGB(pixelHolder, 0, width, x, y, 1, 1);
|
||||||
|
@ -79,6 +85,10 @@ public final class LCDUIImageMonochromeBitmapSource extends BaseMonochromeBitmap
|
||||||
|
|
||||||
public void cacheRowForLuminance(int y) {
|
public void cacheRowForLuminance(int y) {
|
||||||
if (y != cachedRow) {
|
if (y != cachedRow) {
|
||||||
|
// See explanation above
|
||||||
|
if (rgbRow.length != width) {
|
||||||
|
rgbRow = new int[width];
|
||||||
|
}
|
||||||
image.getRGB(rgbRow, 0, width, 0, y, width, 1);
|
image.getRGB(rgbRow, 0, width, 0, y, width, 1);
|
||||||
cachedRow = y;
|
cachedRow = y;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue