画斜线 出现锯齿怎么解决?

shaoguoqiang2002 2006-07-14 08:17:33
用下面的代码画椭圆 和 斜线 都出现锯齿,请高手指教

PaintBox1.Canvas.Ellipse(100,100,200,200);
PaintBox1.Canvas.MoveTo(150,150);
PaintBox1.Canvas.LineTo(200,180);
...全文
1094 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhitaoyang 2006-09-06
  • 打赏
  • 举报
回复
贴张图片上去算了
xzhifei 2006-09-04
  • 打赏
  • 举报
回复
KAO,没看楼主的信誉就回答了,NND

------------------------------------------------------- 本回复由大傻的破玩意儿【CSDN's forum Explorer】完成! 大傻的破玩意儿,今天你用了木有 !! 软件功能强大,速度超快!!支持中... 软件下载地址:http://CoolSlob.ys168.com
xzhifei 2006-09-04
  • 打赏
  • 举报
回复
反走样线的画线函数

procedure AALine(x1,y1,x2,y2 : single; color : tcolor; canvas : tcanvas);
function CrossFadeColor(FromColor,ToColor : TColor; Rate : Single) : TColor;
var r,g,b : byte;
begin
r:=Round(GetRValue(FromColor)*Rate+GetRValue(ToColor)*(1-Rate));
g:=Round(GetGValue(FromColor)*Rate+GetGValue(ToColor)*(1-Rate));
b:=Round(GetBValue(FromColor)*Rate+GetBValue(ToColor)*(1-Rate));
Result:=RGB(r,g,b);
end;
procedure hpixel(x : single; y : integer);
var FadeRate : single;
begin
FadeRate:=x-trunc(x);
with canvas do
begin
pixels[trunc(x),y]:=CrossFadeColor(Color,Pixels[Trunc(x),y],1-FadeRate);
pixels[trunc(x)+1,y]:=CrossFadeColor(Color,Pixels[Trunc(x)+1,y],FadeRate);
end;
end;

procedure vpixel(x : integer; y : single);
var FadeRate : single;
begin
FadeRate:=y-trunc(y);
with canvas do
begin
pixels[x,trunc(y)]:=CrossFadeColor(Color,Pixels[x,Trunc(y)],1-FadeRate);
pixels[x,trunc(y)+1]:=CrossFadeColor(Color,Pixels[x,Trunc(y)+1],FadeRate);
end;
end;

var i : integer;
ly,lx,currentx,currenty,deltax,deltay,l,skipl : single;
begin
if (x1<>x2) or (y1<>y2) then
begin
currentx:=x1;
currenty:=y1;
lx:=abs(x2-x1);
ly:=abs(y2-y1);

if lx>ly then
begin
l:=trunc(lx);
deltay:=(y2-y1)/l;
if x1>x2 then
begin
deltax:=-1;
skipl:=(currentx-trunc(currentx));
end else
begin
deltax:=1;
skipl:=1-(currentx-trunc(currentx));
end;
end else
begin
l:=trunc(ly);
deltax:=(x2-x1)/l;
if y1>y2 then
begin
deltay:=-1;
skipl:=(currenty-trunc(currenty));
end else
begin
deltay:=1;
skipl:=1-(currenty-trunc(currenty));
end;
end;

currentx:=currentx+deltax*skipl;
currenty:=currenty+deltay*skipl;{}

for i:=1 to trunc(l) do
begin
if lx>ly then vpixel(trunc(currentx),currenty) else hpixel(currentx,trunc(currenty));
currentx:=currentx+deltax;
currenty:=currenty+deltay;
end;
end;
end;



------------------------------------------------------- 本回复由大傻的破玩意儿【CSDN's forum Explorer】完成! 大傻的破玩意儿,今天你用了木有 !! 软件功能强大,速度超快!!支持中... 软件下载地址:http://CoolSlob.ys168.com
noelse520 2006-09-04
  • 打赏
  • 举报
回复
会OPENGL不? 那里面有抗锯齿的函数
e_feeling 2006-09-03
  • 打赏
  • 举报
回复
使用算法,反走样处理
GARNETT2183 2006-09-03
  • 打赏
  • 举报
回复
换显示器肯定不实现啦...使用算法就可以了...
在GDI+中,就已经不算自己再用算法了...只需要设置一种反锯齿模式,画出来的东西,就没有锯齿.
可以到盒子下载GDI+ FOR DELPHI 的库
http://www.2ccc.com/article.asp?articleid=3131
OO_is_just_P 2006-08-21
  • 打赏
  • 举报
回复
不知道有没有模拟显示器?

反正数字显示器都是点组成的,没锯齿是不可能的。
daviddelphilee 2006-08-21
  • 打赏
  • 举报
回复
setpixel自己画点,选个好点的算法。参考计算机图形学的前几章
很土 2006-07-14
  • 打赏
  • 举报
回复
因为显示器的分辨率不够高, 如果能够达到 12800 x 10240 像素时, 基本上可以看不到剧齿了

5,928

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧