use of cn.bingoogolapple.qrcode.core.ScanResult in project BGAQRCode-Android by bingoogolapple.
the class ZBarView method processData.
@Override
protected ScanResult processData(byte[] data, int width, int height, boolean isRetry) {
Image barcode = new Image(width, height, "Y800");
Rect scanBoxAreaRect = mScanBoxView.getScanBoxAreaRect(height);
if (scanBoxAreaRect != null && !isRetry && scanBoxAreaRect.left + scanBoxAreaRect.width() <= width && scanBoxAreaRect.top + scanBoxAreaRect.height() <= height) {
barcode.setCrop(scanBoxAreaRect.left, scanBoxAreaRect.top, scanBoxAreaRect.width(), scanBoxAreaRect.height());
}
barcode.setData(data);
String result = processData(barcode);
return new ScanResult(result);
}
use of cn.bingoogolapple.qrcode.core.ScanResult in project BGAQRCode-Android by bingoogolapple.
the class ZBarView method processBitmapData.
@Override
protected ScanResult processBitmapData(Bitmap bitmap) {
try {
int picWidth = bitmap.getWidth();
int picHeight = bitmap.getHeight();
Image barcode = new Image(picWidth, picHeight, "RGB4");
int[] pix = new int[picWidth * picHeight];
bitmap.getPixels(pix, 0, picWidth, 0, 0, picWidth, picHeight);
barcode.setData(pix);
String result = processData(barcode.convert("Y800"));
return new ScanResult(result);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
use of cn.bingoogolapple.qrcode.core.ScanResult in project BGAQRCode-Android by bingoogolapple.
the class ZXingView method processData.
@Override
protected ScanResult processData(byte[] data, int width, int height, boolean isRetry) {
Result rawResult = null;
Rect scanBoxAreaRect = null;
try {
PlanarYUVLuminanceSource source;
scanBoxAreaRect = mScanBoxView.getScanBoxAreaRect(height);
if (scanBoxAreaRect != null) {
source = new PlanarYUVLuminanceSource(data, width, height, scanBoxAreaRect.left, scanBoxAreaRect.top, scanBoxAreaRect.width(), scanBoxAreaRect.height(), false);
} else {
source = new PlanarYUVLuminanceSource(data, width, height, 0, 0, width, height, false);
}
rawResult = mMultiFormatReader.decodeWithState(new BinaryBitmap(new GlobalHistogramBinarizer(source)));
if (rawResult == null) {
rawResult = mMultiFormatReader.decodeWithState(new BinaryBitmap(new HybridBinarizer(source)));
if (rawResult != null) {
BGAQRCodeUtil.d("GlobalHistogramBinarizer 没识别到,HybridBinarizer 能识别到");
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
mMultiFormatReader.reset();
}
if (rawResult == null) {
return null;
}
String result = rawResult.getText();
if (TextUtils.isEmpty(result)) {
return null;
}
BarcodeFormat barcodeFormat = rawResult.getBarcodeFormat();
BGAQRCodeUtil.d("格式为:" + barcodeFormat.name());
// 处理自动缩放和定位点
boolean isNeedAutoZoom = isNeedAutoZoom(barcodeFormat);
if (isShowLocationPoint() || isNeedAutoZoom) {
ResultPoint[] resultPoints = rawResult.getResultPoints();
final PointF[] pointArr = new PointF[resultPoints.length];
int pointIndex = 0;
for (ResultPoint resultPoint : resultPoints) {
pointArr[pointIndex] = new PointF(resultPoint.getX(), resultPoint.getY());
pointIndex++;
}
if (transformToViewCoordinates(pointArr, scanBoxAreaRect, isNeedAutoZoom, result)) {
return null;
}
}
return new ScanResult(result);
}
Aggregations