我一直在阅读此主题中向我建议的代码:How to get pixel data from a UIImage (Cocoa Touch) or CGImage (Core Graphics)?
我想知道如何以下列方式实现代码:
-(IBAction)getRGB:(id)sender {
// Call getRGBAsFromImage here when pressed.
}
+ (NSArray*)getRGBAsFromImage:(UIImage*)image atX:(int)xx andY:(int)yy count:(int)count {
...
}
非常感谢。
编辑0x90:
-(IBAction)getRGB:(id)sender {
UIImage *image = [UIImage imageNamed:@"IMG_0121.JPG"];
[self getRGBAsFromImage:image atX:40 andY:40 count:40];
}
答案 0 :(得分:1)
您可以定义一个强/保留(取决于您是否使用ARC)属性来存储返回的NSArray
,然后调用该方法:
-(IBAction)getRGB:(id)sender {
propertyYouDefined = [self getRGBAsFromImage:image atX:42 andY:42 count:42];
}