X-Git-Url: http://git.rot13.org/?p=zxing.git;a=blobdiff_plain;f=javame%2Fsrc%2Fcom%2Fgoogle%2Fzxing%2Fclient%2Fj2me%2FLCDUIImageMonochromeBitmapSource.java;h=fb06732f2bc2079b3878ffd85a3e9b68990865a1;hp=7c4f2eb81b597a08d820ce378b0d9248260fc83e;hb=762bd23db2057a97f6b0d55f227ee13ee3b822c6;hpb=43fda281a1556d8dc7be7cc810f06e108ccafcb5 diff --git a/javame/src/com/google/zxing/client/j2me/LCDUIImageMonochromeBitmapSource.java b/javame/src/com/google/zxing/client/j2me/LCDUIImageMonochromeBitmapSource.java index 7c4f2eb8..fb06732f 100644 --- a/javame/src/com/google/zxing/client/j2me/LCDUIImageMonochromeBitmapSource.java +++ b/javame/src/com/google/zxing/client/j2me/LCDUIImageMonochromeBitmapSource.java @@ -29,28 +29,17 @@ import javax.microedition.lcdui.Image; public final class LCDUIImageMonochromeBitmapSource extends BaseMonochromeBitmapSource { private final Image image; - private final int height; - private final int width; private final int[] pixelHolder; public LCDUIImageMonochromeBitmapSource(Image image) { + super(image.getHeight(), image.getWidth()); this.image = image; - height = image.getHeight(); - width = image.getWidth(); pixelHolder = new int[1]; } - public int getHeight() { - return height; - } - - public int getWidth() { - return width; - } - // This is expensive and should be used very sparingly. protected int getLuminance(int x, int y) { - image.getRGB(pixelHolder, 0, width, x, y, 1, 1); + image.getRGB(pixelHolder, 0, getWidth(), x, y, 1, 1); int pixel = pixelHolder[0]; // Instead of multiplying by 306, 601, 117, we multiply by 256, 512, 256, so that @@ -72,6 +61,7 @@ public final class LCDUIImageMonochromeBitmapSource extends BaseMonochromeBitmap // For efficiency, the RGB data and the luminance data share the same array. protected int[] getLuminanceRow(int y, int[] row) { + int width = getWidth(); if (row == null || row.length < width) { row = new int[width]; } @@ -86,6 +76,7 @@ public final class LCDUIImageMonochromeBitmapSource extends BaseMonochromeBitmap } protected int[] getLuminanceColumn(int x, int[] column) { + int height = getHeight(); if (column == null || column.length < height) { column = new int[height]; }