private static Bitmap decodeImage(
      ContentResolver resolver, Uri uri, BitmapFactory.Options options)
      throws FileNotFoundException {
    do {
      InputStream stream = null;
      try {
        stream = resolver.openInputStream(uri);
        return BitmapFactory.decodeStream(stream, EMPTY_RECT, options);
      } catch (OutOfMemoryError e) {
        options.inSampleSize *= 2;
      } finally {
        closeSafe(stream);
      }
    } while (options.inSampleSize <= 512);
    throw new RuntimeException("Failed to decode image: " + uri);
  }
Decode image from uri using given "inSampleSize", but if failed due to out-of-memory then raise
the inSampleSize until success.
core/src/main/java/com/theartofdev/edmodo/cropper/BitmapUtils.java