1
我想更改用户在图像上触摸的颜色。我得到了一些代码来获取图像数据低于根据触摸点更改像素的颜色
NSString * path = [[NSBundle mainBundle] pathForResource:@"filename" ofType:@"jpg"];
UIImage * img = [[UIImage alloc]initWithContentsOfFile:path];
CGImageRef image = [img CGImage];
CFDataRef data = CGDataProviderCopyData(CGImageGetDataProvider(image));
const unsigned char * buffer = CFDataGetBytePtr(data);
我知道我可以很容易地触摸点,但我的问题是下面
- 正如我们所知道的视网膜显示1点= 2像素所以,我知道是否需要为单点触摸点更改2像素的颜色?请纠正我,如果我哪里错了?
- 如何从图像数据中获取这两个像素?
根据您的建议,我已经做了一些更改以获得重点。但是我们正在获取像素的图像数据。因此,为了获得某个点的正确像素颜色,我们必须这样做:pixel = CGPointMake(imageLocation.x * image.scale,imageLocation.y * image.scale)。 – Iducool 2013-03-08 16:28:05
如果我的评论看起来合适,请按照此编辑您的答案,以便我接受。 – Iducool 2013-03-08 16:28:50
很高兴编辑,但不知道我明白 - 你的UIImage有一个叫'scale'的属性? – danh 2013-03-08 16:40:06