作者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://www.ptt.cc/bbs/MacDev/M.1427219321.A.6F3.html
推 appleway: 滑鼠? or 手指? 03/25 04:13
→ darktt: 這裡面有解決UIImageView與UIImage的座標轉換的問題 03/25 08:02
→ ljuyentintho: a大應該是手指才對~ 03/25 10:29