[問題]可以讀取的圖片中把RGB的值當變數秀出來嗎

作者: ljuyentintho (小劉)   2015-03-25 01:48:38
目前採用了這個方法當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的值嗎?
目前就只剩這邊卡關了
請各位高手務必幫忙
作者: appleway (蘋果愛天空)   2015-03-25 04:13:00
滑鼠? or 手指?
作者: darktt (小朱)   2015-03-25 08:01:00
你可以看我的這個程式:http://ppt.cc/uqZH這裡面有解決UIImageView與UIImage的座標轉換的問題
作者: ljuyentintho (小劉)   2015-03-25 10:29:00
a大應該是手指才對~

Links booklink

Contact Us: admin [ a t ] ucptt.com