How to create a square bitmap from a rectangular bitmap in Android

view story

http://stackoverflow.com – 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, if the source bitmap has width:100 and height:400, I want a new bitmap with width:400 and height:400. Then, draw the source bitmap centered inside of this new bitmap (see attached image for a better understanding). My code below creates the square bitmap fine, but the source bitmap is not being drawn into it. As a result, I'm left with a bitmap that is completely black. Here is the code: Bitmap sourceBitmap = BitmapFactory (HowTos)