public static Bitmap addPadding(@NonNull Bitmap bmp) {

        int biggerParam = Math.max(bmp.getWidth(), bmp.getHeight());
        Bitmap bitmap = Bitmap.createBitmap(biggerParam, biggerParam, bmp.getConfig());
        Canvas canvas = new Canvas(bitmap);
        canvas.drawColor(Color.WHITE);

        int top = bmp.getHeight() > bmp.getWidth() ? 0 : (bmp.getWidth() - bmp.getHeight())/2;
        int left = bmp.getWidth() > bmp.getHeight() ? 0 : (bmp.getHeight() - bmp.getWidth())/2;

        canvas.drawBitmap(bmp, left, top, null);
        return bitmap;
    }
Write the given bitmap into the given file. JPEG is used as the compression format with
quality set
to 100.

@param bm   The bitmap.
@param file The file to write the bitmap into.
sample/src/main/java/com/fenctose/imagecropper/BitmapUtils.java