Reputation: 1577
I have a TImage with Align := alClient
, Stretch := True
, Proportional := True
and Center := True
inside a TPanel. How to get the top pixel position of the picture that is drawn in the image?
Perhaps an image describing the problem will help:
I saw this question, but could not get the answer for what I need which is closely related.
Upvotes: 2
Views: 1688
Reputation: 109002
There will only be space left at the top and bottom if the aspect ratio of the image is greater than that of the panel. Assuming this is the case, the desired distance is
round(Panel.Height - (Panel.Width / Image.Picture.Width) * Image.Picture.Height) / 2);
Upvotes: 3