本文整理匯總了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;
}