在 SWT 中打开抗锯齿功能
我已经调用了 gc.setAntialias(SWT.ON); ,但它什么也没做。按照这个方法,应该可以。
Javadoc 指出:
设置接收器的抗锯齿功能 参数的值,必须是 SWT.DEFAULT、SWT.OFF 或 SWT.ON 之一。
它对我不起作用,我正在一个简单的画布上绘画。
I've called gc.setAntialias(SWT.ON);
and it does nothing. According to that method, it should work.
The Javadoc states:
Sets the receiver's anti-aliasing
value to the parameter, which must be
one of SWT.DEFAULT, SWT.OFF or SWT.ON.
It's not working for me, and I'm painting on a simple Canvas.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
以下内容在我构建的应用程序中对我有用,以及我对何时/如何执行此操作的猜测。
所以我创建了一个新的 GC,像您一样设置 Antialias,然后用该 gc 对象绘制我需要的内容。关键是将其连接到您要绘制的外壳上。
除此之外,请确保在绘制任何内容之前执行此操作。如果您必须稍后调用它,可以尝试调用整个空间的重绘或重绘。
抱歉,没有更多信息,我不确定到底出了什么问题。
The following worked for me in an app I built and my guesses at when/how you have to do this.
So I created a new GC, set the Antialias as you did and then drew what I needed to with that gc object. The key is attaching it to the shell you will draw in.
Other than that make sure you do this before you draw anything. If you have to call it afterwards maybe try calling a repaint or redraw of the entire space.
Sorry without more information I am not sure exactly what is wrong.
按照 derBiggi 的回答,您还可以将高级选项强制设置为 true。
Following derBiggi's answer, you ca also force the advanced option to true.
另外,如果您正在绘制标签,请确保使用
gc.setTextAntialias( SWT.ON );
您还可以检查
gc.getAdvanced()
是否返回 true,它应该在设置setAntialias()
或setTextAntialias
之后。除此之外,它非常简单。
Also, if you're drawing labels, make sure you use
gc.setTextAntialias( SWT.ON );
You can also check if
gc.getAdvanced()
returns true, it should aftersetAntialias()
orsetTextAntialias
was set.Besides from that it's pretty straight forward.