I want to erase the image to erase (like erasing drawing with eraser). If the footage is 0,0,320,480, but I worry that the size of the view frame is different:
Here my code:
UIGFFICENCESSEGGENTTEX (self.view.frame.size ); [MyImageView.image drawInRect: CGRectMake (0, 0, self.view.frame.size.width, self.view.frame.size.height)]; CGContextSetLineCap (UIGraphicsGetCurrentContext (), kCGImageAlphaNone); CGContextSetLineWidth (UIGraphicsGetCurrentContext (), 10); CGContextSetRGBStrokeColor (UIGraphicsGetCurrentContext (), 1, 0, 0, 10); CGContextBeginPath (UIGraphicsGetCurrentContext ()); CGContextMoveToPoint (UIGraphicsGetCurrentContext (), point.x, point.y); // To remove this line, select the part of the image image CGContextClearRect (UIGraphicsGetCurrentContext (), CGRectMake (point.x, point.y, 30, 30)); // End code CGContextStrokePath (UIGraphicsGetCurrentContext ()); MyImageView.image = UIGraphicsGetImageFromCurrentImageContext ();
Try the code below.
UIGraphicsBeginImageContext (Self.frame.size); [ImageView.image drawInRect: CGRectMake (0, 0, imageView.frame.size.width, imageView.frame.size.height)]; CGContextSetLineCap (UIGraphicsGetCurrentContext (), KCG Leneapreound); CGContextSetLineWidth (UIGraphicsGetCurrentContext (), 30.0); CGContextSetRGBStrokeColor (UIGraphicsGetCurrentContext (), 1.0, 1.0, 1.0, 1.0); CGContextBeginPath (UIGraphicsGetCurrentContext ()); CGContextMoveToPoint (UIGraphicsGetCurrentContext (), LastTouch.x, LastTouch.i); CGContextAddLineToPoint (UIGraphicsGetCurrentContext (), current Point.x, currentPoint.y); CGContextStrokePath (UIGraphicsGetCurrentContext ()); ImageView.image = UIGraphicsGetImageFromCurrentImageContext (); UIGraphicsEndImageContext ();
Comments
Post a Comment