Use this code for resizing the image
// Draw Bitmap on Canvas
public void setBitmap(String imageUrl){
Bitmap myBitmap = BitmapFactory.decodeFile(imageUrl);
Bitmap scaleBitmap = null;
int bWidth = myBitmap.getWidth();
int bHeight = myBitmap.getHeight();
int diff = 0;
Log.d(TAG, "bitmapWidth = " + bitmapWidth + " bitmapHeight = " + bitmapHeight);
Log.d(TAG, "bWidth = " + bWidth + " bHeight = " + bHeight);
if(bWidth >= bHeight){
if(bWidth > bitmapWidth ){
// landscape
float ratio = (float) bWidth / bitmapWidth;
diff = bWidth - bitmapWidth;
bHeight = (int)(bHeight / ratio);
scaleBitmap = Bitmap.createScaledBitmap(myBitmap, bWidth - diff, bHeight, false);
}
else{
scaleBitmap = myBitmap;
}
}
else{
if(bHeight > bitmapHeight){
float ratio = (float) bHeight / bitmapHeight;
diff = bHeight - bitmapHeight;
bWidth = (int)(bWidth / ratio);
scaleBitmap = Bitmap.createScaledBitmap(myBitmap, bWidth, bHeight - diff, false);
}
else{
scaleBitmap = myBitmap;
}
}
canvasBitmap = scaleBitmap;
invalidate();
}
Do raise the arrow so that other can also get the link for resizing the image.