Various code tweaks and refactorings suggested by IntelliJ

git-svn-id: https://zxing.googlecode.com/svn/trunk@246 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2008-03-05 17:26:44 +00:00
parent c82d0790c3
commit a78f7f40d5
26 changed files with 69 additions and 88 deletions

View file

@ -176,20 +176,20 @@ public final class BarcodeReaderCaptureActivity extends Activity {
} }
private static boolean canBeHandled(ParsedReaderResultType type) { private static boolean canBeHandled(ParsedReaderResultType type) {
return type != ParsedReaderResultType.TEXT; return !type.equals(ParsedReaderResultType.TEXT);
} }
private static int getDialogTitleID(ParsedReaderResultType type) { private static int getDialogTitleID(ParsedReaderResultType type) {
if (type == ParsedReaderResultType.ADDRESSBOOK) { if (type.equals(ParsedReaderResultType.ADDRESSBOOK)) {
return R.string.title_add_contact; return R.string.title_add_contact;
} else if (type == ParsedReaderResultType.URI || } else if (type.equals(ParsedReaderResultType.URI) ||
type == ParsedReaderResultType.BOOKMARK || type.equals(ParsedReaderResultType.BOOKMARK) ||
type == ParsedReaderResultType.URLTO) { type.equals(ParsedReaderResultType.URLTO)) {
return R.string.title_open_url; return R.string.title_open_url;
} else if (type == ParsedReaderResultType.EMAIL || } else if (type.equals(ParsedReaderResultType.EMAIL) ||
type == ParsedReaderResultType.EMAIL_ADDRESS) { type.equals(ParsedReaderResultType.EMAIL_ADDRESS)) {
return R.string.title_compose_email; return R.string.title_compose_email;
} else if (type == ParsedReaderResultType.UPC) { } else if (type.equals(ParsedReaderResultType.UPC)) {
return R.string.title_lookup_barcode; return R.string.title_lookup_barcode;
} else { } else {
return R.string.title_barcode_detected; return R.string.title_barcode_detected;

View file

@ -38,15 +38,15 @@ final class CameraManager {
private static final String TAG = "CameraManager"; private static final String TAG = "CameraManager";
private Context context; private final Context context;
private Point cameraResolution; private Point cameraResolution;
private Point stillResolution; private Point stillResolution;
private int stillMultiplier; private int stillMultiplier;
private Point screenResolution; private Point screenResolution;
private Rect framingRect; private Rect framingRect;
private Bitmap bitmap; private final Bitmap bitmap;
private CameraDevice camera; private CameraDevice camera;
private CameraDevice.CaptureParams params; private final CameraDevice.CaptureParams params;
private boolean previewMode; private boolean previewMode;
CameraManager(Context context) { CameraManager(Context context) {
@ -200,7 +200,7 @@ final class CameraManager {
// The camera driver can only capture images which are a multiple of eight, so it's necessary to // The camera driver can only capture images which are a multiple of eight, so it's necessary to
// round up. // round up.
nativeResolution = (nativeResolution + 7) / 8 * 8; nativeResolution = ((nativeResolution + 7) >> 3) << 3;
if (nativeResolution > minDimension) { if (nativeResolution > minDimension) {
nativeResolution = minDimension; nativeResolution = minDimension;
} }

View file

@ -33,8 +33,8 @@ final class CameraSurfaceView extends SurfaceView implements SurfaceHolder.Callb
private static final int[] SCANNER_ALPHA = {0, 64, 128, 192, 255, 192, 128, 64}; private static final int[] SCANNER_ALPHA = {0, 64, 128, 192, 255, 192, 128, 64};
private CameraManager cameraManager; private final CameraManager cameraManager;
private SurfaceHolder surfaceHolder; private final SurfaceHolder surfaceHolder;
private boolean hasSurface; private boolean hasSurface;
private int scannerAlpha; private int scannerAlpha;

View file

@ -25,9 +25,6 @@ package com.google.zxing;
*/ */
public final class ReaderException extends Exception { public final class ReaderException extends Exception {
public ReaderException() {
}
public ReaderException(String message) { public ReaderException(String message) {
super(message); super(message);
} }

View file

@ -48,7 +48,7 @@ public final class URIParsedResult extends ParsedReaderResult {
* Transforms a string that possibly represents a URI into something more proper, by adding or canonicalizing * Transforms a string that possibly represents a URI into something more proper, by adding or canonicalizing
* the protocol. * the protocol.
*/ */
static String massagePossibleURI(String uri) { private static String massagePossibleURI(String uri) {
// Take off leading "URL:" if present // Take off leading "URL:" if present
if (uri.startsWith("URL:")) { if (uri.startsWith("URL:")) {
uri = uri.substring(4); uri = uri.substring(4);

View file

@ -24,7 +24,7 @@ package com.google.zxing.common;
public final class BitArray { public final class BitArray {
private int[] bits; private int[] bits;
private int size; private final int size;
public BitArray(int size) { public BitArray(int size) {
this.size = size; this.size = size;

View file

@ -90,7 +90,7 @@ public final class GF256 {
* *
* @return sum/difference of a and b * @return sum/difference of a and b
*/ */
int addOrSubtract(int a, int b) { static int addOrSubtract(int a, int b) {
return a ^ b; return a ^ b;
} }

View file

@ -99,17 +99,18 @@ final class GF256Poly {
// Just the sum of the coefficients // Just the sum of the coefficients
int result = 0; int result = 0;
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
result = field.addOrSubtract(result, coefficients[i]); result = GF256.addOrSubtract(result, coefficients[i]);
} }
return result; return result;
} }
int result = coefficients[0]; int result = coefficients[0];
for (int i = 1; i < size; i++) { for (int i = 1; i < size; i++) {
result = field.addOrSubtract(field.multiply(a, result), coefficients[i]); result = GF256.addOrSubtract(field.multiply(a, result), coefficients[i]);
} }
return result; return result;
} }
/*
int evaluateFormatDerivativeAt(int a) { int evaluateFormatDerivativeAt(int a) {
int degree = getDegree(); int degree = getDegree();
if (degree == 0) { if (degree == 0) {
@ -126,6 +127,7 @@ final class GF256Poly {
} }
return sum; return sum;
} }
*/
GF256Poly addOrSubtract(GF256Poly other) { GF256Poly addOrSubtract(GF256Poly other) {
if (!field.equals(other.field)) { if (!field.equals(other.field)) {
@ -151,7 +153,7 @@ final class GF256Poly {
System.arraycopy(largerCoefficients, 0, sumDiff, 0, lengthDiff); System.arraycopy(largerCoefficients, 0, sumDiff, 0, lengthDiff);
for (int i = lengthDiff; i < largerCoefficients.length; i++) { for (int i = lengthDiff; i < largerCoefficients.length; i++) {
sumDiff[i] = field.addOrSubtract(smallerCoefficients[i - lengthDiff], largerCoefficients[i]); sumDiff[i] = GF256.addOrSubtract(smallerCoefficients[i - lengthDiff], largerCoefficients[i]);
} }
return new GF256Poly(field, sumDiff); return new GF256Poly(field, sumDiff);
@ -172,7 +174,7 @@ final class GF256Poly {
for (int i = 0; i < aLength; i++) { for (int i = 0; i < aLength; i++) {
int aCoeff = aCoefficients[i]; int aCoeff = aCoefficients[i];
for (int j = 0; j < bLength; j++) { for (int j = 0; j < bLength; j++) {
product[i + j] = field.addOrSubtract(product[i + j], product[i + j] = GF256.addOrSubtract(product[i + j],
field.multiply(aCoeff, bCoefficients[j])); field.multiply(aCoeff, bCoefficients[j]));
} }
} }

View file

@ -70,7 +70,7 @@ public final class ReedSolomonDecoder {
int[] errorMagnitudes = findErrorMagnitudes(sigmaOmega[1], errorLocations); int[] errorMagnitudes = findErrorMagnitudes(sigmaOmega[1], errorLocations);
for (int i = 0; i < errorLocations.length; i++) { for (int i = 0; i < errorLocations.length; i++) {
int position = received.length - 1 - field.log(errorLocations[i]); int position = received.length - 1 - field.log(errorLocations[i]);
received[position] = field.addOrSubtract(received[position], errorMagnitudes[i]); received[position] = GF256.addOrSubtract(received[position], errorMagnitudes[i]);
} }
} }
} }
@ -161,7 +161,7 @@ public final class ReedSolomonDecoder {
for (int j = 0; j < s; j++) { for (int j = 0; j < s; j++) {
if (i != j) { if (i != j) {
denominator = field.multiply(denominator, denominator = field.multiply(denominator,
field.addOrSubtract(1, field.multiply(errorLocations[j], xiInverse))); GF256.addOrSubtract(1, field.multiply(errorLocations[j], xiInverse)));
} }
} }
result[i] = field.multiply(errorEvaluator.evaluateAt(xiInverse), result[i] = field.multiply(errorEvaluator.evaluateAt(xiInverse),

View file

@ -24,9 +24,6 @@ package com.google.zxing.common.reedsolomon;
*/ */
public final class ReedSolomonException extends Exception { public final class ReedSolomonException extends Exception {
public ReedSolomonException() {
}
public ReedSolomonException(String message) { public ReedSolomonException(String message) {
super(message); super(message);
} }

View file

@ -98,7 +98,7 @@ public abstract class AbstractOneDReader implements OneDReader {
throw new ReaderException("No barcode found"); throw new ReaderException("No barcode found");
} }
protected static void recordPattern(BitArray row, int start, int[] counters) throws ReaderException { static void recordPattern(BitArray row, int start, int[] counters) throws ReaderException {
int numCounters = counters.length; int numCounters = counters.length;
for (int i = 0; i < numCounters; i++) { for (int i = 0; i < numCounters; i++) {
counters[i] = 0; counters[i] = 0;
@ -141,7 +141,7 @@ public abstract class AbstractOneDReader implements OneDReader {
* @param pattern expected pattern * @param pattern expected pattern
* @return average variance between counters and pattern * @return average variance between counters and pattern
*/ */
protected static float patternMatchVariance(int[] counters, int[] pattern) { static float patternMatchVariance(int[] counters, int[] pattern) {
int total = 0; int total = 0;
int numCounters = counters.length; int numCounters = counters.length;
int patternLength = 0; int patternLength = 0;
@ -161,13 +161,4 @@ public abstract class AbstractOneDReader implements OneDReader {
return totalVariance / (float) patternLength; return totalVariance / (float) patternLength;
} }
/**
* Fast round method.
*
* @return argument rounded to nearest int
*/
protected static int round(float f) {
return (int) (f + 0.5f);
}
} }

View file

@ -40,17 +40,17 @@ public abstract class AbstractUPCEANReader extends AbstractOneDReader implements
/** /**
* Start/end guard pattern. * Start/end guard pattern.
*/ */
protected static final int[] START_END_PATTERN = {1, 1, 1,}; private static final int[] START_END_PATTERN = {1, 1, 1,};
/** /**
* Pattern marking the middle of a UPC/EAN pattern, separating the two halves. * Pattern marking the middle of a UPC/EAN pattern, separating the two halves.
*/ */
protected static final int[] MIDDLE_PATTERN = {1, 1, 1, 1, 1}; static final int[] MIDDLE_PATTERN = {1, 1, 1, 1, 1};
/** /**
* "Odd", or "L" patterns used to encode UPC/EAN digits. * "Odd", or "L" patterns used to encode UPC/EAN digits.
*/ */
protected static final int[][] L_PATTERNS = { static final int[][] L_PATTERNS = {
{3, 2, 1, 1}, // 0 {3, 2, 1, 1}, // 0
{2, 2, 2, 1}, // 1 {2, 2, 2, 1}, // 1
{2, 1, 2, 2}, // 2 {2, 1, 2, 2}, // 2
@ -66,7 +66,7 @@ public abstract class AbstractUPCEANReader extends AbstractOneDReader implements
/** /**
* As above but also including the "even", or "G" patterns used to encode UPC/EAN digits. * As above but also including the "even", or "G" patterns used to encode UPC/EAN digits.
*/ */
protected static final int[][] L_AND_G_PATTERNS; static final int[][] L_AND_G_PATTERNS;
static { static {
L_AND_G_PATTERNS = new int[20][]; L_AND_G_PATTERNS = new int[20][];
@ -139,7 +139,7 @@ public abstract class AbstractUPCEANReader extends AbstractOneDReader implements
* @return true iff string of digits passes the UPC/EAN checksum algorithm * @return true iff string of digits passes the UPC/EAN checksum algorithm
* @throws ReaderException if the string does not contain only digits * @throws ReaderException if the string does not contain only digits
*/ */
protected boolean checkChecksum(String s) throws ReaderException { boolean checkChecksum(String s) throws ReaderException {
int sum = 0; int sum = 0;
int length = s.length(); int length = s.length();
for (int i = length - 2; i >= 0; i -= 2) { for (int i = length - 2; i >= 0; i -= 2) {
@ -172,7 +172,7 @@ public abstract class AbstractUPCEANReader extends AbstractOneDReader implements
protected abstract int decodeMiddle(BitArray row, int[] startRange, StringBuffer resultString) protected abstract int decodeMiddle(BitArray row, int[] startRange, StringBuffer resultString)
throws ReaderException; throws ReaderException;
protected int[] decodeEnd(BitArray row, int endStart) throws ReaderException { int[] decodeEnd(BitArray row, int endStart) throws ReaderException {
return findGuardPattern(row, endStart, false, START_END_PATTERN); return findGuardPattern(row, endStart, false, START_END_PATTERN);
} }
@ -186,7 +186,7 @@ public abstract class AbstractUPCEANReader extends AbstractOneDReader implements
* @return start/end horizontal offset of guard pattern, as an array of two ints * @return start/end horizontal offset of guard pattern, as an array of two ints
* @throws ReaderException if pattern is not found * @throws ReaderException if pattern is not found
*/ */
protected static int[] findGuardPattern(BitArray row, int rowOffset, boolean whiteFirst, int[] pattern) static int[] findGuardPattern(BitArray row, int rowOffset, boolean whiteFirst, int[] pattern)
throws ReaderException { throws ReaderException {
int patternLength = pattern.length; int patternLength = pattern.length;
int[] counters = new int[patternLength]; int[] counters = new int[patternLength];
@ -240,7 +240,7 @@ public abstract class AbstractUPCEANReader extends AbstractOneDReader implements
* @return horizontal offset of first pixel beyond the decoded digit * @return horizontal offset of first pixel beyond the decoded digit
* @throws ReaderException if digit cannot be decoded * @throws ReaderException if digit cannot be decoded
*/ */
protected static int decodeDigit(BitArray row, static int decodeDigit(BitArray row,
int[] counters, int[] counters,
int rowOffset, int rowOffset,
int[][] patterns) throws ReaderException { int[][] patterns) throws ReaderException {

View file

@ -29,7 +29,7 @@ import com.google.zxing.common.BitArray;
public interface UPCEANReader extends OneDReader { public interface UPCEANReader extends OneDReader {
/** /**
* <p>Like {@link #decodeRow(int, com.google.zxing.common.BitArray)}, but * <p>Like {@link #decodeRow(int, BitArray, java.util.Hashtable)}, but
* allows caller to inform method about where the UPC/EAN start pattern is * allows caller to inform method about where the UPC/EAN start pattern is
* found. This allows this to be computed once and reused across many implementations.</p> * found. This allows this to be computed once and reused across many implementations.</p>
*/ */

View file

@ -34,7 +34,7 @@ final class Mode {
static final Mode BYTE = new Mode(new int[]{8, 16, 16}); static final Mode BYTE = new Mode(new int[]{8, 16, 16});
static final Mode KANJI = new Mode(new int[]{8, 10, 12}); static final Mode KANJI = new Mode(new int[]{8, 10, 12});
private int[] characterCountBitsForVersions; private final int[] characterCountBitsForVersions;
private Mode(int[] characterCountBitsForVersions) { private Mode(int[] characterCountBitsForVersions) {
this.characterCountBitsForVersions = characterCountBitsForVersions; this.characterCountBitsForVersions = characterCountBitsForVersions;

View file

@ -181,8 +181,8 @@ public final class Version {
* will be the same across all blocks within one version.</p> * will be the same across all blocks within one version.</p>
*/ */
static final class ECBlocks { static final class ECBlocks {
private int ecCodewords; private final int ecCodewords;
private ECB[] ecBlocks; private final ECB[] ecBlocks;
private ECBlocks(int ecCodewords, ECB ecBlocks) { private ECBlocks(int ecCodewords, ECB ecBlocks) {
this.ecCodewords = ecCodewords; this.ecCodewords = ecCodewords;
@ -209,8 +209,8 @@ public final class Version {
* parameters is used consecutively in the QR code version's format.</p> * parameters is used consecutively in the QR code version's format.</p>
*/ */
static final class ECB { static final class ECB {
private int count; private final int count;
private int dataCodewords; private final int dataCodewords;
private ECB(int count, int dataCodewords) { private ECB(int count, int dataCodewords) {
this.count = count; this.count = count;

View file

@ -44,10 +44,6 @@ public final class AlignmentPattern implements ResultPoint {
return posY; return posY;
} }
float getEstimatedModuleSize() {
return estimatedModuleSize;
}
/** /**
* <p>Determines if this alignment pattern "about equals" an alignment pattern at the stated * <p>Determines if this alignment pattern "about equals" an alignment pattern at the stated
* position and size -- meaning, it is at nearly the same center with nearly the same size.</p> * position and size -- meaning, it is at nearly the same center with nearly the same size.</p>

View file

@ -94,7 +94,6 @@ final class AlignmentPatternFinder {
stateCount[0] = 0; stateCount[0] = 0;
stateCount[1] = 0; stateCount[1] = 0;
stateCount[2] = 0; stateCount[2] = 0;
int currentState = 0;
int j = startX; int j = startX;
// Burn off leading white pixels before anything else; if we start in the middle of // Burn off leading white pixels before anything else; if we start in the middle of
// a white run, it doesn't make sense to count its length, since we don't know if the // a white run, it doesn't make sense to count its length, since we don't know if the
@ -102,6 +101,7 @@ final class AlignmentPatternFinder {
while (j < maxJ && !luminanceRow.get(j - startX)) { while (j < maxJ && !luminanceRow.get(j - startX)) {
j++; j++;
} }
int currentState = 0;
while (j < maxJ) { while (j < maxJ) {
if (luminanceRow.get(j - startX)) { if (luminanceRow.get(j - startX)) {
// Black pixel // Black pixel

View file

@ -146,12 +146,8 @@ final class FinderPatternFinder {
FinderPattern[] patternInfo = selectBestPatterns(); FinderPattern[] patternInfo = selectBestPatterns();
patternInfo = orderBestPatterns(patternInfo); patternInfo = orderBestPatterns(patternInfo);
float totalModuleSize = 0.0f;
for (int i = 0; i < patternInfo.length; i++) {
totalModuleSize += patternInfo[i].getEstimatedModuleSize();
}
return new FinderPatternInfo(totalModuleSize / (float) patternInfo.length, patternInfo); return new FinderPatternInfo(patternInfo);
} }
/** /**

View file

@ -24,23 +24,16 @@ package com.google.zxing.qrcode.detector;
*/ */
final class FinderPatternInfo { final class FinderPatternInfo {
private final float rawEstimatedModuleSize;
private final FinderPattern bottomLeft; private final FinderPattern bottomLeft;
private final FinderPattern topLeft; private final FinderPattern topLeft;
private final FinderPattern topRight; private final FinderPattern topRight;
FinderPatternInfo(float rawEstimatedModuleSize, FinderPatternInfo(FinderPattern[] patternCenters) {
FinderPattern[] patternCenters) {
this.rawEstimatedModuleSize = rawEstimatedModuleSize;
this.bottomLeft = patternCenters[0]; this.bottomLeft = patternCenters[0];
this.topLeft = patternCenters[1]; this.topLeft = patternCenters[1];
this.topRight = patternCenters[2]; this.topRight = patternCenters[2];
} }
float getRawEstimatedModuleSize() {
return rawEstimatedModuleSize;
}
FinderPattern getBottomLeft() { FinderPattern getBottomLeft() {
return bottomLeft; return bottomLeft;
} }

View file

@ -52,8 +52,7 @@ final class PerspectiveTransform {
PerspectiveTransform qToS = quadrilateralToSquare(x0, y0, x1, y1, x2, y2, x3, y3); PerspectiveTransform qToS = quadrilateralToSquare(x0, y0, x1, y1, x2, y2, x3, y3);
PerspectiveTransform sToQ = squareToQuadrilateral(x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p); PerspectiveTransform sToQ = squareToQuadrilateral(x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p);
PerspectiveTransform product = sToQ.times(qToS); return sToQ.times(qToS);
return product;
} }
void transformPoints(float[] points) { void transformPoints(float[] points) {
@ -100,7 +99,7 @@ final class PerspectiveTransform {
} }
} }
static PerspectiveTransform quadrilateralToSquare(float x0, float y0, private static PerspectiveTransform quadrilateralToSquare(float x0, float y0,
float x1, float y1, float x1, float y1,
float x2, float y2, float x2, float y2,
float x3, float y3) { float x3, float y3) {

View file

@ -34,7 +34,7 @@ final class AdvancedMultimediaManager {
// These signatures must match those in the other class exactly // These signatures must match those in the other class exactly
static void setFocus(Controllable player) throws MediaException, InterruptedException { static void setFocus(Controllable player) throws MediaException {
// do nothing // do nothing
} }

View file

@ -43,7 +43,7 @@ final class AdvancedMultimediaManager {
// do nothing // do nothing
} }
static void setFocus(Controllable player) throws MediaException, InterruptedException { static void setFocus(Controllable player) throws MediaException {
FocusControl focusControl = (FocusControl) FocusControl focusControl = (FocusControl)
player.getControl("javax.microedition.amms.control.camera.FocusControl"); player.getControl("javax.microedition.amms.control.camera.FocusControl");
if (focusControl != null) { if (focusControl != null) {
@ -52,7 +52,11 @@ final class AdvancedMultimediaManager {
} }
if (focusControl.isAutoFocusSupported()) { if (focusControl.isAutoFocusSupported()) {
focusControl.setFocus(FocusControl.AUTO); focusControl.setFocus(FocusControl.AUTO);
try {
Thread.sleep(FOCUS_TIME_MS); // let it focus... Thread.sleep(FOCUS_TIME_MS); // let it focus...
} catch (InterruptedException ie) {
// continue
}
try { try {
focusControl.setFocus(FocusControl.AUTO_LOCK); focusControl.setFocus(FocusControl.AUTO_LOCK);
} catch (MediaException me) { } catch (MediaException me) {

View file

@ -36,7 +36,7 @@ final class SnapshotThread extends Thread {
private final ZXingMIDlet zXingMIDlet; private final ZXingMIDlet zXingMIDlet;
SnapshotThread(ZXingMIDlet zXingMIDlet) { private SnapshotThread(ZXingMIDlet zXingMIDlet) {
this.zXingMIDlet = zXingMIDlet; this.zXingMIDlet = zXingMIDlet;
} }
@ -65,8 +65,10 @@ final class SnapshotThread extends Thread {
} catch (ReaderException re) { } catch (ReaderException re) {
// Show a friendlier message on a mere failure to read the barcode // Show a friendlier message on a mere failure to read the barcode
zXingMIDlet.showError("Sorry, no barcode was found."); zXingMIDlet.showError("Sorry, no barcode was found.");
} catch (Throwable t) { } catch (MediaException me) {
zXingMIDlet.showError(t); zXingMIDlet.showError(me);
} catch (RuntimeException re) {
zXingMIDlet.showError(re);
} finally { } finally {
try { try {
player.start(); player.start();

View file

@ -52,6 +52,10 @@ public final class ZXingMIDlet extends MIDlet {
private Player player; private Player player;
private VideoControl videoControl; private VideoControl videoControl;
Canvas getCanvas() {
return canvas;
}
Player getPlayer() { Player getPlayer() {
return player; return player;
} }
@ -152,7 +156,7 @@ public final class ZXingMIDlet extends MIDlet {
} }
} else { } else {
// cancel // cancel
Display.getDisplay(ZXingMIDlet.this).setCurrent(canvas); Display.getDisplay(ZXingMIDlet.this).setCurrent(getCanvas());
} }
} }
}; };

View file

@ -19,6 +19,7 @@ package com.google.zxing.client.j2se;
import com.google.zxing.DecodeHintType; import com.google.zxing.DecodeHintType;
import com.google.zxing.MultiFormatReader; import com.google.zxing.MultiFormatReader;
import com.google.zxing.ReaderException; import com.google.zxing.ReaderException;
import com.google.zxing.MonochromeBitmapSource;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
@ -64,9 +65,9 @@ public final class CommandLineRunner {
return false; return false;
} }
try { try {
Hashtable hints = new Hashtable(); Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>(3);
hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE); hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
BufferedImageMonochromeBitmapSource source = new BufferedImageMonochromeBitmapSource(image); MonochromeBitmapSource source = new BufferedImageMonochromeBitmapSource(image);
String result = new MultiFormatReader().decode(source, hints).getText(); String result = new MultiFormatReader().decode(source, hints).getText();
System.out.println(uri.toString() + ": " + result); System.out.println(uri.toString() + ": " + result);
return true; return true;

View file

@ -46,7 +46,6 @@ public final class ImageConverter {
File inputFile = new File(arg); File inputFile = new File(arg);
if (inputFile.exists()) { if (inputFile.exists()) {
if (inputFile.isDirectory()) { if (inputFile.isDirectory()) {
int count = 0;
for (File input : inputFile.listFiles()) { for (File input : inputFile.listFiles()) {
convertImage(input.toURI()); convertImage(input.toURI());
} }