projects
/
zxing.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Lots of updates:
[zxing.git]
/
android
/
src
/
com
/
google
/
zxing
/
client
/
android
/
DecodeThread.java
diff --git
a/android/src/com/google/zxing/client/android/DecodeThread.java
b/android/src/com/google/zxing/client/android/DecodeThread.java
index
bce87ca
..
bd2ade6
100755
(executable)
--- a/
android/src/com/google/zxing/client/android/DecodeThread.java
+++ b/
android/src/com/google/zxing/client/android/DecodeThread.java
@@
-25,7
+25,6
@@
import com.google.zxing.Result;
import com.google.zxing.common.GlobalHistogramBinarizer;
import android.content.SharedPreferences;
import com.google.zxing.common.GlobalHistogramBinarizer;
import android.content.SharedPreferences;
-import android.graphics.Rect;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
@@
-38,19
+37,20
@@
import java.util.Vector;
/**
* This thread does all the heavy lifting of decoding the images.
/**
* This thread does all the heavy lifting of decoding the images.
+ *
+ * @author dswitkin@google.com (Daniel Switkin)
*/
final class DecodeThread extends Thread {
*/
final class DecodeThread extends Thread {
-
public static final String BARCODE_BITMAP = "barcode_bitmap";
private static final String TAG = "DecodeThread";
public static final String BARCODE_BITMAP = "barcode_bitmap";
private static final String TAG = "DecodeThread";
- public Handler
mH
andler;
- private final CaptureActivity
mA
ctivity;
- private final MultiFormatReader m
M
ultiFormatReader;
+ public Handler
h
andler;
+ private final CaptureActivity
a
ctivity;
+ private final MultiFormatReader multiFormatReader;
DecodeThread(CaptureActivity activity, String mode) {
DecodeThread(CaptureActivity activity, String mode) {
-
mA
ctivity = activity;
- m
M
ultiFormatReader = new MultiFormatReader();
+
this.a
ctivity = activity;
+ multiFormatReader = new MultiFormatReader();
// The prefs can't change while the thread is running, so pick them up once here.
if (mode == null || mode.length() == 0) {
// The prefs can't change while the thread is running, so pick them up once here.
if (mode == null || mode.length() == 0) {
@@
-80,7
+80,7
@@
final class DecodeThread extends Thread {
@Override
public void run() {
Looper.prepare();
@Override
public void run() {
Looper.prepare();
-
mH
andler = new Handler() {
+
h
andler = new Handler() {
@Override
public void handleMessage(Message message) {
switch (message.what) {
@Override
public void handleMessage(Message message) {
switch (message.what) {
@@
-104,7
+104,7
@@
final class DecodeThread extends Thread {
vector.addElement(BarcodeFormat.EAN_13);
vector.addElement(BarcodeFormat.EAN_8);
hints.put(DecodeHintType.POSSIBLE_FORMATS, vector);
vector.addElement(BarcodeFormat.EAN_13);
vector.addElement(BarcodeFormat.EAN_8);
hints.put(DecodeHintType.POSSIBLE_FORMATS, vector);
- m
M
ultiFormatReader.setHints(hints);
+ multiFormatReader.setHints(hints);
}
/**
}
/**
@@
-121,7
+121,7
@@
final class DecodeThread extends Thread {
vector.addElement(BarcodeFormat.CODE_128);
vector.addElement(BarcodeFormat.ITF);
hints.put(DecodeHintType.POSSIBLE_FORMATS, vector);
vector.addElement(BarcodeFormat.CODE_128);
vector.addElement(BarcodeFormat.ITF);
hints.put(DecodeHintType.POSSIBLE_FORMATS, vector);
- m
M
ultiFormatReader.setHints(hints);
+ multiFormatReader.setHints(hints);
}
private void setDecodeQRMode() {
}
private void setDecodeQRMode() {
@@
-129,7
+129,7
@@
final class DecodeThread extends Thread {
Vector<BarcodeFormat> vector = new Vector<BarcodeFormat>(1);
vector.addElement(BarcodeFormat.QR_CODE);
hints.put(DecodeHintType.POSSIBLE_FORMATS, vector);
Vector<BarcodeFormat> vector = new Vector<BarcodeFormat>(1);
vector.addElement(BarcodeFormat.QR_CODE);
hints.put(DecodeHintType.POSSIBLE_FORMATS, vector);
- m
M
ultiFormatReader.setHints(hints);
+ multiFormatReader.setHints(hints);
}
/**
}
/**
@@
-148,7
+148,7
@@
final class DecodeThread extends Thread {
vector.addElement(BarcodeFormat.ITF);
vector.addElement(BarcodeFormat.QR_CODE);
hints.put(DecodeHintType.POSSIBLE_FORMATS, vector);
vector.addElement(BarcodeFormat.ITF);
vector.addElement(BarcodeFormat.QR_CODE);
hints.put(DecodeHintType.POSSIBLE_FORMATS, vector);
- m
M
ultiFormatReader.setHints(hints);
+ multiFormatReader.setHints(hints);
}
/**
}
/**
@@
-163,12
+163,10
@@
final class DecodeThread extends Thread {
long start = System.currentTimeMillis();
boolean success;
Result rawResult = null;
long start = System.currentTimeMillis();
boolean success;
Result rawResult = null;
- Rect rect = CameraManager.get().getFramingRect();
- YUVLuminanceSource source = new YUVLuminanceSource(data, width, height, rect.left, rect.top,
- rect.width(), rect.height());
+ BaseLuminanceSource source = CameraManager.get().buildLuminanceSource(data, width, height);
BinaryBitmap bitmap = new BinaryBitmap(new GlobalHistogramBinarizer(source));
try {
BinaryBitmap bitmap = new BinaryBitmap(new GlobalHistogramBinarizer(source));
try {
- rawResult = m
M
ultiFormatReader.decodeWithState(bitmap);
+ rawResult = multiFormatReader.decodeWithState(bitmap);
success = true;
} catch (ReaderException e) {
success = false;
success = true;
} catch (ReaderException e) {
success = false;
@@
-177,15
+175,14
@@
final class DecodeThread extends Thread {
if (success) {
Log.v(TAG, "Found barcode (" + (end - start) + " ms):\n" + rawResult.toString());
if (success) {
Log.v(TAG, "Found barcode (" + (end - start) + " ms):\n" + rawResult.toString());
- Message message = Message.obtain(
mActivity.mH
andler, R.id.decode_succeeded, rawResult);
+ Message message = Message.obtain(
activity.h
andler, R.id.decode_succeeded, rawResult);
Bundle bundle = new Bundle();
Bundle bundle = new Bundle();
- bundle.putParcelable(BARCODE_BITMAP, source.render
To
Bitmap());
+ bundle.putParcelable(BARCODE_BITMAP, source.render
CroppedGreyscale
Bitmap());
message.setData(bundle);
message.sendToTarget();
} else {
message.setData(bundle);
message.sendToTarget();
} else {
- Message message = Message.obtain(
mActivity.mH
andler, R.id.decode_failed);
+ Message message = Message.obtain(
activity.h
andler, R.id.decode_failed);
message.sendToTarget();
}
}
message.sendToTarget();
}
}
-
}
}