Basically, I have a rectangular bitmap and want to create a new Bitmap with squared dimensions which will contain the rectangular bitmap inside of it.
So, for example, i
Try this:
private static Bitmap createSquaredBitmap(Bitmap srcBmp) {
int dim = Math.max(srcBmp.getWidth(), srcBmp.getHeight());
Bitmap dstBmp = Bitmap.createBitmap(dim, dim, Config.ARGB_8888);
Canvas canvas = new Canvas(dstBmp);
canvas.drawColor(Color.WHITE);
canvas.drawBitmap(srcBmp, (dim - srcBmp.getWidth()) / 2, (dim - srcBmp.getHeight()) / 2, null);
return dstBmp;
}