Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the current view size for an image in Delphi 2009

I wish to get the current size for an image being displayed with TImage, this object has the Proportional property set to True and is aligned to Client with main form. So, when resizing the form I wanna get the current size for that image, not canvas size neither real size for that image. Getting the current size I can show what's the percentage for current image size respect to real image size. Thanks in advance


1 Answers

I don't think there's a built-in way to do this. You may just have to calculate it. Something like this:

  1. Get the height and width of the canvas.
  2. Get the height and width of the image's Picture property.
  3. Calculate the ratios of the Picture's dimensions to the canvas's dimensions.
  4. Whichever of the two ratios is smaller is your percentage.
like image 102
Mason Wheeler Avatar answered Feb 04 '26 02:02

Mason Wheeler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!