【发布时间】:2010-11-04 18:32:24
【问题描述】:
我在获取我在 CALayer 中绘制的 UIImage 时遇到一些问题,以显示它没有模糊。我将 400x300px 图像放入 123x89 CALayer。这个规模应该意味着生成的 CALayer 相对尖锐,但事实并非如此。
这是我用来绘制 UIImage 的代码:
CGSize s = image.size;
CGRect r = CGRectInset (bounds, 8, 8);
CGFloat scale = MIN (r.size.width / s.width, r.size.height / s.height);
s.width *= scale; s.height *= scale;
r.origin.x += (r.size.width - s.width) * .5;
r.size.width = s.width;
r.origin.y += (r.size.height - s.height) * .5;
r.size.height = s.height;
CGContextSaveGState (ctx);
CGContextTranslateCTM (ctx, 0, bounds.size.height);
CGContextScaleCTM (ctx, 1, -1);
if (image != nil) {
CGContextDrawImage (ctx, r, image.CGImage);
}
CGContextRestoreGState (ctx);
如果您遇到同样的问题或知道此问题的解决方案,我们将不胜感激。
谢谢,
约书亚·李·塔克。
【问题讨论】:
标签: iphone uiview uiimage calayer