image画图

image画图 Delphi / Windows SDK/API
http://www.delphi2007.net/DelphiMultimedia/html/delphi_20061010164801258.html
刚学delphi,想做一个雷达盘。用了两个image,一个做背景图,一个画扫描线,用timer触发事件更新  
  运行的时候图像闪的很厉害,doublebuffered也设为true了。请达人帮忙改一下是图像流畅一点,别闪了  
  procedure   TForm1.OnDraw;  
  var  
      brect   :   TRect;  
      bitmap   :   TBitmap;  
      centerx,centery:   Integer;  
      radium,pi   :   Double;  
      angleh:integer;  
      Toplacex,Toplacey:integer;  
  //     x,y   :   Double;  
  begin  
      brect:=rect(0,0,Image1.Width,Image1.Height);  
      radium:=252.0;  
      pi:=3.14159265;  
      centerx:=round(Image1.Width/2);  
      centery:=round(Image1.Height/2);  
      ScanAngle:=ScanAngle   mod   (360   div   ScanSpeed)+1;  
      bitmap:=TBitmap.Create;  
      with   bitmap   do  
      begin  
          Height   :=Image1.Height;  
          Width   :=   Image1.Width;  
          for   angleh:=ScanSpeed*ScanAngle   downto   ScanSpeed*ScanAngle-ScanWide   do  
          begin//画扫秒指针  
              Toplacex:=trunc(centerx+radium*sin(angleh/180*pi));  
              Toplacey:=trunc(centery-radium*cos(angleh/180*pi));  
              Canvas.Pen.Color:=rgb(colorvalue,colorvalue,colorvalue);  
              Canvas.Pen.Width:=4;   //connectted   with   R  
              Canvas.MoveTo(centerx,centery);  
              Canvas.LineTo(Toplacex,Toplacey);  
              dec(colorvalue,200   div   Scanwide);  
          end;  
      end;  
      Image2.Canvas.CopyRect(brect,bitmap.Canvas,brect);  
      bitmap.Free;  
   
  end;

不要使用使用Image2.Canvas.CopyRec……;  
   
  1、用Image1作为底图,上面覆盖一个同样大小的PaintBox1  
  2、然后直接在PaintBox1.OnPaint事件中直接画扫描指针  
  3、然后在你的定时器触发事件中调用PaintBox1.Invalidate

使用paintbox试了一下,不像原来闪的那么厉害,但还是会闪,是怎么回事啊

解决了,谢谢哈

转载于:https://www.cnblogs.com/delphi2007/archive/2009/03/13/1410280.html

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值