Enable DataMatrix in the web app / other small tweaks

git-svn-id: https://zxing.googlecode.com/svn/trunk@903 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2009-04-10 13:46:11 +00:00
parent 58705e7b91
commit dea0247615
5 changed files with 25 additions and 15 deletions

View file

@ -45,8 +45,6 @@ public abstract class BaseMonochromeBitmapSource implements MonochromeBitmapSour
private void initLuminances() {
if (luminances == null) {
int width = getWidth();
int height = getHeight();
int max = width > height ? width : height;
luminances = new int[max];
}
@ -135,7 +133,7 @@ public abstract class BaseMonochromeBitmapSource implements MonochromeBitmapSour
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;

View file

@ -16,8 +16,6 @@
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>

View file

@ -49,11 +49,11 @@ public final class AlignmentPattern implements ResultPoint {
* 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;
}
}

View file

@ -64,10 +64,11 @@ public final class FinderPattern implements ResultPoint {
* 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;
}
}

View file

@ -21,6 +21,7 @@ import com.google.zxing.MultiFormatReader;
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;
@ -63,6 +64,7 @@ import java.net.URISyntaxException;
import java.net.UnknownHostException;
import java.util.Hashtable;
import java.util.List;
import java.util.Vector;
import java.util.logging.Logger;
/**
@ -80,8 +82,19 @@ public final class DecodeServlet extends HttpServlet {
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;