本文整理汇总了Java中com.google.zxing.Result类的典型用法代码示例。如果您正苦于以下问题:Java Result类的具体用法?Java Result怎么用?Java Result使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Result类属于com.google.zxing包,在下文中一共展示了Result类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleMessage
import com.google.zxing.Result; //导入依赖的package包/类
@Override
public void handleMessage(Message message) {
switch (message.what) {
case R.id.restart_preview:
restartPreviewAndDecode();
break;
case R.id.decode_succeeded:
state = State.SUCCESS;
Bundle bundle = message.getData();
activity.handleDecode((Result) message.obj, bundle);
break;
case R.id.decode_failed:
// We're decoding as fast as possible, so when one decode fails,
// start another.
state = State.PREVIEW;
cameraManager.requestPreviewFrame(decodeThread.getHandler(), R.id.decode);
break;
case R.id.return_scan_result:
activity.setResult(Activity.RESULT_OK, (Intent) message.obj);
activity.finish();
break;
}
}
示例2: parse
import com.google.zxing.Result; //导入依赖的package包/类
@Override
public WifiParsedResult parse(Result result) {
String rawText = getMassagedText(result);
if (!rawText.startsWith("WIFI:")) {
return null;
}
String ssid = matchSinglePrefixedField("S:", rawText, ';', false);
if (ssid == null || ssid.isEmpty()) {
return null;
}
String pass = matchSinglePrefixedField("P:", rawText, ';', false);
String type = matchSinglePrefixedField("T:", rawText, ';', false);
if (type == null) {
type = "nopass";
}
boolean hidden = Boolean.parseBoolean(matchSinglePrefixedField("H:", rawText, ';', false));
return new WifiParsedResult(type, ssid, pass, hidden);
}
示例3: decode
import com.google.zxing.Result; //导入依赖的package包/类
/**
* @param srcImgFilePath
* 要解码的图片地址
* @return {Result}
*/
@SuppressWarnings("finally")
public static Result decode(String srcImgFilePath) {
Result result = null;
BufferedImage image;
try {
File srcFile = new File(srcImgFilePath);
image = ImageIO.read(srcFile);
if (null != image) {
LuminanceSource source = new BufferedImageLuminanceSource(image);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
Hashtable<DecodeHintType, String> hints = new Hashtable<DecodeHintType, String>();
hints.put(DecodeHintType.CHARACTER_SET, "UTF-8");
result = new MultiFormatReader().decode(bitmap, hints);
} else {
throw new IllegalArgumentException ("Could not decode image.");
}
} catch (Exception e) {
e.printStackTrace();
} finally {
return result;
}
}
示例4: handleResult
import com.google.zxing.Result; //导入依赖的package包/类
@Override
public void handleResult(Result result) {
if (typeResult == CameraActivity.TAG_FROM_SEND || typeResult == CameraActivity.TAG_FROM_HOME) {
if (WalletUtils.isValidAddress(result.getText())) {
view.onSuccessfulScanQR(result.getText());
} else {
view.onFailScanQR();
mScannerView.resumeCameraPreview(this);
}
}
if (typeResult == CameraActivity.TAG_FROM_IMPORT) {
if (WalletUtils.isValidPrivateKey(result.getText())) {
view.onSuccessfulScanQR(result.getText());
} else {
view.onFailScanQR();
mScannerView.resumeCameraPreview(this);
}
}
}
示例5: decodeRow
import com.google.zxing.Result; //导入依赖的package包/类
@Override
public Result decodeRow(int rowNumber,
BitArray row,
Map<DecodeHintType,?> hints) throws NotFoundException {
Pair leftPair = decodePair(row, false, rowNumber, hints);
addOrTally(possibleLeftPairs, leftPair);
row.reverse();
Pair rightPair = decodePair(row, true, rowNumber, hints);
addOrTally(possibleRightPairs, rightPair);
row.reverse();
for (Pair left : possibleLeftPairs) {
if (left.getCount() > 1) {
for (Pair right : possibleRightPairs) {
if (right.getCount() > 1 && checkChecksum(left, right)) {
return constructResult(left, right);
}
}
}
}
throw NotFoundException.getNotFoundInstance();
}
示例6: decode
import com.google.zxing.Result; //导入依赖的package包/类
public static String decode(File file) throws Exception {
BufferedImage image;
image = ImageIO.read(file);
if (image == null) {
return null;
}
CodeImage source = new CodeImage(
image);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
Result result;
Hashtable hints = new Hashtable();
hints.put(DecodeHintType.CHARACTER_SET, CHARSET);
result = new MultiFormatReader().decode(bitmap, hints);
String resultStr = result.getText();
return resultStr;
}
示例7: decodeRow
import com.google.zxing.Result; //导入依赖的package包/类
@Override
public Result decodeRow(int rowNumber,
BitArray row,
Map<DecodeHintType,?> hints) throws NotFoundException, FormatException {
// Rows can start with even pattern in case in prev rows there where odd number of patters.
// So lets try twice
this.pairs.clear();
this.startFromEven = false;
try {
return constructResult(decodeRow2pairs(rowNumber, row));
} catch (NotFoundException e) {
// OK
}
this.pairs.clear();
this.startFromEven = true;
return constructResult(decodeRow2pairs(rowNumber, row));
}
示例8: initScan
import com.google.zxing.Result; //导入依赖的package包/类
/**
* 初始化扫描
*/
private void initScan() {
scanManager = new ScanManager(this, sfvContent, rlAll, rlCapture, imgLine,
Constant.REQUEST_SCAN_MODE_ALL_MODE, new ScanListener() {
@Override
public void scanResult(Result rawResult, Bundle bundle) {
String scanData = rawResult.getText().trim();
ShowTextActivity.Companion.start(getActivity(), scanData);
}
@Override
public void scanError(Exception e) {
showToast("扫描失败,请重试!");
}
});
}
示例9: handleResult
import com.google.zxing.Result; //导入依赖的package包/类
private void handleResult(Result result) {
if (TextUtils.isEmpty(result.getText())) {
mDecodeManager.showCouldNotReadQrCodeFromScanner(this, new DecodeManager.OnRefreshCameraListener() {
@Override
public void refresh() {
restartPreview();
}
});
} else {
Vibrator vibrator = (Vibrator) this.getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(200L);
if (switch1.isChecked()) {
qrSucceed(result.getText());
} else {
phoneSucceed(result.getText(), result.getBitmap());
}
}
}
示例10: getRawResult
import com.google.zxing.Result; //导入依赖的package包/类
/**
* 获取解码结果
*
* @param bitmap
* @return
*/
public Result getRawResult(Bitmap bitmap) {
if (bitmap == null) {
return null;
}
try {
return multiFormatReader.decodeWithState(new BinaryBitmap(
new HybridBinarizer(new BitmapLuminanceSource(bitmap))));
}
catch (NotFoundException e) {
e.printStackTrace();
}
return null;
}
示例11: decodeQr
import com.google.zxing.Result; //导入依赖的package包/类
public static String decodeQr(String filePath) {
String retStr = "";
if ("".equalsIgnoreCase(filePath) && filePath.length() == 0) {
return "图片路径为空!";
}
try {
BufferedImage bufferedImage = ImageIO.read(new FileInputStream(filePath));
LuminanceSource source = new BufferedImageLuminanceSource(bufferedImage);
Binarizer binarizer = new HybridBinarizer(source);
BinaryBitmap bitmap = new BinaryBitmap(binarizer);
HashMap<DecodeHintType, Object> hintTypeObjectHashMap = new HashMap<>();
hintTypeObjectHashMap.put(DecodeHintType.CHARACTER_SET, "UTF-8");
Result result = new MultiFormatReader().decode(bitmap, hintTypeObjectHashMap);
retStr = result.getText();
} catch (Exception e) {
logger.error("", e);
}
return retStr;
}
示例12: decodeRow
import com.google.zxing.Result; //导入依赖的package包/类
@Override
public Result decodeRow(int rowNumber,
BitArray row,
Map<DecodeHintType,?> hints) throws NotFoundException {
Pair leftPair = decodePair(row, false, rowNumber, hints);
addOrTally(possibleLeftPairs, leftPair);
row.reverse();
Pair rightPair = decodePair(row, true, rowNumber, hints);
addOrTally(possibleRightPairs, rightPair);
row.reverse();
for (Pair left : possibleLeftPairs) {
if (left.getCount() > 1) {
for (Pair right : possibleRightPairs) {
if (right.getCount() > 1) {
if (checkChecksum(left, right)) {
return constructResult(left, right);
}
}
}
}
}
throw NotFoundException.getNotFoundInstance();
}
示例13: decodeRow
import com.google.zxing.Result; //导入依赖的package包/类
Result decodeRow(int rowNumber, BitArray row, int[] extensionStartRange) throws NotFoundException {
StringBuilder result = decodeRowStringBuffer;
result.setLength(0);
int end = decodeMiddle(row, extensionStartRange, result);
String resultString = result.toString();
Map<ResultMetadataType,Object> extensionData = parseExtensionString(resultString);
Result extensionResult =
new Result(resultString,
null,
new ResultPoint[] {
new ResultPoint((extensionStartRange[0] + extensionStartRange[1]) / 2.0f, rowNumber),
new ResultPoint(end, rowNumber),
},
BarcodeFormat.UPC_EAN_EXTENSION);
if (extensionData != null) {
extensionResult.putAllMetadata(extensionData);
}
return extensionResult;
}
示例14: syncDecodeQRCode
import com.google.zxing.Result; //导入依赖的package包/类
/**
* 同步解析bitmap二维码。该方法是耗时操作,请在子线程中调用。
*
* @param bitmap 要解析的二维码图片
* @return 返回二维码图片里的内容 或 null
*/
public static String syncDecodeQRCode(Bitmap bitmap) {
try {
int width = bitmap.getWidth();
int height = bitmap.getHeight();
int[] pixels = new int[width * height];
bitmap.getPixels(pixels, 0, width, 0, 0, width, height);
RGBLuminanceSource source = new RGBLuminanceSource(width, height, pixels);
Result result = new MultiFormatReader().decode(new BinaryBitmap(new HybridBinarizer(source)), HINTS);
return result.getText();
} catch (Exception e) {
return null;
}
}
示例15: decodeRow
import com.google.zxing.Result; //导入依赖的package包/类
Result decodeRow(int rowNumber, BitArray row, int[] extensionStartRange) throws
NotFoundException {
StringBuilder result = this.decodeRowStringBuffer;
result.setLength(0);
int end = decodeMiddle(row, extensionStartRange, result);
String resultString = result.toString();
Map<ResultMetadataType, Object> extensionData = parseExtensionString(resultString);
Result extensionResult = new Result(resultString, null, new ResultPoint[]{new ResultPoint
(((float) (extensionStartRange[0] + extensionStartRange[1])) / 2.0f, (float)
rowNumber), new ResultPoint((float) end, (float) rowNumber)},
BarcodeFormat.UPC_EAN_EXTENSION);
if (extensionData != null) {
extensionResult.putAllMetadata(extensionData);
}
return extensionResult;
}