一、下载地址
下载: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 bytesPerPixel = 4;
int bytesPerRow = bytesPer

本文介绍了如何使用Objective-C(OC)从图片中提取颜色,提供了下载链接和展示效果,并给出了关键代码片段。
最低0.47元/天 解锁文章
2415

被折叠的 条评论
为什么被折叠?



