如何知道图片被CGContextClearRect 擦除了多少

Donny_zhang 2012-07-24 03:17:56
各位,如何知道图片被CGContextClearRect 擦除了多少.我想将一张图片擦除到80%的时候就让他全部消失了.但是不知道如何计算擦除了多少像素.请高手帮忙

主要代码:
-(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下载地址:http://download.csdn.net/download/xiaohui1224/4318189



...全文
305 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
wwwang89123 2014-09-16
  • 打赏
  • 举报
回复
学习咯
Donny_zhang 2012-07-26
  • 打赏
  • 举报
回复
谢谢darkdong 帮顶
Donny_zhang 2012-07-26
  • 打赏
  • 举报
回复
好吧,我想了一天想出来一个办法说出来大家参考吧:
1.将要擦除的图片虚拟的分割成100块小矩形.
2.当涂抹的x,y经过矩形区域时就将矩形的左定点存入数组(数组内的值不重复)
3.判断等数组内元素大于80个的时候,即意味着涂抹路径已经经过了80块矩形.涂抹了大概80%的图片.

当然,如果要细化还可以将图片分割成更多的矩形.
巴依老爷 2012-07-25
  • 打赏
  • 举报
回复
不了解,只能帮顶
Donny_zhang 2012-07-25
  • 打赏
  • 举报
回复
没人做过吗?

29,048

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧