闪烁问题(100分)

  • 主题发起人 fzzz_radium
  • 开始时间
F

fzzz_radium

Unregistered / Unconfirmed
GUEST, unregistred user!
我做了一个小的动画,是通过timer控制时间
然后,画擦画擦,不过,这样做,画出来的东西不停的闪烁?有什么办法解决吗?
有人提议我用线程来做,具体我不懂,但是,
如果不用线程来解决,就用timer,能不能找到一个好方法呢?
因为,我没有用线程,如果重新写的话,时间不够。
 
双缓冲!!!!!!!!!!!!!!!
一定要双缓冲!!!!!
具体可以去搜索一下例子!
 
55
我不懂,能不能说具体一点,
多谢大虾指教啊
 
用内存位图

在内存中画好了

在贴到显示的位图上
 
你是画在哪儿的?如果直接在Form上,Self.DoubleBuffered := true 试试,另外动画的实现
好象有比较好的方法,我在哪儿看到过,不太记得了。
参考一下:
unit main;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, jpeg;

type
TForm1 = class(TForm)
Image1: TImage;
Image3: TImage;
Timer1: TTimer;
Image2: TImage;
Image4: TImage;
procedure Timer1Timer(Sender: TObject);
procedure FormPaint(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
xpos : integer =0;
page : integer = 1;
implementation

{$R *.DFM}

procedure TForm1.Timer1Timer(Sender: TObject);
var i:integer;
lf : TLogFont;
tf : TFont;

begin
bitblt(image1.canvas.handle,0,0,image1.width,image1.height,
image3.canvas.handle,xpos,0,srccopy);


//---
// image1.Canvas.Brush.Color := clbtnface;
// image1.Enabled := false;
// image1.Canvas.FillRect(image1.Canvas.ClipRect);
with image1.Canvas do
begin
Font.Name := '宋体';
Font.Size :=13;
font.Color := clgray;
tf := TFont.Create;
tf.Assign(Font);
GetObject(tf.Handle, sizeof(lf), @lf);
lf.lfEscapement := xpos*100 mod 3600;
lf.lfOrientation :=xpos*100 mod 3600;
tf.Handle := CreateFontIndirect(lf);
Font.Assign(tf);
tf.Free;
brush.Style := bsClear;
font.Color := clblue;
TextOut(113 , 113, '福斯软件开发有限公司');
// font.Color := clgray;
// TextOut(112,112,'福斯软件开发有限公司');

end;
//---
bitblt(image1.canvas.handle,10,40,image4.width,
image4.height,image4.canvas.handle,0,0,srcand);
bitblt(image1.canvas.handle,10,40,image2.width,
image2.height,image2.canvas.handle,0,0,SRCPAINT );
with image1.Canvas do
begin
Font.Name := '宋体';
Font.Size := 13;
font.Color := clgray;
tf := TFont.Create;
tf.Assign(Font);
GetObject(tf.Handle, sizeof(lf), @lf);
lf.lfEscapement := (xpos+18)*100 mod 3600;
lf.lfOrientation :=(xpos+18)*100 mod 3600;
tf.Handle := CreateFontIndirect(lf);
Font.Assign(tf);
tf.Free;
brush.Style := bsClear;
font.Color := clblue;
TextOut(113 , 113, '福斯软件开发有限公司');
// font.Color := clgray;
// TextOut(112,112,'福斯软件开发有限公司');

end;

xpos := xpos + 1;
if xpos > image1.width then xpos := 0;
bitblt(canvas.handle,0,0,image1.width,image1.height,image1.canvas.handle,0,0,srccopy);
end;

procedure TForm1.FormPaint(Sender: TObject);
begin
bitblt(canvas.handle,0,0,image1.width,image1.height,image1.canvas.handle,0,0,srccopy);
end;

end.
 
如果你的image控件在form上,那么form1.doublebuffered := true
 
顶部