本文整理汇总了Java中com.google.zxing.Result.getText方法的典型用法代码示例。如果您正苦于以下问题:Java Result.getText方法的具体用法?Java Result.getText怎么用?Java Result.getText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.zxing.Result
的用法示例。
在下文中一共展示了Result.getText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: translateResultPoints
import com.google.zxing.Result; //导入方法依赖的package包/类
private static Result translateResultPoints(Result result, int xOffset, int yOffset) {
ResultPoint[] oldResultPoints = result.getResultPoints();
if (oldResultPoints == null) {
return result;
}
ResultPoint[] newResultPoints = new ResultPoint[oldResultPoints.length];
for (int i = 0; i < oldResultPoints.length; i++) {
ResultPoint oldPoint = oldResultPoints[i];
if (oldPoint != null) {
newResultPoints[i] = new ResultPoint(oldPoint.getX() + xOffset, oldPoint.getY() + yOffset);
}
}
Result newResult = new Result(result.getText(),
result.getRawBytes(),
result.getNumBits(),
newResultPoints,
result.getBarcodeFormat(),
result.getTimestamp());
newResult.putAllMetadata(result.getResultMetadata());
return newResult;
}
示例2: handleDecode
import com.google.zxing.Result; //导入方法依赖的package包/类
/**
* Handler scan result
* @param result
* @param barcode
*/
public void handleDecode(Result result, Bitmap barcode) {
inactivityTimer.onActivity();
playBeepSoundAndVibrate();
String resultString = result.getText();
if (resultString.equals("")) {
Toast.makeText(CaptureActivity.this, "Scan failed!", Toast.LENGTH_SHORT).show();
}else {
Intent resultIntent = new Intent();
Bundle bundle = new Bundle();
bundle.putString("result", resultString);
bundle.putParcelable("bitmap", barcode);
resultIntent.putExtras(bundle);
this.setResult(RESULT_OK, resultIntent);
}
CaptureActivity.this.finish();
}
示例3: decode
import com.google.zxing.Result; //导入方法依赖的package包/类
/**
* 解析二维码
*
* @param file 二维码图片
* @return
* @throws Exception
*/
public static String decode(File file) throws Exception {
BufferedImage image;
image = ImageIO.read(file);
if (image == null) {
return null;
}
BufferedImageLuminanceSource source = new BufferedImageLuminanceSource(image);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
Result result;
Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>();
hints.put(DecodeHintType.CHARACTER_SET, CHARSET);
result = new MultiFormatReader().decode(bitmap, hints);
String resultStr = result.getText();
return resultStr;
}
示例4: 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;
}
示例5: 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;
}
}
示例6: handleResult
import com.google.zxing.Result; //导入方法依赖的package包/类
@Override
public void handleResult(Result result) {
if (result == null) return;
String address = result.getText();
try {
AddressEncoder scanned = AddressEncoder.decode(address);
Intent data = new Intent();
data.putExtra("ADDRESS", scanned.getAddress().toLowerCase());
if (scanned.getAddress().length() > 42 && !scanned.getAddress().startsWith("0x") && scanned.getAmount() == null)
type = PRIVATE_KEY;
if (scanned.getAmount() != null) {
data.putExtra("AMOUNT", scanned.getAmount());
type = REQUEST_PAYMENT;
}
data.putExtra("TYPE", type);
setResult(RESULT_OK, data);
finish();
} catch (IOException e) {
e.printStackTrace();
}
}
示例7: translateResultPoints
import com.google.zxing.Result; //导入方法依赖的package包/类
private static Result translateResultPoints(Result result, int xOffset, int yOffset) {
ResultPoint[] oldResultPoints = result.getResultPoints();
if (oldResultPoints == null) {
return result;
}
ResultPoint[] newResultPoints = new ResultPoint[oldResultPoints.length];
for (int i = 0; i < oldResultPoints.length; i++) {
ResultPoint oldPoint = oldResultPoints[i];
if (oldPoint != null) {
newResultPoints[i] = new ResultPoint(oldPoint.getX() + xOffset, oldPoint.getY() + yOffset);
}
}
Result newResult = new Result(result.getText(), result.getRawBytes(), newResultPoints, result.getBarcodeFormat());
newResult.putAllMetadata(result.getResultMetadata());
return newResult;
}
示例8: decodes
import com.google.zxing.Result; //导入方法依赖的package包/类
/**
* 解析条形码
*/
public static String decodes(String imgPath) {
BufferedImage image = null;
Result result = null;
try {
image = ImageIO.read(new File(imgPath));
if (image == null) {
System.out.println("the decode image may be not exit.");
}
LuminanceSource source = new BufferedImageLuminanceSource(image);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
result = new MultiFormatReader().decode(bitmap, null);
return result.getText();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
示例9: handleDecode
import com.google.zxing.Result; //导入方法依赖的package包/类
/**
* Handler scan result
* @param result
* @param barcode
*/
public void handleDecode(Result result, Bitmap barcode) {
inactivityTimer.onActivity();
playBeepSoundAndVibrate();
String resultString = result.getText();
//FIXME
if (resultString.equals("")) {
Toast.makeText(CaptureActivity.this, "Scan failed!", Toast.LENGTH_SHORT).show();
}
setResult(RESULT_OK, new Intent().putExtra(RESULT_QRCODE_STRING, resultString));
finish();
}
示例10: main
import com.google.zxing.Result; //导入方法依赖的package包/类
public static void main(String[] args) {
String saveImgFilePath = "D://zxing.png";
Boolean encode = encode("我是Javen205", BarcodeFormat.QR_CODE, 3, ErrorCorrectionLevel.H, "png", 200, 200,
saveImgFilePath);
if (encode) {
Result result = decode(saveImgFilePath);
String text = result.getText();
System.out.println(text);
}
}
示例11: handleResult
import com.google.zxing.Result; //导入方法依赖的package包/类
@Override
public void handleResult(Result rawResult) {
if (config.getCamera()) {
qrView.resumeCameraPreview(this);
}
String s = rawResult.getText();
if (s.equals(lastScanCode) && System.currentTimeMillis() - lastScanTime < 5000) {
return;
}
lastScanTime = System.currentTimeMillis();
lastScanCode = s;
handleScan(s);
}
示例12: handleResult
import com.google.zxing.Result; //导入方法依赖的package包/类
@Override
public void handleResult(Result result) {
Intent i = new Intent(ActivityEscaner.this, ActivityRegistrarProducto.class);
i.putExtra("barcode", result.getText());
barCode = result.getText();
escanerView.stopCamera();
startActivity(i);
this.finish();
}
开发者ID:EdwardAlexis,项目名称:Sistema-de-Comercializacion-Negocios-Jhordan,代码行数:10,代码来源:ActivityEscaner.java
示例13: maybeReturnResult
import com.google.zxing.Result; //导入方法依赖的package包/类
private static Result maybeReturnResult(Result result) throws FormatException {
String text = result.getText();
if (text.charAt(0) == '0') {
return new Result(text.substring(1), null, result.getResultPoints(), BarcodeFormat
.UPC_A);
}
throw FormatException.getFormatInstance();
}
示例14: handleDecode
import com.google.zxing.Result; //导入方法依赖的package包/类
/**
* Handler scan result
*
* @param result
* @param barcode
*/
public void handleDecode(Result result, Bitmap barcode) {
inactivityTimer.onActivity();
playBeepSoundAndVibrate();
String resultString = result.getText();
handleResult(resultString);
}
示例15: maybeReturnResult
import com.google.zxing.Result; //导入方法依赖的package包/类
private static Result maybeReturnResult(Result result) throws FormatException {
String text = result.getText();
if (text.charAt(0) == '0') {
return new Result(text.substring(1), null, result.getResultPoints(), BarcodeFormat.UPC_A);
} else {
throw FormatException.getFormatInstance();
}
}