我正在研究一些图像处理项目,我需要在图像上实现橡皮擦。我还必须实现捏合效果以缩小或缩小图像。 Pinch工作很好。橡皮擦也完美如果我不通过捏缩放图像。但是当我使用捏,然后使用橡皮擦。图像变得模糊。我在UIPanGestureRecognizer
上实施了橡皮擦。如何在objective-c iPhone中缩放图像前后使用橡皮擦?
下面是橡皮的代码。
CGPoint translatedPoint = [(UIPanGestureRecognizer*)sender locationInView:tattooImage];
if([(UIPanGestureRecognizer*)sender state] == UIGestureRecognizerStateBegan)
{
lastPoint = translatedPoint;
//lastPoint.x += 60;
//lastPoint.y += 60;
}
else
{
CGPoint currentPoint = translatedPoint;
//currentPoint.x += 60;
//currentPoint.y += 60;
UIGraphicsBeginImageContext(tattooImage.frame.size);
[tattooImage.image drawInRect:CGRectMake(0, 0,tattooImage.frame.size.width, tattooImage.frame.size.height)];
CGContextSetBlendMode(UIGraphicsGetCurrentContext(),kCGBlendModeClear);
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 25.0);
CGContextSetStrokeColorWithColor(UIGraphicsGetCurrentContext(), [[UIColor clearColor] CGColor]);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext()) ;
tattooImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
lastPoint = currentPoint;
}
请提供任何帮助。提前致谢。
的问题是不是与移动或用橡皮擦。问题是同时使用缩放和橡皮擦。你能提供关于这个的解决方案吗? – 2012-08-01 08:18:02