public String attemptDecodePicture(Bitmap thumbnail) {
   if (thumbnail == null) {
     Log.d(TAG, "No picture selected");
   } else {
     Log.d(TAG, "Picture selected");
     Result rawResult = null;
     Reader reader = new QRCodeReader();
     int w = thumbnail.getWidth();
     int h = thumbnail.getHeight();
     int maxOneDimension = 500;
     if (w * h > maxOneDimension * maxOneDimension) { // too big, reduce
       float bitmapRatio = (float) w / (float) h;
       if (bitmapRatio > 0) {
         w = maxOneDimension;
         h = (int) (w / bitmapRatio);
       } else {
         h = maxOneDimension;
         w = (int) (h * bitmapRatio);
       }
       thumbnail = Bitmap.createScaledBitmap(thumbnail, w, h, true);
     }
     int[] pixels = new int[w * h];
     thumbnail.getPixels(pixels, 0, w, 0, 0, w, h);
     RGBLuminanceSource source = new RGBLuminanceSource(w, h, pixels);
     if (source.getMatrix() != null) {
       BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
       try {
         rawResult = reader.decode(bitmap);
       } catch (ReaderException re) {
         re.printStackTrace();
       } finally {
         reader.reset();
       }
     }
     if (rawResult != null) {
       Log.d(TAG, "QR code found " + rawResult.getText());
       return rawResult.getText();
     } else {
       Log.d(TAG, "Picture No QR code found");
     }
   }
   return null;
 }
 public String attemptDecodeBytes(byte[] bytes, Camera camera) {
   Result rawResult = null;
   Reader reader = new QRCodeReader();
   int w = camera.getParameters().getPreviewSize().width;
   int h = camera.getParameters().getPreviewSize().height;
   PlanarYUVLuminanceSource source = new PlanarYUVLuminanceSource(bytes, w, h, 0, 0, w, h, false);
   if (source.getMatrix() != null) {
     BinaryBitmap bitmap = new BinaryBitmap(new GlobalHistogramBinarizer(source));
     try {
       rawResult = reader.decode(bitmap);
     } catch (ReaderException re) {
       // nothing to do here
     } finally {
       reader.reset();
     }
   }
   if (rawResult != null) {
     Log.d(TAG, "QR code found " + rawResult.getText());
     return rawResult.getText();
   } else {
     return null;
   }
 }
 //  @Override
 public void reset() {
   delegate.reset();
 }