我目前在 C 数组中有一些图像数据,其中包含 RGBA 数据。
float array[length][4]
我试图把它放到一个 UIImage 中,看起来这些是用文件、NSData 和 URL 初始化的。由于其他两种方法速度较慢,因此我对 NSData 方法最感兴趣。
我可以将所有这些值放入 NSArray 中,如下所示:
for (i=0; i<image.size.width * image.size.height; i++){
replace = [UIColor colorWithRed:array[i][0] green:array[i][1] blue:array[i][2] alpha:array[i][3]];
[output replaceObjectAtIndex:i withObject:replace];
}
所以,我有一个充满 UIColor 对象的 NSArray。我尝试了很多方法,但是如何将其转换为 UIImage?
我认为这将是直截了当的。一个类似的函数imageWithData:data R:0 B:1 G:2 A:3 length:length width:width length:length
会很好,但据我所知没有函数。