在 SWT 中打开抗锯齿功能

发布于 2024-08-10 12:22:12 字数 207 浏览 5 评论 0原文

我已经调用了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

南笙 2024-08-17 12:22:12

以下内容在我构建的应用程序中对我有用,以及我对何时/如何执行此操作的猜测。

所以我创建了一个新的 GC,像您一样设置 Antialias,然后用该 gc 对象绘制我需要的内容。关键是将其连接到您要绘制的外壳上。

GC gc = new GC(shell);
gc.setAntialias(SWT.ON); 
//then I attach to LightweightSystem for testing.
LightweightSystem lws = new LightweightSystem(shell);

除此之外,请确保在绘制任何内容之前执行此操作。如果您必须稍后调用它,可以尝试调用整个空间的重绘或重绘。

抱歉,没有更多信息,我不确定到底出了什么问题。

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.

GC gc = new GC(shell);
gc.setAntialias(SWT.ON); 
//then I attach to LightweightSystem for testing.
LightweightSystem lws = new LightweightSystem(shell);

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.

谈情不如逗狗 2024-08-17 12:22:12

按照 derBiggi 的回答,您还可以将高级选项强制设置为 true。

gc.setAdvanced(true)

Following derBiggi's answer, you ca also force the advanced option to true.

gc.setAdvanced(true)
寂寞花火° 2024-08-17 12:22:12

另外,如果您正在绘制标签,请确保使用 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 after setAntialias() or setTextAntialias was set.

Besides from that it's pretty straight forward.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文