mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Changed the order of the BaseMonochromeBitmapSource constructor arguments to be width, height to match the rest of the codebase, and added two apparently missing methods to the J2ME subclass, although I can't test it.
git-svn-id: https://zxing.googlecode.com/svn/trunk@874 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
6fe022eb10
commit
c1bc060065
|
@ -78,7 +78,7 @@ public final class YUVMonochromeBitmapSource extends BaseMonochromeBitmapSource
|
||||||
int cropLeft,
|
int cropLeft,
|
||||||
int cropBottom,
|
int cropBottom,
|
||||||
int cropRight) {
|
int cropRight) {
|
||||||
super(cropBottom - cropTop, cropRight - cropLeft);
|
super(cropRight - cropLeft, cropBottom - cropTop);
|
||||||
if (cropRight - cropLeft > dataWidth || cropBottom - cropTop > dataHeight) {
|
if (cropRight - cropLeft > dataWidth || cropBottom - cropTop > dataHeight) {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public final class RGBMonochromeBitmapSource extends BaseMonochromeBitmapSource
|
||||||
}
|
}
|
||||||
|
|
||||||
public RGBMonochromeBitmapSource(Bitmap bitmap) {
|
public RGBMonochromeBitmapSource(Bitmap bitmap) {
|
||||||
super(bitmap.getHeight(), bitmap.getWidth());
|
super(bitmap.getWidth(), bitmap.getHeight());
|
||||||
int width = bitmap.getWidth();
|
int width = bitmap.getWidth();
|
||||||
int height = bitmap.getHeight();
|
int height = bitmap.getHeight();
|
||||||
int[] pixels = new int[width * height];
|
int[] pixels = new int[width * height];
|
||||||
|
|
|
@ -36,7 +36,7 @@ public final class AWTImageMonochromeBitmapSource extends BaseMonochromeBitmapSo
|
||||||
private final int[] pixels;
|
private final int[] pixels;
|
||||||
|
|
||||||
public AWTImageMonochromeBitmapSource(Image image) throws ReaderException {
|
public AWTImageMonochromeBitmapSource(Image image) throws ReaderException {
|
||||||
super(image.getHeight(null), image.getWidth(null));
|
super(image.getWidth(null), image.getHeight(null));
|
||||||
int height = getHeight();
|
int height = getHeight();
|
||||||
int width = getWidth();
|
int width = getWidth();
|
||||||
pixels = new int[height * width];
|
pixels = new int[height * width];
|
||||||
|
|
|
@ -35,7 +35,7 @@ public abstract class BaseMonochromeBitmapSource implements MonochromeBitmapSour
|
||||||
private int lastArgument;
|
private int lastArgument;
|
||||||
private int[] luminances;
|
private int[] luminances;
|
||||||
|
|
||||||
protected BaseMonochromeBitmapSource(int height, int width) {
|
protected BaseMonochromeBitmapSource(int width, int height) {
|
||||||
this.height = height;
|
this.height = height;
|
||||||
this.width = width;
|
this.width = width;
|
||||||
blackPoint = 0x7F;
|
blackPoint = 0x7F;
|
||||||
|
|
|
@ -32,11 +32,19 @@ public final class LCDUIImageMonochromeBitmapSource extends BaseMonochromeBitmap
|
||||||
private final int[] pixelHolder;
|
private final int[] pixelHolder;
|
||||||
|
|
||||||
public LCDUIImageMonochromeBitmapSource(Image image) {
|
public LCDUIImageMonochromeBitmapSource(Image image) {
|
||||||
super(image.getHeight(), image.getWidth());
|
super(image.getWidth(), image.getHeight());
|
||||||
this.image = image;
|
this.image = image;
|
||||||
pixelHolder = new int[1];
|
pixelHolder = new int[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final int getHeight() {
|
||||||
|
return image.getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int getWidth() {
|
||||||
|
return image.getWidth();
|
||||||
|
}
|
||||||
|
|
||||||
// This is expensive and should be used very sparingly.
|
// This is expensive and should be used very sparingly.
|
||||||
protected int getLuminance(int x, int y) {
|
protected int getLuminance(int x, int y) {
|
||||||
image.getRGB(pixelHolder, 0, getWidth(), x, y, 1, 1);
|
image.getRGB(pixelHolder, 0, getWidth(), x, y, 1, 1);
|
||||||
|
|
|
@ -57,17 +57,20 @@ public final class BufferedImageMonochromeBitmapSource extends BaseMonochromeBit
|
||||||
* @param image image to decode a region of
|
* @param image image to decode a region of
|
||||||
* @param left x coordinate of leftmost pixels to decode
|
* @param left x coordinate of leftmost pixels to decode
|
||||||
* @param top y coordinate of topmost pixels to decode
|
* @param top y coordinate of topmost pixels to decode
|
||||||
* @param right one more than the x coordinate of rightmost pixels to decode. That is, we will decode
|
* @param right one more than the x coordinate of rightmost pixels to decode, i.e. we will decode
|
||||||
* pixels whose x coordinate is in [left,right)
|
* pixels whose x coordinate is in [left,right)
|
||||||
* @param bottom likewise, one more than the y coordinate of the bottommost pixels to decode
|
* @param bottom likewise, one more than the y coordinate of the bottommost pixels to decode
|
||||||
*/
|
*/
|
||||||
public BufferedImageMonochromeBitmapSource(BufferedImage image, int left, int top, int right, int bottom) {
|
public BufferedImageMonochromeBitmapSource(BufferedImage image, int left, int top, int right,
|
||||||
super(bottom - top, right - left);
|
int bottom) {
|
||||||
|
super(right - left, bottom - top);
|
||||||
this.image = image;
|
this.image = image;
|
||||||
int sourceHeight = image.getHeight();
|
int sourceHeight = image.getHeight();
|
||||||
int sourceWidth = image.getWidth();
|
int sourceWidth = image.getWidth();
|
||||||
if (left < 0 || top < 0 || right > sourceWidth || bottom > sourceHeight || right <= left || bottom <= top) {
|
if (left < 0 || top < 0 || right > sourceWidth || bottom > sourceHeight || right <= left ||
|
||||||
throw new IllegalArgumentException("Invalid bounds: (" + top + ',' + left + ") (" + right + ',' + bottom + ')');
|
bottom <= top) {
|
||||||
|
throw new IllegalArgumentException("Invalid bounds: (" + top + ',' + left + ") (" + right +
|
||||||
|
',' + bottom + ')');
|
||||||
}
|
}
|
||||||
this.left = left;
|
this.left = left;
|
||||||
this.top = top;
|
this.top = top;
|
||||||
|
@ -75,7 +78,8 @@ public final class BufferedImageMonochromeBitmapSource extends BaseMonochromeBit
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return underlying {@link BufferedImage} behind this instance. Note that even if this instance
|
* @return underlying {@link BufferedImage} behind this instance. Note that even if this instance
|
||||||
* only uses a subset of the full image, the returned value here represents the entire backing image.
|
* only uses a subset of the full image, the returned value here represents the entire backing
|
||||||
|
* image.
|
||||||
*/
|
*/
|
||||||
public BufferedImage getImage() {
|
public BufferedImage getImage() {
|
||||||
return image;
|
return image;
|
||||||
|
@ -88,9 +92,11 @@ public final class BufferedImageMonochromeBitmapSource extends BaseMonochromeBit
|
||||||
}
|
}
|
||||||
int sourceWidth = image.getWidth();
|
int sourceWidth = image.getWidth();
|
||||||
int sourceHeight = image.getHeight();
|
int sourceHeight = image.getHeight();
|
||||||
|
|
||||||
// 90 degrees counterclockwise:
|
// 90 degrees counterclockwise:
|
||||||
AffineTransform transform = new AffineTransform(0.0, -1.0, 1.0, 0.0, 0.0, sourceWidth);
|
AffineTransform transform = new AffineTransform(0.0, -1.0, 1.0, 0.0, 0.0, sourceWidth);
|
||||||
BufferedImageOp op = new AffineTransformOp(transform, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
|
BufferedImageOp op = new AffineTransformOp(transform, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
|
||||||
|
|
||||||
// Note width/height are flipped since we are rotating 90 degrees:
|
// Note width/height are flipped since we are rotating 90 degrees:
|
||||||
BufferedImage rotatedImage = new BufferedImage(sourceHeight, sourceWidth, image.getType());
|
BufferedImage rotatedImage = new BufferedImage(sourceHeight, sourceWidth, image.getType());
|
||||||
op.filter(image, rotatedImage);
|
op.filter(image, rotatedImage);
|
||||||
|
|
Loading…
Reference in a new issue