Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should i resize the bitmap before adding to a ImageView or let the ImageView resize the Bitmap?

i have a simple question: Should i resize a bigger bitmap before adding to a ImageView or let the ImageView resize the Bitmap? What's the right way, regarding performance?

Thanks

like image 461
Benjamin Avatar asked Sep 01 '11 10:09

Benjamin


People also ask

How do I resize a bitmap image?

❓ How can I resize a BMP image? First, you need to add a BMP image file: drag & drop your BMP image file or click inside the white area to choose a file. Then adjust resize settings, and click the "Resize" button. After the process completes, you can download your result file.

What is ImageView in android Studio?

ImageView class is used to display any kind of image resource in the android application either it can be android. graphics. Bitmap or android. graphics. drawable.

How do you show the full size image in pop up when clicking the picture on android?

How to show the full size image in popup on clicking the image in android. Below is the code that will show the full size image in a dialog box popup without defining layout xml file . int a=v. getId(); intiger "a" will have the value equal to profile_pic if we touched on profile_pic imageview else we will get pro id .


2 Answers

Consider using scale for ImageView, and don't bother about resizing. You can scale an image like this, for example:

image.setAdjustViewBounds(true);
image.setMaxHeight(50);
image.setMaxWidth(50);
image.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
like image 115
Aurelian Cotuna Avatar answered Oct 27 '22 22:10

Aurelian Cotuna


The bigger the image, the bigger the size, I wouldn't think performance would really be affected but keep things efficient.

You could also place different size images in the different folders for different resolutions:

res/drawable-mdpi/my_icon.png        // bitmap for medium density
res/drawable-hdpi/my_icon.png        // bitmap for high density
res/drawable-xhdpi/my_icon.png       // bitmap for extra high density

Supporting different size screens

like image 43
Ricky Avatar answered Oct 27 '22 22:10

Ricky