Android Question Get Image dimensions after scaling in imageview [SOLVED]

itgirl

Active Member
Licensed User
Longtime User
Hello guys, Lets say i have Imageview1 with a fixed width and height and i put a scaled bitmap in it using bitmapplus lib now the question is how to get the the layout variables (left,top,width,height) of the actual drawn image after scaling inside the imageview with a CENTER gravity ???

not the imageview dimensions but the drawn bitmap inside, lets say i want to place a panel over the drawn image not all the imageview

i thought imageview1.bitmap.height/width would be a good start but it shows the same dimensions as the imageview maybe because it's centered im not sure.
 

itgirl

Active Member
Licensed User
Longtime User
Which type of scaling does this library do?

If you want the image to fit while preserving the original ratio then you can use this code: https://www.b4x.com/android/forum/threads/stretch-zoom-image-displayed.27463/#post-159300

You can also use it to calculate the size without making any drawing.
Thank you Erel for your reply , I think BitmapPlus uses the orginal createScaledBitmap(Bitmap src, int dstWidth, int dstHeight, boolean filter)

Ok i think your code uses some similar method to createScaledBitmap because i kept using the old createScaledBitmap to scale my images and after that i used your code to re-calculate the rect and VUALA it come out correct, Both methods return the same exact Rect.

That piece of "magic" you sent me made it able to get the exact Rect and re-use it to scale whatever view i want . THANKS ❤ Erel ❤

 
Upvote 0
Top