本文整理匯總了Java中com.google.zxing.MultiFormatReader.decode方法的典型用法代碼示例。如果您正苦於以下問題:Java MultiFormatReader.decode方法的具體用法?Java MultiFormatReader.decode怎麽用?Java MultiFormatReader.decode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.zxing.MultiFormatReader
的用法示例。
在下文中一共展示了MultiFormatReader.decode方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: convert
import com.google.zxing.MultiFormatReader; //導入方法依賴的package包/類
public static String convert(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 rgbLuminanceSource = new RGBLuminanceSource(
width, height, pixels);
BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(
rgbLuminanceSource));
HashMap<DecodeHintType, Object> hints = new HashMap<DecodeHintType, Object>();
hints.put(DecodeHintType.CHARACTER_SET, DEFAULT_CHARSET);
MultiFormatReader multiFormatReader = new MultiFormatReader();
Result result = multiFormatReader.decode(binaryBitmap, hints);
return result.getText();
} catch (Exception e) {
return null;
}
}
示例2: readImage
import com.google.zxing.MultiFormatReader; //導入方法依賴的package包/類
/**
* Reads the message from a code.
*/
private String readImage(final Exchange exchange, final InputStream stream) throws Exception {
final MultiFormatReader reader = new MultiFormatReader();
final BufferedInputStream in = exchange.getContext()
.getTypeConverter()
.mandatoryConvertTo(BufferedInputStream.class, stream);
final BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(new BufferedImageLuminanceSource(ImageIO.read(in))));
final Result result = reader.decode(bitmap, readerHintMap);
// write the found barcode format into the header
exchange.getOut().setHeader(Barcode.BARCODE_FORMAT, result.getBarcodeFormat());
return result.getText();
}
示例3: text
import com.google.zxing.MultiFormatReader; //導入方法依賴的package包/類
@Test
public void text() throws WriterException, IOException, NotFoundException {
QRCode code = LQRT.qr(TEXT, ErrorCorrectionLevel.L, null);
ImageQRPainter iqrp = new ImageQRPainter();
iqrp.paint(code);
BinaryBitmap bb = imageToBitmap(iqrp.getImage());
MultiFormatReader mfr = new MultiFormatReader();
Result res = mfr.decode(bb);
assertEquals(TEXT, res.getText());
assertEquals(BarcodeFormat.QR_CODE, res.getBarcodeFormat());
}