你会么?图形不正,角度是随机的

你会么?图形不正,角度是随机的 Delphi / Windows SDK/API
http://www.delphi2007.net/DelphiMultimedia/html/delphi_2006120616581283.html
如题,会的~~~请提供资料啊   以后有分给你~~  
  我的分数给完了

用什么控件显示图?TImage?TPaintBox?还是任意画布?  
 

大致算法就是图形乘上一个旋转变换矩阵,这是比较基础的算法.具体做法在网上搜索得到.  
 

xiexie   !!   任意画布

帖上《数字图像处理及高级应用》中的源码片断供参考:  
   
  procedure   Tform1.bmp_rotate(Srcbmp,   DestBmp:   Tbitmap;   angle:   extended);  
  var  
      c1x,   c1y,   c2x,   c2y:   integer;  
      p1x,   p1y,   p2x,   p2y:   integer;  
      radius,   n:   integer;  
      alpha:   extended;  
      c0,   c1,   c2,   c3:   tcolor;  
  begin  
      if   SrcBmp.Width   >   SrcBmp.Height   then  
      begin  
          DestBmp.width   :=   SrcBmp.Width;  
          DestBmp.height   :=   SrcBmp.Width;  
      end  
      else  
          DestBmp.Width   :=   SrcBmp.Height;  
      DestBmp.Height   :=   SrcBmp.Height;  
      //将角度转换为PI值  
      angle   :=   (angle   /   180)   *   pi;  
      //   计算中心点,你可以修改它  
      c1x   :=   SrcBmp.width   div   2;  
      c1y   :=   SrcBmp.height   div   2;  
      c2x   :=   DestBmp.width   div   2;  
      c2y   :=   DestBmp.height   div   2;  
      //   步骤数值number  
      if   c2x   <   c2y   then  
          n   :=   c2y  
      else  
          n   :=   c2x;  
      dec(n,   1);  
      //   开始旋转  
      for   p2x   :=   0   to   n   do  
      begin  
          for   p2y   :=   0   to   n   do  
          begin  
              if   p2x   =   0   then  
                  alpha   :=   pi   /   2  
              else  
                  alpha   :=   arctan2(p2y,   p2x);  
              radius   :=   round(sqrt((p2x   *   p2x)   +   (p2y   *   p2y)));  
              p1x   :=   round(radius   *   cos(angle   +   alpha));  
              p1y   :=   round(radius   *   sin(angle   +   alpha));  
   
              c0   :=   SrcBmp.canvas.pixels[c1x   +   p1x,   c1y   +   p1y];  
              c1   :=   SrcBmp.canvas.pixels[c1x   -   p1x,   c1y   -   p1y];  
              c2   :=   SrcBmp.canvas.pixels[c1x   +   p1y,   c1y   -   p1x];  
              c3   :=   SrcBmp.canvas.pixels[c1x   -   p1y,   c1y   +   p1x];  
   
              DestBmp.Canvas.pixels[c2x   +   p2x,   c2y   +   p2y]   :=   c0;  
              DestBmp.canvas.pixels[c2x   -   p2x,   c2y   -   p2y]   :=   c1;  
              DestBmp.canvas.pixels[c2x   +   p2y,   c2y   -   p2x]   :=   c2;  
              DestBmp.canvas.pixels[c2x   -   p2y,   c2y   +   p2x]   :=   c3;  
          end;  
          application.processmessages  
      end;  
  end;  
 

楼上贴的代码算法可以,  
  但由于使用了DestBmp.canvas.pixels方式逐点访问,速度应该相当慢,效果不理想.  
  改为ScanLine会明显快一些.  
 

3KS

转载于:https://www.cnblogs.com/delphi2007/archive/2008/08/31/1280466.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值