To avoid out of memory exceptions it is recommended to use sampling. (see Strange out of memory issue while loading an image to a Bitmap object)
But these algorithms do not scale if the new image is less than required image width and height. How to increase the size of the image to fit the layout.
Is it ok to use following code?
if(inputBitmap.getHeight() < imageheight || inputBitmap.getWidth() < imageWidth) {
Bitmap scaledBitmap = Bitmap.createScaledBitmap(inputBitmap,
(imageWidth), (imageheight), true);
inputBitmap.recycle();
inputBitmap = scaledBitmap;
}