static BitmapSampled cropBitmap(
      Context context,
      Uri loadedImageUri,
      float[] points,
      int degreesRotated,
      int orgWidth,
      int orgHeight,
      boolean fixAspectRatio,
      int aspectRatioX,
      int aspectRatioY,
      int reqWidth,
      int reqHeight,
      boolean flipHorizontally,
      boolean flipVertically) {
    int sampleMulti = 1;
    while (true) {
      try {
        // if successful, just return the resulting bitmap
        return cropBitmap(
            context,
            loadedImageUri,
            points,
            degreesRotated,
            orgWidth,
            orgHeight,
            fixAspectRatio,
            aspectRatioX,
            aspectRatioY,
            reqWidth,
            reqHeight,
            flipHorizontally,
            flipVertically,
            sampleMulti);
      } catch (OutOfMemoryError e) {
        // if OOM try to increase the sampling to lower the memory usage
        sampleMulti *= 2;
        if (sampleMulti > 16) {
          throw new RuntimeException(
              "Failed to handle OOM by sampling ("
                  + sampleMulti
                  + "): "
                  + loadedImageUri
                  + "\r\n"
                  + e.getMessage(),
              e);
        }
      }
    }
  }
Crop image bitmap from URI by decoding it with specific width and height to down-sample if
required.<br>
Additionally if OOM is thrown try to increase the sampling (2,4,8).
core/src/main/java/com/theartofdev/edmodo/cropper/BitmapUtils.java