I'm loading a 5000x5000
png image onto a TImage with a wrapmode being set to Fit
. I want to then get the height and width of the bitmap thats being shown in the UI however I seem to only get the original size of the bitmap and not the size of the image thats being shown.
I'm loading the bitmap as follows: imgMap.Bitmap.LoadFromFile('map_4000_35161.png');
When resizing the TImage the size of the bitmap being displayed changes so that it can fit inside of the TImage;
How can I get the width and height of the bitmap thats being shown?
I've tried imgMap.Bitmap.Width
, imgMap.Bitmap.Canvas.Width
but I only end up getting the original size of 5000
The Bitmap is your source bitmap, it's not being resized, but rather when it's rendered on the TImage
it's rendered to fit the TImage
. AFAIK, there is no way to get the results of that rendering unless you resize it yourself.
You can get the size of the TImage
, though. Is that not enough? If you are preserving the aspect ratio then it's fairly simple to calculate the size of a rectangle with known aspect ratio and containing boundary.