我有一个用户可以删除图像的应用程序。
因此,如果用户触摸图像的某些px,则这些像素的α值应该变低。
例如,如果我触摸(0,0)图像的一次像素,(0,0)px不透明度应该变为0.9。如果我触摸px 10次,我不应该在点(0,0)处看到图像。
实施该方法的最佳方法是什么?
答案 0 :(得分:0)
这是您可以检测触摸值的系数
CGPoint StartPoint = [touch previousLocationInView:self];
CGPoint Endpoint = [touch locationInView:self];
NSString *str = [NSString stringWithFormat:@"%f",StartPoint.x];
NSString *strlx = [NSString stringWithFormat:@"%f",StartPoint.y];
NSString *strcx = [NSString stringWithFormat:@"%f",Endpoint.x];
NSString *strcy = [NSString stringWithFormat:@"%f",Endpoint.y];
这里触摸是UITouch的对象。
我不能透露任何关于不透明度的事情。
答案 1 :(得分:0)
如果您想要快速(如实时快速),您将需要使用OpenGL。 最好的方法是创建一个alpha值掩码,使用自定义构建的着色器将其应用于原始图像。
更简单的方法,但更慢的是从UIImage获取原始像素 并在原始像素数组上应用alpha值,然后将其转回UIImage(here is a nice example)