0
 val mBitmap: Bitmap = BitmapFactory.decodeFile(compressedFile.path)
 val pixels = IntArray(mBitmap.width * mBitmap.height)
 mBitmap.getPixels(pixels, 0, mBitmap.width, 0, 0, mBitmap.width,mBitmap.height)

 val rawResult: Result
 try {
      rawResult =QRCodeReader().decode(BinaryBitmap(HybridBinarizer(RGBLuminanceSource(mBitmap.width, mBitmap.height, pixels))))
      mBitmap.recycle()
      Observable.just(rawResult.text!!)
 } catch (e: Exception) {
      mBitmap.recycle()
      Observable.error<String>(e)
 }

I use zxing to decode pickture picked from android gallery, if the image is download from chrome, it decoded successfully, but if the image is taken from android camera, it thrown NotFoundException. I don`t known the reason.

  • I don't know how this looks for kotlin, but I was facing similar issue in java. The problem was I wasn't really saving taken picture. I was able to take it, or crop it, and even set it inside ImageView, but when I tried to open it later I couldn't find it. – SkypeDogg Dec 05 '18 at 08:11
  • Check for `path`, See if you are getting right path, And have permission to read the file . – ADM Dec 05 '18 at 08:24
  • The path is correct, I used a ImageView to display the bitmap decoded from file, I could see the picture display correctly – Fitz.Lu Dec 05 '18 at 08:34

0 Answers0