【发布时间】:2011-08-08 23:21:34
【问题描述】:
我有一个 UIImage,我在它上面画出跟随用户手指的线条。这就像一个绘图板。这在 UIImage 很小(比如 500 x 600)时非常有效,但如果它像 1600 x 1200 一样,它会变得非常粗糙和滞后。有没有办法可以优化这个?这是我在 touchesModed 中的绘图代码:
UIGraphicsBeginImageContext(self.frame.size);
[drawImageView.image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 15.0);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1.0, 0.0, 0.0, 1.0);
//CGContextSetAlpha(UIGraphicsGetCurrentContext(), 0.5f);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
drawImageView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
谢谢。
【问题讨论】:
标签: objective-c ios cocoa-touch core-graphics