将uiimage转换为int数组

时间:2014-09-22 00:03:44

标签: ios objective-c uiimage

我目前有代码接受UIImage并返回NSArray

-(NSArray*)getPixelsFromImage:(UIImage*)image
{
    NSMutableArray *pixelData=[NSMutableArray new];
    for (int y = 0; y<image.size.height; y+=1) {
        for (int x = 0; x<image.size.width; x+=1) {
            CGImageRef tmp = CGImageCreateWithImageInRect(image.CGImage, CGRectMake(x, y, 1, 1));
            UIImage *part=[UIImage imageWithCGImage:tmp];
            [pixelData addObject:part];
        }

    }
    return [pixelData copy];
}

我想知道如何将NSArray返回并将其转换为整数数组?

0 个答案:

没有答案