I have an image path that I decode into a bitmap. I found that that Bitmap is to big and tried to resize it. It didn´t work (the image stayed too big), is my code ok?
ImageButton myImage = (ImageButton) findViewById(R.id.image);
Bitmap myBitmap = BitmapFactory.decodeFile(selectedImagePath);
Bitmap.createScaledBitmap(myBitmap, NEW_WIDTH, NEW_HEIGHT, true);
myImage.setImageBitmap(myBitmap);
It’s designed to not change the original bitmap. You’re not capturing the reference so it’s just being thrown away.
Keep in mind that creating a bitmap in this format takes up more memory because you’re creating a new bitmap while still holding on to the old one. If you’re doing this very often and not throwing away the old reference, then your heap will grow massive real quick.