當前位置: 首頁>>代碼示例>>Java>>正文


Java MultiFormatReader.decode方法代碼示例

本文整理匯總了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;
    }
}
 
開發者ID:wavinsun,項目名稱:MUtils,代碼行數:20,代碼來源:QRCodeUtil.java

示例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();
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:17,代碼來源:BarcodeDataFormat.java

示例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());        
}
 
開發者ID:phonedeck,項目名稱:lqrt,代碼行數:15,代碼來源:LQRTTest.java


注:本文中的com.google.zxing.MultiFormatReader.decode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。