• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

delphi有办法旋转或翻转图片么?

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
delphi有办法旋转或翻转图片么? Delphi / Windows SDK/API
http://www.delphi2007.net/DelphiMultimedia/html/delphi_20060929153916275.html
rt  
  要求效率比较高  
  谢谢

沙发  
  随便google下不都可以找一堆吗

procedure   TForm1.RotateangleClick(Sender:   TObject);  
  var  
      newbmp:   TBitmap;  
      Bitmap:   TBitmap;  
      angle:   integer;  
  begin  
      newbmp   :=   TBitmap.Create;  
      Bitmap   :=   TBitmap.Create;  
      screen.Cursor   :=   crhourglass;  
      newbmp.Assign(image1.Picture.Bitmap);  
      //newbmp.pixelFormat:=pf8bit;  
      //Bitmap.pixelFormat:=pf8bit;  
      angle   :=   strtoint(inputbox('旋转位图',   '请输入旋转角度',   '90'));  
      Bmp_Rotate(newbmp,   bitmap,   angle);  
      image1.picture.Bitmap.Assign(bitmap);  
      image1.Left   :=   (self.Width   div   2)   -   (bitmap.Width   div   2);  
      image1.Top   :=   (self.Height   div   2)   -   (bitmap.Height   div   2);  
      screen.Cursor   :=   crdefault;  
      newbmp.Free;  
      Bitmap.Free;  
  end;

 
  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;

用IMAGEEN控件可以做很多效果,并且速度很快

http://www.efg2.com/Lab/ImageProcessing/RotateScanline.htm  
  这个是用扫描线来做得   速度很快   自己看懂改下   就能用了

以上答案都正确

这么多分,我接!可以下一本<<delphi数字图象处理>>来看看!

发现个好组件:TRotateImage


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
delphi下实现ribbon界面的方法(一)发布时间:2022-07-18
下一篇:
Delphi的编译指令(3):常用的预定义条件标识符发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap