This is my code.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
img = (ImageView)findViewById(R.id.resizedView);
BitmapFactory.Options options = new BitmapFactory.Options ();
options.inScaled = false;
Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.drawable.tutimage1, options);
Bitmap bmp = getResizedBitmap(largeIcon, 200);
img.setImageBitmap(bmp);
}
public Bitmap getResizedBitmap(Bitmap image, int maxSize)
{
int width = image.getWidth();
int height = image.getHeight();
float bitmapRatio = (float)width / (float) height;
if (bitmapRatio > 1) {
width = maxSize;
height = (int) (width / bitmapRatio);
} else {
height = maxSize;
width = (int) (height * bitmapRatio);
}
// return getResizedBitmapWithQuality(image, width, height);
return Bitmap.createScaledBitmap(image, width, height, false);
}
So I tried to research and tested but the result is still the same.
Is that because of the size needed is too small?
Original size is 1120 x 2048, the size of the result is 110 x 200.