I have been reading the code that was suggested to me in this thread here: How to get pixel data from a UIImage (Cocoa Touch) or CGImage (Core Graphics)?
I am wondering how I would implement the code in the following manner:
-(IBAction)getRGB:(id)sender {
// Call getRGBAsFromImage here when pressed.
}
+ (NSArray*)getRGBAsFromImage:(UIImage*)image atX:(int)xx andY:(int)yy count:(int)count {
...
}
Thank you very much.
Edit for 0x90:
-(IBAction)getRGB:(id)sender {
UIImage *image = [UIImage imageNamed:@"IMG_0121.JPG"];
[self getRGBAsFromImage:image atX:40 andY:40 count:40];
}
You would define a strong/retained (depends on whether you use ARC) property to store the returned NSArray
and then call the method as such:
-(IBAction)getRGB:(id)sender {
propertyYouDefined = [self getRGBAsFromImage:image atX:42 andY:42 count:42];
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.