Java 类com.google.zxing.Reader 实例源码

项目:event-app    文件:DecodeImageTask.java   
/**
 * 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;
}
项目:commcare-j2me    文件:ZXingBarcodeProcessingService.java   
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");
    }
}
项目:android-opensource-library-56    文件:BarcodeScanCameraActivity.java   
@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();
    }
}
项目:ZxingCore    文件:AbstractBlackBoxTestCase.java   
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");
}
项目:QRCodeUtility    文件:ActivityHelper.java   
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;
}
项目:Camel    文件:BarcodeTestBase.java   
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());
}
项目:bd-codes    文件:CodeReader.java   
public static void main(String[] args) throws ReaderException,
            InterruptedException {
        Reader reader = new MultiFormatReader(); 
        String imgPath = "qr1.gif";
        Image image = java.awt.Toolkit.getDefaultToolkit().getImage(imgPath);
        BufferedImage myImage = CodeReader.imageToBufImage(image);
//      MonochromeBitmapSource source = new BufferedImageMonochromeBitmapSource(
//              myImage);
//      Result result = reader.decode(source);
//      System.out.println(result.getText());
    }
项目:OkapiBarcode    文件:SymbolTest.java   
/**
 * 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;
}
项目:zxing-bsplus    文件:AbstractBlackBoxTestCase.java   
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");
}
项目:dev    文件:AbstractBlackBoxTestCase.java   
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>();
}
项目:BibSearch    文件:MultiFormatOneDReader.java   
public void reset() {
  int size = readers.size();
  for (int i = 0; i < size; i++) {
    Reader reader = (Reader) readers.elementAt(i);
    reader.reset();
  }
}
项目:BibSearch    文件:MultiFormatUPCEANReader.java   
public void reset() {
  int size = readers.size();
  for (int i = 0; i < size; i++) {
    Reader reader = (Reader) readers.elementAt(i);
    reader.reset();
  }
}
项目:weex-3d-map    文件:MultiFormatOneDReader.java   
@Override
public void reset() {
  for (Reader reader : readers) {
    reader.reset();
  }
}
项目:weex-3d-map    文件:MultiFormatUPCEANReader.java   
@Override
public void reset() {
  for (Reader reader : readers) {
    reader.reset();
  }
}
项目:weex-3d-map    文件:GenericMultipleBarcodeReader.java   
public GenericMultipleBarcodeReader(Reader delegate) {
  this.delegate = delegate;
}
项目:weex-3d-map    文件:ByQuadrantReader.java   
public ByQuadrantReader(Reader delegate) {
  this.delegate = delegate;
}
项目:ZxingForAndroid    文件:Decoder.java   
protected Reader getReader() {
    return reader;
}
项目:QrCode    文件:MultiFormatOneDReader.java   
@Override
public void reset() {
  for (Reader reader : readers) {
    reader.reset();
  }
}
项目:QrCode    文件:MultiFormatUPCEANReader.java   
@Override
public void reset() {
  for (Reader reader : readers) {
    reader.reset();
  }
}
项目:QrCode    文件:GenericMultipleBarcodeReader.java   
public GenericMultipleBarcodeReader(Reader delegate) {
  this.delegate = delegate;
}
项目:QrCode    文件:ByQuadrantReader.java   
public ByQuadrantReader(Reader delegate) {
  this.delegate = delegate;
}
项目:boohee_v5.6    文件:MultiFormatOneDReader.java   
public void reset() {
    for (Reader reader : this.readers) {
        reader.reset();
    }
}
项目:boohee_v5.6    文件:MultiFormatUPCEANReader.java   
public void reset() {
    for (Reader reader : this.readers) {
        reader.reset();
    }
}
项目:boohee_v5.6    文件:GenericMultipleBarcodeReader.java   
public GenericMultipleBarcodeReader(Reader delegate) {
    this.delegate = delegate;
}
项目:boohee_v5.6    文件:ByQuadrantReader.java   
public ByQuadrantReader(Reader delegate) {
    this.delegate = delegate;
}
项目:Tesseract-OCR-Scanner    文件:MultiFormatOneDReader.java   
@Override
public void reset() {
  for (Reader reader : readers) {
    reader.reset();
  }
}
项目:Tesseract-OCR-Scanner    文件:MultiFormatUPCEANReader.java   
@Override
public void reset() {
  for (Reader reader : readers) {
    reader.reset();
  }
}
项目:Tesseract-OCR-Scanner    文件:GenericMultipleBarcodeReader.java   
public GenericMultipleBarcodeReader(Reader delegate) {
  this.delegate = delegate;
}
项目:Tesseract-OCR-Scanner    文件:ByQuadrantReader.java   
public ByQuadrantReader(Reader delegate) {
  this.delegate = delegate;
}
项目:QrCodeScanner    文件:MultiFormatOneDReader.java   
@Override
public void reset() {
  for (Reader reader : readers) {
    reader.reset();
  }
}
项目:QrCodeScanner    文件:MultiFormatUPCEANReader.java   
@Override
public void reset() {
  for (Reader reader : readers) {
    reader.reset();
  }
}
项目:QrCodeScanner    文件:GenericMultipleBarcodeReader.java   
public GenericMultipleBarcodeReader(Reader delegate) {
  this.delegate = delegate;
}
项目:QrCodeScanner    文件:ByQuadrantReader.java   
public ByQuadrantReader(Reader delegate) {
  this.delegate = delegate;
}
项目:PortraitZXing    文件:MultiFormatOneDReader.java   
@Override
public void reset() {
  for (Reader reader : readers) {
    reader.reset();
  }
}
项目:PortraitZXing    文件:MultiFormatUPCEANReader.java   
@Override
public void reset() {
  for (Reader reader : readers) {
    reader.reset();
  }
}
项目:PortraitZXing    文件:GenericMultipleBarcodeReader.java   
public GenericMultipleBarcodeReader(Reader delegate) {
  this.delegate = delegate;
}
项目:PortraitZXing    文件:ByQuadrantReader.java   
public ByQuadrantReader(Reader delegate) {
  this.delegate = delegate;
}
项目:PortraitZXing    文件:MultiFormatOneDReader.java   
@Override
public void reset() {
  for (Reader reader : readers) {
    reader.reset();
  }
}
项目:PortraitZXing    文件:MultiFormatUPCEANReader.java   
@Override
public void reset() {
  for (Reader reader : readers) {
    reader.reset();
  }
}
项目:PortraitZXing    文件:GenericMultipleBarcodeReader.java   
public GenericMultipleBarcodeReader(Reader delegate) {
  this.delegate = delegate;
}