给你一个例子,你就明白了 来自:卷起千堆雪tyn, 时间:2001-12-24 22:10:00, ID:809383 YB老弟说我没有诚意,唉,那我就来点诚意,无私一把,给大家一点小小技巧----关于蚂蚁线>以下程序在一个表单上放置一个Timer控件,设置Interval :=100; >实现PhotoShop里的流动线效果. >以下程序字节数<512,简练,高效;原来PhotoShop也不过如此~~unit n;interfaceuses Windows,Forms,Graphics,Classes,ExtCtrls;type TF=class(TForm) m:TTimer; procedure mTimer(Sender:TObject); end;var F:TF; a:Byte;implementation{$R *.DFM}procedure c(X,Y:Integer;t:TCanvas);stdcall; begin a:=a shl 1; if a =0 then a:=1; if (a and 224)>0 then t.Pixels[X,Y]:=clWhite else t.Pixels[X,Y]:=clBlack; end;procedure TF.mTimer(Sender:TObject); begin LineDDA(0,0,333,333,@c,LongInt(Canvas)); end;end.>运行之后,有没有看见象蚂蚁在爬呢?
TLineDDAProc = procedure (X, Y: Integer; lpdata: LPARAM); stdcall;在 procedure Func(AProc: TLineDDAProc);
在vc,bcb中不也是这样码
来自:卷起千堆雪tyn, 时间:2001-12-24 22:10:00, ID:809383
YB老弟说我没有诚意,唉,那我就来点诚意,无私一把,给大家一点小小技巧----关于蚂蚁线>以下程序在一个表单上放置一个Timer控件,设置Interval :=100;
>实现PhotoShop里的流动线效果.
>以下程序字节数<512,简练,高效;原来PhotoShop也不过如此~~unit n;interfaceuses
Windows,Forms,Graphics,Classes,ExtCtrls;type
TF=class(TForm)
m:TTimer;
procedure mTimer(Sender:TObject);
end;var
F:TF;
a:Byte;implementation{$R *.DFM}procedure c(X,Y:Integer;t:TCanvas);stdcall;
begin
a:=a shl 1;
if a =0 then a:=1;
if (a and 224)>0 then
t.Pixels[X,Y]:=clWhite
else
t.Pixels[X,Y]:=clBlack;
end;procedure TF.mTimer(Sender:TObject);
begin
LineDDA(0,0,333,333,@c,LongInt(Canvas));
end;end.>运行之后,有没有看见象蚂蚁在爬呢?
另外,
1.我定义了一个指向结构体的指针(设为lp),
但是我执行 lp:=lp+2;
却好像行不通,为什么?2.我定义了一个指向array of TPoint的指针(设为lpPoint),
lpPoint:=lpPoint + 1;
也行不通,为什么?
是不是Delphi对指针的支持不好???
可用Inc(lpPoint, 1);
xzgyb(老达摩): 此方法在我自己定义的类中却出现问题,请帮助解决:
unit Glyph;interfaceuses
Windows,Forms,Graphics,Classes,ExtCtrls.............;type
TGlyph=class(Tobject)
private
procedure c(X,Y:Integer;t:integer);stdcall;
procedure DrawTTFPolgon(p1,p2:Tpoint;cTotal:Cardinal);
..........
..........
end;implementation{$R *.DFM}procedure TGlyph.DrawTTFPolgon(p1,p2:Tpoint;cTotal:Cardinal);
begin //假设p1=point(10,11),p2=point(13,14)
LineDDA(p1.x,p1.y,p2.x,p2.y,@TGlyph.c,-1);
end;procedure TGlyph.c(X,Y:Integer;t:integer);//此处传递过来的参数有误X=11,Y=-1;
begin //而实际上此时应该为X=10,Y=11
.......... //每次调用时时都是X:=Y,Y:=t; 参数好象左移了一个
............. //这是为什么???
end;
end.
这里的过程c是类的方法不能用于回调函数, 而这样@TGlyph.c,虽然通过,但有问题
你在
procedure TGlyph.c(X,Y:Integer;t:integer);//此处传递过来的参数有误X=11,Y=-1;
begin //而实际上此时应该为X=10,Y=11
.......... //每次调用时时都是X:=Y,Y:=t; 参数好象左移了一个
............. //这是为什么???
end;
里取一下Self值,正好是真正的X值,正是因为c是类中的方法,它会多传一个Self参数
我在类的 [实现] 部分中直接写下面程序段
procedure c(X,Y:Integer;t:integer);stdcall;
begin
.......
end;然后编译时会在LineDDA(p1,p2,p3,p4,@c,p6)的@c处会报错:C没有定义
那怎么办呢??如何解决??
begin
.......
end;
你如放在 LineDDA(p1,p2,p3,p4,@c,p6)当然会报错,找不到
一个是放在LineDDA前面,在就是在Interface部分声明一下在c中在类中声明回调函数好像用静态函数
而Delphi中有个类方法,但好像不行
一着急忘写了
大公无私提供代码的aningstar(乘风破浪终有时) 和 乐善好施的 xzgyb(老达摩)
多谢了!!!
大公无私提供代码的aningstar(乘风破浪终有时) 和 乐善好施的 xzgyb(老达摩)
多谢了!!!