【发布时间】:2012-03-14 11:21:33
【问题描述】:
使用下面的代码,CGContextDrawImage() 绘制层的质量低于原始显示层。图像中的某些线条出现锯齿。
这是我的代码
- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
{
CGContextSaveGState(ctx);
UIGraphicsBeginImageContext(layer.bounds.size);
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextSetShouldAntialias(c, YES);
CGContextSetAllowsAntialiasing(c, YES);
CGContextSetInterpolationQuality(c, kCGInterpolationHigh);
[self.view.layer renderInContext:c];
CGImageRef image = CGBitmapContextCreateImage(c);
UIGraphicsEndImageContext();
CGImageRef flipImage = CGImageCreateWithImageInRect(image, layer.bounds);
CGContextTranslateCTM(ctx, 0, layer.bounds.size.height);
CGContextScaleCTM(ctx, 1.0f, -1.0f);
CGContextSetShouldAntialias(ctx, YES);
CGContextSetAllowsAntialiasing(ctx, YES);
CGContextSetInterpolationQuality(ctx, kCGInterpolationHigh);
CGContextDrawImage(ctx, layer.bounds, flipImage);
CGContextRestoreGState(ctx);
LogMessage(@"drawLayer", 1, @"draw layer content");
}
更新 1
drawLayer: 中绘制的图层与屏幕大小不同。
我想将屏幕切成小块,然后对其应用动画。
原始层:
绘制层:
【问题讨论】:
标签: ios core-graphics calayer