【问题标题】:Getting the coordinates of the Bitmap inside a Timage获取 Timage 中位图的坐标
【发布时间】:2013-11-26 16:29:59
【问题描述】:

我在 Firemonkey 中有一个 TImage 控件(不是 TImageControl)。该控件内的位图居中并且不占用整个 TImage。如何获取位图的坐标(左和上)?

【问题讨论】:

  • 因为居中:Left := (Image.Width - Image.Picture.Graphic.Width) / 2;

标签: delphi firemonkey timage


【解决方案1】:

与@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;

【讨论】:

  • 那你可以考虑接受这个答案。这就是说“它有效。谢谢”的方式:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-28
  • 1970-01-01
  • 2012-05-27
  • 2011-10-18
  • 1970-01-01
相关资源
最近更新 更多