private static int calculateInSampleSizeByMaxTextureSize(int width, int height) {
    int inSampleSize = 1;
    if (mMaxTextureSize == 0) {
      mMaxTextureSize = getMaxTextureSize();
    }
    if (mMaxTextureSize > 0) {
      while ((height / inSampleSize) > mMaxTextureSize
          || (width / inSampleSize) > mMaxTextureSize) {
        inSampleSize *= 2;
      }
    }
    return inSampleSize;
  }
Calculate the largest inSampleSize value that is a power of 2 and keeps both height and width
smaller than max texture size allowed for the device.
core/src/main/java/com/theartofdev/edmodo/cropper/BitmapUtils.java