@NonNull
    private static BitmapDrawable scaleBitmapTo(@NonNull final Bitmap image, final int maxWidth, final int maxHeight, final int minWidth, final int minHeight) {
        final Application app = CgeoApplication.getInstance();
        Bitmap result = image;
        final ImmutableTriple<Integer, Integer, Boolean> scaledSize = calculateScaledImageSizes(image.getWidth(), image.getHeight(), maxWidth, maxHeight, minWidth, minHeight);

        if (scaledSize.right) {
            if (image.getConfig() == null) {
                // see #15526: surprisingly, Bitmaps with getConfig() == null may causing a NPE when using BitmapCompat...
                result = Bitmap.createScaledBitmap(image, scaledSize.left, scaledSize.middle, true);
            } else {
                result = BitmapCompat.createScaledBitmap(image, scaledSize.left, scaledSize.middle, null, true);
            }
        }

        final BitmapDrawable resultDrawable = new BitmapDrawable(app.getResources(), result);
        resultDrawable.setBounds(new Rect(0, 0, scaledSize.left, scaledSize.middle));

        return resultDrawable;
    }
Scales a bitmap to the given bounds if it is larger, otherwise returns the original bitmap (except when "force" is set to true)

@param image The bitmap to scale
@return BitmapDrawable The scaled image
main/src/main/java/cgeo/geocaching/utils/ImageUtils.java