本文整理汇总了Java中com.google.zxing.Result.getBarcodeFormat方法的典型用法代码示例。如果您正苦于以下问题:Java Result.getBarcodeFormat方法的具体用法?Java Result.getBarcodeFormat怎么用?Java Result.getBarcodeFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.zxing.Result
的用法示例。
在下文中一共展示了Result.getBarcodeFormat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawResultPoints
import com.google.zxing.Result; //导入方法依赖的package包/类
/**
* Superimpose a line for 1D or dots for 2D to highlight the key features of the barcode.
*
* @param barcode A bitmap of the captured image.
* @param scaleFactor amount by which thumbnail was scaled
* @param rawResult The decoded results which contains the points to draw.
*/
private void drawResultPoints(Bitmap barcode, float scaleFactor, Result rawResult) {
ResultPoint[] points = rawResult.getResultPoints();
if (points != null && points.length > 0) {
Canvas canvas = new Canvas(barcode);
Paint paint = new Paint();
paint.setColor(getResources().getColor(R.color.result_points));
if (points.length == 2) {
paint.setStrokeWidth(4.0f);
drawLine(canvas, paint, points[0], points[1], scaleFactor);
} else if (points.length == 4 &&
(rawResult.getBarcodeFormat() == BarcodeFormat.UPC_A ||
rawResult.getBarcodeFormat() == BarcodeFormat.EAN_13)) {
// Hacky special case -- draw two lines, for the barcode and metadata
drawLine(canvas, paint, points[0], points[1], scaleFactor);
drawLine(canvas, paint, points[2], points[3], scaleFactor);
} else {
paint.setStrokeWidth(10.0f);
for (ResultPoint point : points) {
if (point != null) {
canvas.drawPoint(scaleFactor * point.getX(), scaleFactor * point.getY(), paint);
}
}
}
}
}
示例2: parse
import com.google.zxing.Result; //导入方法依赖的package包/类
@Override
public ProductParsedResult parse(Result result) {
BarcodeFormat format = result.getBarcodeFormat();
if (!(format == BarcodeFormat.UPC_A || format == BarcodeFormat.UPC_E ||
format == BarcodeFormat.EAN_8 || format == BarcodeFormat.EAN_13)) {
return null;
}
String rawText = getMassagedText(result);
if (!isStringOfDigits(rawText, rawText.length())) {
return null;
}
// Not actually checking the checksum again here
String normalizedProductID;
// Expand UPC-E for purposes of searching
if (format == BarcodeFormat.UPC_E && rawText.length() == 8) {
normalizedProductID = UPCEReader.convertUPCEtoUPCA(rawText);
} else {
normalizedProductID = rawText;
}
return new ProductParsedResult(rawText, normalizedProductID);
}
示例3: parse
import com.google.zxing.Result; //导入方法依赖的package包/类
/**
* See <a href="http://www.bisg.org/isbn-13/for.dummies.html">ISBN-13 For Dummies</a>
*/
@Override
public ISBNParsedResult parse(Result result) {
BarcodeFormat format = result.getBarcodeFormat();
if (format != BarcodeFormat.EAN_13) {
return null;
}
String rawText = getMassagedText(result);
int length = rawText.length();
if (length != 13) {
return null;
}
if (!rawText.startsWith("978") && !rawText.startsWith("979")) {
return null;
}
return new ISBNParsedResult(rawText);
}
示例4: 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;
}
示例5: handDecode
import com.google.zxing.Result; //导入方法依赖的package包/类
public void handDecode(final Result result) {
mInactivityTimer.onActivity();
beepManager.playBeepSoundAndVibrate();
// AlertDialog.Builder mScannerDialogBuilder = new AlertDialog.Builder(this);
// mScannerDialogBuilder.setMessage("codeType:" + result.getBarcodeFormat() + "-----content:" + result.getText());
// mScannerDialogBuilder.setCancelable(false);
// mScannerDialogBuilder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface dialog, int which) {
// dialog.dismiss();
// ScannerActivity.this.finish();
// }
// });
// mScannerDialogBuilder.create().show();
Intent data = new Intent();
BarcodeFormat format = result.getBarcodeFormat();
String type = format.toString();
data.putExtra(Constant.EXTRA_RESULT_CODE_TYPE, type);
data.putExtra(Constant.EXTRA_RESULT_CONTENT, result.getText());
setResult(RESULT_OK, data);
finish();
}
示例6: drawResultPoints
import com.google.zxing.Result; //导入方法依赖的package包/类
/**
* Superimpose a line for 1D or dots for 2D to highlight the key features of the barcode.
*
* @param barcode A bitmap of the captured image.
* @param scaleFactor amount by which thumbnail was scaled
* @param rawResult The decoded results which contains the points to draw.
*/
private void drawResultPoints(Bitmap barcode, float scaleFactor, Result rawResult) {
ResultPoint[] points = rawResult.getResultPoints();
if (points != null && points.length > 0) {
Canvas canvas = new Canvas(barcode);
Paint paint = new Paint();
paint.setColor(getResources().getColor(R.color.result_points));
if (points.length == 2) {
paint.setStrokeWidth(4.0f);
drawLine(canvas, paint, points[0], points[1], scaleFactor);
} else if (points.length == 4 &&
(rawResult.getBarcodeFormat() == BarcodeFormat.UPC_A ||
rawResult.getBarcodeFormat() == BarcodeFormat.EAN_13)) {
// Hacky special case -- draw two lines, for the barcode and metadata
drawLine(canvas, paint, points[0], points[1], scaleFactor);
drawLine(canvas, paint, points[2], points[3], scaleFactor);
} else {
paint.setStrokeWidth(10.0f);
for (ResultPoint point : points) {
if (point != null) {
canvas.drawPoint(scaleFactor * point.getX(), scaleFactor * point.getY(), paint);
}
}
}
}
}
示例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(),
result.getNumBits(),
newResultPoints,
result.getBarcodeFormat(),
result.getTimestamp());
newResult.putAllMetadata(result.getResultMetadata());
return newResult;
}
示例8: handleResult
import com.google.zxing.Result; //导入方法依赖的package包/类
@Override
public void handleResult(Result rawResult) {
if ((rawResult.getBarcodeFormat() == BarcodeFormat.QR_CODE)) {
if (onScannedListener.onScanned(rawResult.getText())) {
return;
} else {
Toast.makeText(getActivity(), getString(R.string.send_qr_address_invalid), Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(getActivity(), getString(R.string.send_qr_invalid), Toast.LENGTH_SHORT).show();
}
// Note from dm77:
// * Wait 2 seconds to resume the preview.
// * On older devices continuously stopping and resuming camera preview can result in freezing the app.
// * I don't know why this is the case but I don't have the time to figure out.
Handler handler = new Handler();
handler.postDelayed(new
Runnable() {
@Override
public void run() {
mScannerView.resumeCameraPreview(ScannerFragment.this);
}
}, 2000);
}
示例9: parse
import com.google.zxing.Result; //导入方法依赖的package包/类
public ProductParsedResult parse(Result result) {
BarcodeFormat format = result.getBarcodeFormat();
if (format != BarcodeFormat.UPC_A && format != BarcodeFormat.UPC_E && format !=
BarcodeFormat.EAN_8 && format != BarcodeFormat.EAN_13) {
return null;
}
String rawText = ResultParser.getMassagedText(result);
if (!ResultParser.isStringOfDigits(rawText, rawText.length())) {
return null;
}
String normalizedProductID;
if (format == BarcodeFormat.UPC_E && rawText.length() == 8) {
normalizedProductID = UPCEReader.convertUPCEtoUPCA(rawText);
} else {
normalizedProductID = rawText;
}
return new ProductParsedResult(rawText, normalizedProductID);
}
示例10: parse
import com.google.zxing.Result; //导入方法依赖的package包/类
public VINParsedResult parse(Result result) {
if (result.getBarcodeFormat() != BarcodeFormat.CODE_39) {
return null;
}
String rawText = IOQ.matcher(result.getText()).replaceAll("").trim();
if (!AZ09.matcher(rawText).matches()) {
return null;
}
try {
if (!checkChecksum(rawText)) {
return null;
}
String wmi = rawText.substring(0, 3);
return new VINParsedResult(rawText, wmi, rawText.substring(3, 9), rawText.substring
(9, 17), countryCode(wmi), rawText.substring(3, 8), modelYear(rawText.charAt
(9)), rawText.charAt(10), rawText.substring(11));
} catch (IllegalArgumentException e) {
return null;
}
}
示例11: 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() + ((float) xOffset),
oldPoint.getY() + ((float) yOffset));
}
}
Result newResult = new Result(result.getText(), result.getRawBytes(), newResultPoints,
result.getBarcodeFormat());
newResult.putAllMetadata(result.getResultMetadata());
return newResult;
}
示例12: drawResultPoints
import com.google.zxing.Result; //导入方法依赖的package包/类
/**
* Superimpose a line for 1D or dots for 2D to highlight the key features of the barcode.
*
* @param barcode A bitmap of the captured image.
* @param scaleFactor amount by which thumbnail was scaled
* @param rawResult The decoded results which contains the points to draw.
*/
private void drawResultPoints(Bitmap barcode, float scaleFactor, Result rawResult) {
ResultPoint[] points = rawResult.getResultPoints();
if (points != null && points.length > 0) {
Canvas canvas = new Canvas(barcode);
Paint paint = new Paint();
paint.setColor(getResources().getColor(R.color.result_points));
if (points.length == 2) {
paint.setStrokeWidth(4.0f);
drawLine(canvas, paint, points[0], points[1], scaleFactor);
} else if (points.length == 4 &&
(rawResult.getBarcodeFormat() == BarcodeFormat.UPC_A ||
rawResult.getBarcodeFormat() == BarcodeFormat.EAN_13)) {
// Hacky special case -- draw two lines, for the barcode and metadata
drawLine(canvas, paint, points[0], points[1], scaleFactor);
drawLine(canvas, paint, points[2], points[3], scaleFactor);
} else {
paint.setStrokeWidth(10.0f);
for (ResultPoint point : points) {
if (point != null) {
canvas.drawPoint(scaleFactor * point.getX(), scaleFactor * point.getY(),
paint);
}
}
}
}
}
示例13: drawResultPoints
import com.google.zxing.Result; //导入方法依赖的package包/类
/**
* Superimpose a line for 1D or dots for 2D to highlight the key features of
* the barcode.
*
* @param barcode
* A bitmap of the captured image.
* @param scaleFactor
* amount by which thumbnail was scaled
* @param rawResult
* The decoded results which contains the points to draw.
*/
private void drawResultPoints(Bitmap barcode, float scaleFactor,
Result rawResult) {
ResultPoint[] points = rawResult.getResultPoints();
if (points != null && points.length > 0) {
Canvas canvas = new Canvas(barcode);
Paint paint = new Paint();
paint.setColor(getResources().getColor(R.color.result_points));
if (points.length == 2) {
paint.setStrokeWidth(4.0f);
drawLine(canvas, paint, points[0], points[1], scaleFactor);
} else if (points.length == 4
&& (rawResult.getBarcodeFormat() == BarcodeFormat.UPC_A || rawResult
.getBarcodeFormat() == BarcodeFormat.EAN_13)) {
// Hacky special case -- draw two lines, for the barcode and
// metadata
drawLine(canvas, paint, points[0], points[1], scaleFactor);
drawLine(canvas, paint, points[2], points[3], scaleFactor);
} else {
paint.setStrokeWidth(10.0f);
for (ResultPoint point : points) {
if (point != null) {
canvas.drawPoint(scaleFactor * point.getX(),
scaleFactor * point.getY(), paint);
}
}
}
}
}
示例14: drawResultPoints
import com.google.zxing.Result; //导入方法依赖的package包/类
/**
* Superimpose a line for 1D or dots for 2D to highlight the key features of
* the barcode.
*
* @param barcode
* A bitmap of the captured image.
* @param scaleFactor
* amount by which thumbnail was scaled
* @param rawResult
* The decoded results which contains the points to draw.
*/
private void drawResultPoints(Bitmap barcode, float scaleFactor,
Result rawResult) {
ResultPoint[] points = rawResult.getResultPoints();
if (points != null && points.length > 0) {
Canvas canvas = new Canvas(barcode);
Paint paint = new Paint();
paint.setColor(Color.parseColor("#c099cc00"));
if (points.length == 2) {
paint.setStrokeWidth(4.0f);
drawLine(canvas, paint, points[0], points[1], scaleFactor);
} else if (points.length == 4
&& (rawResult.getBarcodeFormat() == BarcodeFormat.UPC_A || rawResult
.getBarcodeFormat() == BarcodeFormat.EAN_13)) {
// Hacky special case -- draw two lines, for the barcode and
// metadata
drawLine(canvas, paint, points[0], points[1], scaleFactor);
drawLine(canvas, paint, points[2], points[3], scaleFactor);
} else {
paint.setStrokeWidth(10.0f);
for (ResultPoint point : points) {
if (point != null) {
canvas.drawPoint(scaleFactor * point.getX(),
scaleFactor * point.getY(), paint);
}
}
}
}
}
示例15: parse
import com.google.zxing.Result; //导入方法依赖的package包/类
public ISBNParsedResult parse(Result result) {
if (result.getBarcodeFormat() != BarcodeFormat.EAN_13) {
return null;
}
String rawText = ResultParser.getMassagedText(result);
if (rawText.length() != 13) {
return null;
}
if (rawText.startsWith("978") || rawText.startsWith("979")) {
return new ISBNParsedResult(rawText);
}
return null;
}