如何在IBAction中实现NSArray方法?

发布于 2025-01-08 01:47:02 字数 668 浏览 6 评论 0原文

我一直在阅读此线程中向我建议的代码: 如何从 UIImage (Cocoa Touch) 或 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];
}

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];
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鸠魁 2025-01-15 01:47:02

您可以定义一个强/保留(取决于您是否使用 ARC)属性来存储返回的 NSArray ,然后调用该方法,如下所示:

-(IBAction)getRGB:(id)sender {
    propertyYouDefined = [self getRGBAsFromImage:image atX:42 andY:42 count:42];
}

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];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文