本文整理汇总了Java中com.google.zxing.MultiFormatReader.reset方法的典型用法代码示例。如果您正苦于以下问题:Java MultiFormatReader.reset方法的具体用法?Java MultiFormatReader.reset怎么用?Java MultiFormatReader.reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.zxing.MultiFormatReader
的用法示例。
在下文中一共展示了MultiFormatReader.reset方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decodeWithZxing
import com.google.zxing.MultiFormatReader; //导入方法依赖的package包/类
public String decodeWithZxing(byte[] data, int width, int height, Rect crop) {
MultiFormatReader multiFormatReader = new MultiFormatReader();
multiFormatReader.setHints(changeZXingDecodeDataMode());
Result rawResult = null;
PlanarYUVLuminanceSource source = new PlanarYUVLuminanceSource(data, width, height,
crop.left, crop.top, crop.width(), crop.height(), false);
if (source != null) {
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
try {
rawResult = multiFormatReader.decodeWithState(bitmap);
} catch (ReaderException re) {
// continue
} finally {
multiFormatReader.reset();
}
}
return rawResult != null ? rawResult.getText() : null;
}
示例2: decodeWithZxing
import com.google.zxing.MultiFormatReader; //导入方法依赖的package包/类
public Result decodeWithZxing(Bitmap bitmap) {
MultiFormatReader multiFormatReader = new MultiFormatReader();
multiFormatReader.setHints(changeZXingDecodeDataMode());
int width = bitmap.getWidth();
int height = bitmap.getHeight();
int[] pixels = new int[width * height];
bitmap.getPixels(pixels, 0, width, 0, 0, width, height);
Result rawResult = null;
RGBLuminanceSource source = new RGBLuminanceSource(width, height, pixels);
BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(source));
try {
rawResult = multiFormatReader.decodeWithState(binaryBitmap);
} catch (ReaderException re) {
// continue
} finally {
multiFormatReader.reset();
}
return rawResult;
}
示例3: doInBackground
import com.google.zxing.MultiFormatReader; //导入方法依赖的package包/类
@Override
protected Result doInBackground(Void... params) {
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(luminanceSource));
Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>(3);
hints.put(DecodeHintType.CHARACTER_SET, "UTF-8");
hints.put(DecodeHintType.NEED_RESULT_POINT_CALLBACK, listener);
MultiFormatReader multiFormatReader = new MultiFormatReader();
multiFormatReader.setHints(hints);
long start = System.currentTimeMillis();
Result rawResult = null;
try {
rawResult = multiFormatReader.decodeWithState(bitmap);
mBitmap = luminanceSource.renderCroppedGreyScaleBitmap();
long end = System.currentTimeMillis();
Log.d("DecodeThread", "Decode use " + (end - start) + "ms");
} catch (ReaderException re) {
} finally {
multiFormatReader.reset();
}
return rawResult;
}
示例4: scanningImage
import com.google.zxing.MultiFormatReader; //导入方法依赖的package包/类
public Result scanningImage(String path) {
if (TextUtils.isEmpty(path)) {
return null;
}
multiFormatReader = new MultiFormatReader();
//BufferedImage image =null;
Hashtable<DecodeHintType, String> hints = new Hashtable<DecodeHintType, String>();
hints.put(DecodeHintType.CHARACTER_SET, "UTF8");
multiFormatReader.setHints(hints);
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
Bitmap scanBitmap = BitmapFactory.decodeFile(path, options);
options.inJustDecodeBounds = false;
int sampleSize = (int) (options.outHeight / (float) 200);
if (sampleSize <= 0)
sampleSize = 1;
scanBitmap = BitmapFactory.decodeFile(path, options);
RGBLuminanceSource source = new RGBLuminanceSource(scanBitmap);
BinaryBitmap bitmap1 = new BinaryBitmap(new HybridBinarizer(source));
try {
return multiFormatReader.decodeWithState(bitmap1);
} catch (ReaderException re) {
// continue
} finally {
multiFormatReader.reset();
}
return null;
}