I IamBot Member Licensed User Longtime User Aug 7, 2012 #1 Is it possible to fill an ImageView with a picture without making the image itself disproportionate when displayed? Lets say my picture is 640x480 in size and my ImageView is only 100x100. Is it possible to make it scale correctly when displayed? In this case it should fill in width but stop at 75 in height. Using gravity.fill would fully stretch the image in height as well and cause picture to be disproportionate. Thank you in advance.
Is it possible to fill an ImageView with a picture without making the image itself disproportionate when displayed? Lets say my picture is 640x480 in size and my ImageView is only 100x100. Is it possible to make it scale correctly when displayed? In this case it should fill in width but stop at 75 in height. Using gravity.fill would fully stretch the image in height as well and cause picture to be disproportionate. Thank you in advance.
klaus Expert Licensed User Longtime User Aug 7, 2012 #2 You could load the bitmap and with the ratio of Bitmap.Width and Bitmap.Height change the ImagView.Height. Best regards. Upvote 0
You could load the bitmap and with the ratio of Bitmap.Width and Bitmap.Height change the ImagView.Height. Best regards.
R Roger Garstang Well-Known Member Licensed User Longtime User Aug 7, 2012 #3 I ran into this a few times and you have to get the ratio as suggested. This works fine if you load it outside B4A and hardcode the ratio too. My issue is usually the reason for needing this to begin with is the bitmap is too large for memory and often loaded by a user. Best solution would be to read the header and get the width/height. I think there may be a library here for that. Upvote 0
I ran into this a few times and you have to get the ratio as suggested. This works fine if you load it outside B4A and hardcode the ratio too. My issue is usually the reason for needing this to begin with is the bitmap is too large for memory and often loaded by a user. Best solution would be to read the header and get the width/height. I think there may be a library here for that.
klaus Expert Licensed User Longtime User Aug 7, 2012 #4 Have a look at the VBBitmap library to get the width/height ratio. I haven't tested it. Best regards. Upvote 0
Have a look at the VBBitmap library to get the width/height ratio. I haven't tested it. Best regards.
I IamBot Member Licensed User Longtime User Aug 7, 2012 #5 Thank you for your suggestions, I will take a look at it. Upvote 0