【发布时间】:2013-11-26 16:29:59
【问题描述】:
我在 Firemonkey 中有一个 TImage 控件(不是 TImageControl)。该控件内的位图居中并且不占用整个 TImage。如何获取位图的坐标(左和上)?
【问题讨论】:
-
因为居中:
Left := (Image.Width - Image.Picture.Graphic.Width) / 2;
标签: delphi firemonkey timage
我在 Firemonkey 中有一个 TImage 控件(不是 TImageControl)。该控件内的位图居中并且不占用整个 TImage。如何获取位图的坐标(左和上)?
【问题讨论】:
Left := (Image.Width - Image.Picture.Graphic.Width) / 2;
标签: delphi firemonkey timage
与@GolezTrol 建议的相同,但使用整数除法并检查是否有分配给图像的图片:
if Assigned (Image.Picture.Graphic) then // is there an image assigned?
begin
ImgX := (Image.Width - Image.Picture.Graphic.Width) div 2;
ImgY := (Image.Height - Image.Picture.Graphic.Height) div 2;
end;
【讨论】: