我正在做一些图像处理项目,我需要在图像上实现橡皮擦。我还必须实现捏合效果以将图像缩放得更小或更大。捏工作得很好。如果我不通过捏缩放图像,橡皮擦也可以完美工作。但是当我使用捏然后使用橡皮擦时。图像变得模糊。我已经在UIPanGestureRecognizer
.
下面是橡皮擦的代码。
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;
}
请提供任何帮助。提前致谢。