在目标 c 中,
我需要将 UIImage 转换为与以下类型匹配的内容:
const unsigned char myImg[6300] = { 0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0x0,
0x0,0xff,0xff,0x0,0x0,0xff,0xff,0xff,0xff,0x0,0x0,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0x0,0x0,0xff,0xff, etc etc etc }
我已阅读 NSData 文档,并尝试过:
self.animalImage = [UIImage imageNamed:@"animal.png"];
self.animalData = UIImagePNGRepresentation(self.animalImage);
NSUInteger size = [self.animalData length] / sizeof(unsigned char);
unsigned char* array = (unsigned char*) [self.animalData bytes];
但结果是垃圾或零,我需要它与上述格式完全匹配。有什么想法吗?提前感谢您的任何提示!