X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=javame%2Fsrc%2Fcom%2Fgoogle%2Fzxing%2Fclient%2Fj2me%2FLCDUIImageMonochromeBitmapSource.java;h=b65b715939974329f069627251ad0a76f92b5dbc;hb=7eec24ee881d16e10dac4228adb5aa199eec0b29;hp=e82525761319c6651b2e8a30f6ae962d16da692c;hpb=2cf44178b43d1fa6960fec0d9051d043753ea11b;p=zxing.git diff --git a/javame/src/com/google/zxing/client/j2me/LCDUIImageMonochromeBitmapSource.java b/javame/src/com/google/zxing/client/j2me/LCDUIImageMonochromeBitmapSource.java index e8252576..b65b7159 100644 --- a/javame/src/com/google/zxing/client/j2me/LCDUIImageMonochromeBitmapSource.java +++ b/javame/src/com/google/zxing/client/j2me/LCDUIImageMonochromeBitmapSource.java @@ -23,33 +23,31 @@ import javax.microedition.lcdui.Image; /** *

An implementation based on Java ME's {@link Image} representation.

* - * @author Sean Owen (srowen@google.com), Daniel Switkin (dswitkin@google.com) + * @author Sean Owen + * @author Daniel Switkin (dswitkin@google.com) */ 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.getWidth(), image.getHeight()); this.image = image; - height = image.getHeight(); - width = image.getWidth(); pixelHolder = new int[1]; } - public int getHeight() { - return height; + public final int getHeight() { + return image.getHeight(); } - public int getWidth() { - return width; + public final int getWidth() { + return image.getWidth(); } // 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 @@ -71,6 +69,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]; } @@ -85,6 +84,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]; }