use of com.google.zxing.decode.BitmapDecoder in project QRCode by 5peak2me.
the class CaptureActivity method onActivityResult.
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (resultCode == RESULT_OK) {
final ProgressDialog progressDialog;
switch(requestCode) {
case REQUEST_CODE:
// 获取选中图片的路径
Cursor cursor = getContentResolver().query(intent.getData(), null, null, null, null);
if (cursor.moveToFirst()) {
photoPath = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA));
}
cursor.close();
progressDialog = new ProgressDialog(this);
progressDialog.setMessage("正在扫描...");
progressDialog.setCancelable(false);
progressDialog.show();
new Thread(new Runnable() {
@Override
public void run() {
Bitmap img = BitmapUtils.getCompressedBitmap(photoPath);
BitmapDecoder decoder = new BitmapDecoder(CaptureActivity.this);
Result result = decoder.getRawResult(img);
if (result != null) {
Message m = mHandler.obtainMessage();
m.what = PARSE_BARCODE_SUC;
m.obj = ResultParser.parseResult(result).toString();
mHandler.sendMessage(m);
} else {
Message m = mHandler.obtainMessage();
m.what = PARSE_BARCODE_FAIL;
mHandler.sendMessage(m);
}
progressDialog.dismiss();
}
}).start();
break;
}
}
}
use of com.google.zxing.decode.BitmapDecoder in project QRCode by 5peak2me.
the class CaptureActivity method onActivityResult.
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (resultCode == RESULT_OK) {
final ProgressDialog progressDialog;
switch(requestCode) {
case REQUEST_CODE:
// 获取选中图片的路径
Cursor cursor = getContentResolver().query(intent.getData(), null, null, null, null);
if (cursor.moveToFirst()) {
photoPath = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA));
}
cursor.close();
progressDialog = new ProgressDialog(this);
progressDialog.setMessage("正在扫描...");
progressDialog.setCancelable(false);
progressDialog.show();
new Thread(new Runnable() {
@Override
public void run() {
Bitmap img = BitmapUtils.getCompressedBitmap(photoPath);
BitmapDecoder decoder = new BitmapDecoder(CaptureActivity.this);
Result result = decoder.getRawResult(img);
if (result != null) {
Message m = mHandler.obtainMessage();
m.what = PARSE_BARCODE_SUC;
m.obj = ResultParser.parseResult(result).toString();
mHandler.sendMessage(m);
} else {
Message m = mHandler.obtainMessage();
m.what = PARSE_BARCODE_FAIL;
mHandler.sendMessage(m);
}
progressDialog.dismiss();
}
}).start();
break;
}
}
}
Aggregations