question: private static Bitmap createPaddedBitmap ( Bitmap bitmapIn , XMPMeta xmp , int intermediateWidth ) { try { int croppedAreaWidth = getInt ( xmp , CROPPED_AREA_IMAGE_WIDTH_PIXELS ) ; int croppedAreaHeight = getInt ( xmp , CROPPED_AREA_IMAGE_HEIGHT_PIXELS ) ; int fullPanoWidth = getInt ( xmp , CROPPED_AREA_FULL_PANO_WIDTH_PIXELS ) ; int fullPanoHeight = getInt ( xmp , CROPPED_AREA_FULL_PANO_HEIGHT_PIXELS ) ; int left = getInt ( xmp , CROPPED_AREA_LEFT ) ; int top = getInt ( xmp , CROPPED_AREA_TOP ) ; if ( fullPanoWidth == 0 || fullPanoHeight == 0 ) { return bitmapIn ; } Bitmap paddedBitmap = null ; float scale = intermediateWidth / ( float ) fullPanoWidth ; while ( paddedBitmap == null ) { try { paddedBitmap = Bitmap . createBitmap ( ( int ) ( fullPanoWidth * scale ) , ( int ) ( fullPanoHeight * scale ) , Bitmap . Config . ARGB_8888 ) ; } catch ( OutOfMemoryError e ) { System . gc ( ) ; scale /= 2 ; } } Canvas paddedCanvas = new Canvas ( paddedBitmap ) ; int right = left + croppedAreaWidth ; int bottom = top + croppedAreaHeight ; RectF destRect = new RectF ( left * scale , top * scale , right * scale , bottom * scale ) ; paddedCanvas . drawBitmap ( bitmapIn , null , destRect , null ) ; return paddedBitmap ; } catch ( XMPException ex ) { } return bitmapIn ; }
target:  To create a proper TinyPlanet, the input image must be 2:1 (360:180 degrees). So if needed, we pad the source image with black.