Saturday, November 30, 2013

How do you know how many pictures are erased CGContextClearRect

Ladies and gentlemen, how do you know how many pictures are CGContextClearRect erased and I would like to erase an image to 80% of the time let him all but disappeared, but do not know how to calculate how many pixels are erased. Please help

The main code:
- (Void) touchesMoved: (NSSet *) touches withEvent: (UIEvent *) event
{
UITouch * touch = [touches anyObject];
if (canEarse)
{

CGPoint currentPoint = [touch locationInView: reaseImage];
UIGraphicsBeginImageContext (self.reaseImage.frame.size);
[ReaseImage.image drawInRect: reaseImage.bounds];
CGContextClearRect (UIGraphicsGetCurrentContext (), CGRectMake (currentPoint.x, currentPoint.y, 50, 50));
reaseImage.image = UIGraphicsGetImageFromCurrentImageContext ();
UIGraphicsEndImageContext ();
}
}



demo Download: http://download.csdn.net/download/xiaohui1224/4318189




Reply:
Nobody has done it?
Reply:
Do not know, only Bangding
Reply:
Well, I think one day would like to say we came up with a way to refer to it:
One would want to erase the picture is divided into 100 virtual small rectangle.
(2) When the painting x, y passes through the rectangular area will be left point of the rectangle into an array (an array of values ​​within the non-repetition)
When the elements of the array 3. Judgment is greater than 80, that means that the path has been painted rectangle 80. Applied for about 80% of the picture.

Of course, if you want to refine the image can also be divided into more rectangular.
Reply:
Thank darkdong Bangding

No comments:

Post a Comment