private void initLuminances() {
if (luminances == null) {
- int width = getWidth();
- int height = getHeight();
int max = width > height ? width : height;
luminances = new int[max];
}
histogram[luminances[x] >> LUMINANCE_SHIFT]++;
}
} else {
- throw new IllegalArgumentException("Unknown method: " + method);
+ throw new IllegalArgumentException("Unknown method");
}
blackPoint = BlackPointEstimator.estimate(histogram) << LUMINANCE_SHIFT;
lastMethod = method;
package com.google.zxing.qrcode.decoder;
-import com.google.zxing.ReaderException;
-
/**
* <p>Encapsulates a QR Code's format information, including the data mask used and
* error correction level.</p>
* position and size -- meaning, it is at nearly the same center with nearly the same size.</p>
*/
boolean aboutEquals(float moduleSize, float i, float j) {
- return
- Math.abs(i - posY) <= moduleSize &&
- Math.abs(j - posX) <= moduleSize &&
- (Math.abs(moduleSize - estimatedModuleSize) <= 1.0f ||
- Math.abs(moduleSize - estimatedModuleSize) / estimatedModuleSize <= 0.1f);
+ if (Math.abs(i - posY) <= moduleSize && Math.abs(j - posX) <= moduleSize) {
+ float moduleSizeDiff = Math.abs(moduleSize - estimatedModuleSize);
+ return moduleSizeDiff <= 1.0f || moduleSizeDiff / estimatedModuleSize <= 1.0f;
+ }
+ return false;
}
}
\ No newline at end of file
* position and size -- meaning, it is at nearly the same center with nearly the same size.</p>
*/
boolean aboutEquals(float moduleSize, float i, float j) {
- return Math.abs(i - posY) <= moduleSize &&
- Math.abs(j - posX) <= moduleSize &&
- (Math.abs(moduleSize - estimatedModuleSize) <= 1.0f ||
- Math.abs(moduleSize - estimatedModuleSize) / estimatedModuleSize <= 0.1f);
+ if (Math.abs(i - posY) <= moduleSize && Math.abs(j - posX) <= moduleSize) {
+ float moduleSizeDiff = Math.abs(moduleSize - estimatedModuleSize);
+ return moduleSizeDiff <= 1.0f || moduleSizeDiff / estimatedModuleSize <= 1.0f;
+ }
+ return false;
}
}
import com.google.zxing.Reader;
import com.google.zxing.ReaderException;
import com.google.zxing.Result;
+import com.google.zxing.BarcodeFormat;
import com.google.zxing.client.j2se.BufferedImageMonochromeBitmapSource;
import com.google.zxing.client.result.ParsedResult;
import com.google.zxing.client.result.ResultParser;
import java.net.UnknownHostException;
import java.util.Hashtable;
import java.util.List;
+import java.util.Vector;
import java.util.logging.Logger;
/**
static final Hashtable<DecodeHintType, Object> HINTS;
static {
- HINTS = new Hashtable<DecodeHintType, Object>(3);
+ HINTS = new Hashtable<DecodeHintType, Object>(5);
HINTS.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
+ Vector possibleFormats = new Vector();
+ possibleFormats.add(BarcodeFormat.UPC_A);
+ possibleFormats.add(BarcodeFormat.UPC_E);
+ possibleFormats.add(BarcodeFormat.EAN_8);
+ possibleFormats.add(BarcodeFormat.EAN_13);
+ possibleFormats.add(BarcodeFormat.CODE_39);
+ possibleFormats.add(BarcodeFormat.CODE_128);
+ possibleFormats.add(BarcodeFormat.ITF);
+ possibleFormats.add(BarcodeFormat.QR_CODE);
+ possibleFormats.add(BarcodeFormat.DATAMATRIX);
+ HINTS.put(DecodeHintType.POSSIBLE_FORMATS, possibleFormats);
}
private HttpClient client;