Android Question resize bitmaps

Eduard

Active Member
Licensed User
Longtime User
Hi,

I've a couple of issues regarding to resize bitmaps.

1) LoadBitmapSample does not deliver an bitmap with a width or height set to the maximum, but delivers just the original image. I didn't test it on really large images, but on small images it has no effect. LoadBitmapSample(<dir>,"256pixelSample.png",80dip,80dip) just returns a bitmap of 256 pixels instead.

2) I tried to resize it myself with BitmapExtended, but this doesn't work well too. I have a imageView of 80dip (=160pixels). If I scale the bitmaps to 80dip, the width and height is 160. But if I load this image into imageview1 it is displayed too big! If I resize the bitmaps to 40dip it does fit the imageview, but image quality is poor.

3) If I set imageview.gravity to gravity_fill, the image is of good quality and of good size. However, the aspect ratio is wrong!

Anyone got a solution for this?
 

Eduard

Active Member
Licensed User
Longtime User
Setting the density of the bitmaps to 0 seems to solve problem number 2.... But I don't understand why this is necessary.
B4X:
bitmapExtended1.setDensity(bitmap1,0)
 
Upvote 0
Top