作者ljuyentintho (小刘)
看板MacDev
标题[问题]可以读取的图片中把RGB的值当变数秀出来吗
时间Wed Mar 25 01:48:38 2015
目前采用了这个方法当imageview读取的图片的RGB
- (UIColor *)getPixelWithImage:(UIImage *)image: atPointX:(int)x andY:(int)y {
int a=UIColor.red;
CFDataRef pixelData = CGDataProviderCopyData(CGImageGetDataProvider(
image.CGImage));
const UInt8* data = CFDataGetBytePtr(pixelData);
int pixelInfo = ((image.size.width * y) + x ) * 4;
UInt8 red = data[pixelInfo];
UInt8 green = data[(pixelInfo + 1)];
UInt8 blue = data[pixelInfo + 2];
UInt8 alpha = data[pixelInfo + 3];
CFRelease(pixelData);
return [UIColor colorWithRed:red/255.0f green:green/255.0f
blue:blue/255.0f alpha:alpha/255.0f];
}
请问有方法依照滑鼠目前的位置
秀出那个位置的RGB的值吗?
目前就只剩这边卡关了
请各位高手务必帮忙
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 220.132.55.42
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/MacDev/M.1427219321.A.6F3.html
1F:推 appleway: 滑鼠? or 手指? 03/25 04:13
3F:→ darktt: 这里面有解决UIImageView与UIImage的座标转换的问题 03/25 08:02
4F:→ ljuyentintho: a大应该是手指才对~ 03/25 10:29