获取矩形旋转后的新矩形

原理:  三角函数 平面转换

用例:  预估旋转后的位置,   可事先设定好矩形大小

代码:

var
  angle: Single;
   Sn, Cn: Single;
   Sx, Sy, Scale: Single;
begin

    angle:= angle* PI / 180; //180 - 负180度

    // get the width and height of rotated image (without scaling)
    SinCos(angle, Sn, Cn);
    Sx := Abs(SrcR * Cn) + Abs(SrcB * Sn);
    Sy := Abs(SrcR * Sn) + Abs(SrcB * Cn);
    Panel1.Width := Trunc(sx);    Panel1.Height :=Trunc(sy);

    //居中
    Panel1.Left := Dst.Left + (Dst.Width - Panel1.Width) div 2;    Panel1.Top := Dst.Top + (Dst.Height - Panel1.Height) div 2;
    // calculate a new scale so that the image fits in original boundaries
    Sx := Src.Bitmap.Width / Sx;
    Sy := Src.Bitmap.Height / Sy;
    Scale := Min(Sx, Sy);

    //缩放显示,保证display不超过src范围 T.Scale(Scale);

end;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值