[問題]可以讀取的圖片中把RGB的值當變數秀出來嗎
目前採用了這個方法當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://www.ptt.cc/bbs/MacDev/M.1427219321.A.6F3.html
推
03/25 04:13, , 1F
03/25 04:13, 1F
推
03/25 08:01, , 2F
03/25 08:01, 2F
→
03/25 08:02, , 3F
03/25 08:02, 3F
→
03/25 10:29, , 4F
03/25 10:29, 4F
MacDev 近期熱門文章
PTT數位生活區 即時熱門文章