如何在iPhoneOS中消除别名图层 [英] How to Anti-Alias Layers in iPhoneOS

查看:131
本文介绍了如何在iPhoneOS中消除别名图层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经将 Reiner Knizia的钱推出了几个月了。这是
做得很好,所以我们一直在更新它,因为时间允许。
然而,有一件事继续让我烦恼。我从来没有能够正确地将我的
分层卡片用于消除别名。

We've had Reiner Knizia's Money out for a couple of months now. It's done pretty well, and so we've been updating it as time allows. However, one thing continues to bug me. I've never been able to get my layered cards to anti-alias correctly.

这是一个示例:

直线放置的卡非常干净,但只要它们是b
角度,卡周围的黑线就会变成锯齿状。我试过这个
取决于艺术品隐含的两条线和通过drawRect:绘制的
线,它们都做同样的事情。我已经尝试了
edgeAntiAliasingMask,据我所知,它没有做任何事情。
我已经为子图层设置为NO和YES尝试了maskToBounds。

Cards that are laid straight are very clean, but whenever they're angled the black lines around the cards get jagged. I've tried this depending on both lines implicit to the artwork and lines drawn through drawRect:, and they both do the same thing. I've tried the edgeAntiAliasingMask and it doesn't do a thing as far as I can tell. I've tried masksToBounds for the sublayers set to NO and YES.

现在我的卡被设置为CALayer,其中包含子CALayer
正面和背面,加上一些其他的东西,比如闪电面具
和一个变暗的面具。以下是代码的一些片段:

Right now my card is set up as a CALayer that has sub-CALayers for the front and the back, plus for a few other things like a lightening mask and a darkening mask. Here's some snippets of the code:

   CArdLayer *theCardLayer = [CArdLayer layer];
   theCardLayer.edgeAntialiasingMask = kCALayerLeftEdge | kCALayerRightEdge | kCALayerBottomEdge | kCALayerTopEdge;

   theCardLayer.front = [CALayer layer];
   theCardLayer.front.edgeAntialiasingMask = kCALayerLeftEdge | kCALayerRightEdge | kCALayerBottomEdge | kCALayerTopEdge;
   theCardLayer.front.bounds = theCardLayer.bounds;
   theCardLayer.front.masksToBounds = YES;
   theCardLayer.front.contents = (id)[cardDrawing CGImage];

   [theCardLayer addSublayer:theCardLayer.front];

等...

任何想法关于如何使卡实际上是反别名?

Any ideas on how to make the cards actually anti-alias?

推荐答案

我能想出的最好结果就是做我做的事情在我的评论中建议:我每个(透明)图形每边增加1个像素。凭借这一点点的优势,这些卡片在背景下的合成效果更好。

The best result that I could come up with was by doing what I suggested in my comment: I grew each (transparent) graphic by 1 pixel on each side. With that little bit of margin, the cards composited much better with the background.

因此,不完全是iPhone代码的答案,但仍可在iPhone上运行。

So, not exactly an iPhone code answer, but one that nonetheless works on the iPhone.

这是一个后镜头,你可以比较之前,上面:

Here's an "after" shot that you can compare to the "before", above:

这篇关于如何在iPhoneOS中消除别名图层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆