当前位置: 首页>>代码示例>>Java>>正文


Java Result类代码示例

本文整理汇总了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;
    }
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:25,代码来源:CaptureActivityHandler.java

示例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);
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:19,代码来源:WifiResultParser.java

示例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;
	}
}
 
开发者ID:Javen205,项目名称:IJPay,代码行数:29,代码来源:ZxingKit.java

示例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);
    }
  }
}
 
开发者ID:AtlantPlatform,项目名称:atlant-android,代码行数:20,代码来源:CameraPresenterImpl.java

示例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();
}
 
开发者ID:simplezhli,项目名称:Tesseract-OCR-Scanner,代码行数:22,代码来源:RSS14Reader.java

示例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;
}
 
开发者ID:Awesky,项目名称:awe-awesomesky,代码行数:17,代码来源:CodeUtil.java

示例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));
}
 
开发者ID:10045125,项目名称:QrCode,代码行数:19,代码来源:RSSExpandedReader.java

示例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("扫描失败,请重试!");
        }
    });
}
 
开发者ID:StickyTolt,项目名称:ForeverLibrary,代码行数:19,代码来源:ScanToolActivity.java

示例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());
        }
    }
}
 
开发者ID:simplezhli,项目名称:Tesseract-OCR-Scanner,代码行数:19,代码来源:ScannerActivity.java

示例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;
}
 
开发者ID:wp521,项目名称:MyFire,代码行数:22,代码来源:BitmapDecoder.java

示例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;
}
 
开发者ID:iBase4J,项目名称:iBase4J-Common,代码行数:20,代码来源:QrcodeUtil.java

示例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();
}
 
开发者ID:10045125,项目名称:QrCode,代码行数:24,代码来源:RSS14Reader.java

示例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;
  }
 
开发者ID:simplezhli,项目名称:Tesseract-OCR-Scanner,代码行数:23,代码来源:UPCEANExtension2Support.java

示例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;
    }
}
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:20,代码来源:QRCodeDecoder.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:17,代码来源:UPCEANExtension2Support.java


注:本文中的com.google.zxing.Result类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。