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


Java Reader類代碼示例

本文整理匯總了Java中com.google.zxing.Reader的典型用法代碼示例。如果您正苦於以下問題:Java Reader類的具體用法?Java Reader怎麽用?Java Reader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Reader類屬於com.google.zxing包,在下文中一共展示了Reader類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doInBackground

import com.google.zxing.Reader; //導入依賴的package包/類
/**
 * Searches Bitmap image for a QR code, and returns the String representation
 * of it if a valid QR code was found.
 * Returns empty String if no valid QR code was found.
 *
 * @param bitmap The Bitmap to decode
 * @return The string representation of the Bitmap, or "" if no valid QR code was found
 */
@Override
protected String doInBackground(BinaryBitmap... bitmap) {
    String decodedText;
    // get QR reader
    final Reader reader = new QRCodeReader();
    // try to decode QR code
    try {
        // get Result from decoder
        final Result result = reader.decode(bitmap[0]);
        // get text from Result
        decodedText = result.getText();
    } catch (Exception e) {
        // set text to blank, no QR code found
        decodedText = "";
    }
    // return text
    return decodedText;
}
 
開發者ID:cscd-488,項目名稱:event-app,代碼行數:27,代碼來源:DecodeImageTask.java

示例2: processImage

import com.google.zxing.Reader; //導入依賴的package包/類
public IAnswerData processImage(Image image)
        throws ImageProcessingException {
    MonochromeBitmapSource source = new LCDUIImageMonochromeBitmapSource(
            image);
    Reader reader = new QRCodeReader();
    Hashtable hints = new Hashtable();
    // hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);

    try {
        Result result = reader.decode(source, hints);
        if ((result != null) && (result.getText() != null)) {
            String scannedCode = result.getText();
            return new StringData(scannedCode);
        } else {
            throw new ImageProcessingException("Barcode scanning failed");
        }
    } catch (ReaderException re) {
        throw new ImageProcessingException("Barcode scanning failed");
    }
}
 
開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:21,代碼來源:ZXingBarcodeProcessingService.java

示例3: onPreviewFrame

import com.google.zxing.Reader; //導入依賴的package包/類
@Override
public void onPreviewFrame(byte[] data, Camera camera) {
    int previewWidth = camera.getParameters().getPreviewSize().width;
    int previewHeight = camera.getParameters().getPreviewSize().height;

    PlanarYUVLuminanceSource source = new PlanarYUVLuminanceSource(
            data, previewWidth, previewHeight, 0, 0, previewWidth,
            previewHeight, false);
    BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));

    Reader reader = new QRCodeReader();
    try {

        Result result = reader.decode(bitmap);
        String text = result.getText();

        Intent intent = new Intent();
        intent.setData(Uri.parse(text));
        setResult(RESULT_OK, intent);
        finish();
    } catch (Exception e) {
        e.printStackTrace();
        Toast.makeText(getApplicationContext(), "Not Found",
                Toast.LENGTH_SHORT).show();
    }
}
 
開發者ID:android-opensource-library-56,項目名稱:android-opensource-library-56,代碼行數:27,代碼來源:BarcodeScanCameraActivity.java

示例4: AbstractBlackBoxTestCase

import com.google.zxing.Reader; //導入依賴的package包/類
protected AbstractBlackBoxTestCase(String testBasePathSuffix,
                                   Reader barcodeReader,
                                   BarcodeFormat expectedFormat) {
  // A little workaround to prevent aggravation in my IDE
  File testBase = new File(testBasePathSuffix);
  if (!testBase.exists()) {
    // try starting with 'core' since the test base is often given as the project root
    testBase = new File("core/" + testBasePathSuffix);
  }
  this.testBase = testBase;
  this.barcodeReader = barcodeReader;
  this.expectedFormat = expectedFormat;
  testResults = new ArrayList<TestResult>();

  System.setProperty("java.util.logging.SimpleFormatter.format", "%4$s: %5$s%6$s%n");
}
 
開發者ID:yinglovezhuzhu,項目名稱:ZxingCore,代碼行數:17,代碼來源:AbstractBlackBoxTestCase.java

示例5: scanBitmap

import com.google.zxing.Reader; //導入依賴的package包/類
public Result scanBitmap(Bitmap bitmap) throws FormatException, ChecksumException, NotFoundException {
    Reader reader = new MultiFormatReader();
    Result result;

    int[] intArray = new int[bitmap.getWidth() * bitmap.getHeight()];
    //copy pixel data from the Bitmap into the 'intArray' array
    bitmap.getPixels(intArray, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight());

    LuminanceSource source = new RGBLuminanceSource(bitmap.getWidth(), bitmap.getHeight(), intArray);
    BinaryBitmap bMap = new BinaryBitmap(new HybridBinarizer(source));

    result = reader.decode(bMap);

    return result;
}
 
開發者ID:areebbeigh,項目名稱:QRCodeUtility,代碼行數:16,代碼來源:ActivityHelper.java

示例6: checkFormat

import com.google.zxing.Reader; //導入依賴的package包/類
private void checkFormat(File file, BarcodeFormat format) throws IOException {
    Reader reader = new MultiFormatReader();
    BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(new BufferedImageLuminanceSource(ImageIO.read(file))));
    Result result;
    try {
        result = reader.decode(bitmap);
    } catch (ReaderException ex) {
        throw new IOException(ex);
    }
    
    assertEquals(format, result.getBarcodeFormat());
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:13,代碼來源:BarcodeTestBase.java

示例7: findReader

import com.google.zxing.Reader; //導入依賴的package包/類
/**
 * Returns a ZXing reader that can read the specified symbol.
 *
 * @param symbol the symbol to be read
 * @return a ZXing reader that can read the specified symbol
 */
private static Reader findReader(Symbol symbol) {

    if (symbol instanceof Code128 || symbol instanceof UspsPackage) {
        return new Code128Reader();
    } else if (symbol instanceof Code93) {
        return new Code93Reader();
    } else if (symbol instanceof Code3Of9) {
        return new Code39Reader();
    } else if (symbol instanceof Codabar) {
        return new CodaBarReader();
    } else if (symbol instanceof AztecCode) {
        return new AztecReader();
    } else if (symbol instanceof QrCode) {
        return new QRCodeReader();
    } else if (symbol instanceof Ean) {
        Ean ean = (Ean) symbol;
        if (ean.getMode() == Ean.Mode.EAN8) {
            return new EAN8Reader();
        } else {
            return new EAN13Reader();
        }
    } else if (symbol instanceof Pdf417) {
        Pdf417 pdf417 = (Pdf417) symbol;
        if (pdf417.getMode() != Pdf417.Mode.MICRO) {
            return new PDF417Reader();
        }
    } else if (symbol instanceof Upc) {
        Upc upc = (Upc) symbol;
        if (upc.getMode() == Upc.Mode.UPCA) {
            return new UPCAReader();
        } else {
            return new UPCEReader();
        }
    }

    // no corresponding ZXing reader exists, or it behaves badly so we don't use it for testing
    return null;
}
 
開發者ID:woo-j,項目名稱:OkapiBarcode,代碼行數:45,代碼來源:SymbolTest.java

示例8: AbstractBlackBoxTestCase

import com.google.zxing.Reader; //導入依賴的package包/類
protected AbstractBlackBoxTestCase(String testBasePathSuffix,
                                   Reader barcodeReader,
                                   BarcodeFormat expectedFormat) {
  this.testBase = buildTestBase(testBasePathSuffix);
  this.barcodeReader = barcodeReader;
  this.expectedFormat = expectedFormat;
  testResults = new ArrayList<>();

  System.setProperty("java.util.logging.SimpleFormatter.format", "%4$s: %5$s%6$s%n");
}
 
開發者ID:srowen,項目名稱:zxing-bsplus,代碼行數:11,代碼來源:AbstractBlackBoxTestCase.java

示例9: AbstractBlackBoxTestCase

import com.google.zxing.Reader; //導入依賴的package包/類
protected AbstractBlackBoxTestCase(String testBasePathSuffix,
                                   Reader barcodeReader,
                                   BarcodeFormat expectedFormat) {
  // A little workaround to prevent aggravation in my IDE
  File testBase = new File(testBasePathSuffix);
  if (!testBase.exists()) {
    // try starting with 'core' since the test base is often given as the project root
    testBase = new File("core/" + testBasePathSuffix);
  }
  this.testBase = testBase;
  this.barcodeReader = barcodeReader;
  this.expectedFormat = expectedFormat;
  testResults = new ArrayList<TestResult>();
}
 
開發者ID:da-baumann,項目名稱:dev,代碼行數:15,代碼來源:AbstractBlackBoxTestCase.java

示例10: reset

import com.google.zxing.Reader; //導入依賴的package包/類
public void reset() {
  int size = readers.size();
  for (int i = 0; i < size; i++) {
    Reader reader = (Reader) readers.elementAt(i);
    reader.reset();
  }
}
 
開發者ID:saqimtiaz,項目名稱:BibSearch,代碼行數:8,代碼來源:MultiFormatOneDReader.java

示例11: reset

import com.google.zxing.Reader; //導入依賴的package包/類
@Override
public void reset() {
  for (Reader reader : readers) {
    reader.reset();
  }
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:7,代碼來源:MultiFormatOneDReader.java

示例12: GenericMultipleBarcodeReader

import com.google.zxing.Reader; //導入依賴的package包/類
public GenericMultipleBarcodeReader(Reader delegate) {
  this.delegate = delegate;
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:4,代碼來源:GenericMultipleBarcodeReader.java

示例13: ByQuadrantReader

import com.google.zxing.Reader; //導入依賴的package包/類
public ByQuadrantReader(Reader delegate) {
  this.delegate = delegate;
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:4,代碼來源:ByQuadrantReader.java

示例14: getReader

import com.google.zxing.Reader; //導入依賴的package包/類
protected Reader getReader() {
    return reader;
}
 
開發者ID:yinhaojun,項目名稱:ZxingForAndroid,代碼行數:4,代碼來源:Decoder.java

示例15: reset

import com.google.zxing.Reader; //導入依賴的package包/類
public void reset() {
    for (Reader reader : this.readers) {
        reader.reset();
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:6,代碼來源:MultiFormatOneDReader.java


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