一、下载地址
下载:https://github.com/puyangdev/PYColorPicker
二、 效果
三、关键代码
//获取图片某一点的颜色
- (UIColor *)colorAtPixel:(CGPoint)point {
if (!CGRectContainsPoint(CGRectMake(0.0f, 0.0f, self.image.size.width, self.image.size.height), point)) {
return nil;
}
NSInteger pointX = trunc(point.x);
NSInteger pointY = trunc(point.y);
CGImageRef cgImage = self.image.CGImage;
NSUInteger width = self.image.size.width;
NSUInteger height = self.image.size.height;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
int bytesP