2

突然发现,在iOS 8.3 SDK(其他版本我没有测试),可以直接使用[UIImage imageWithData:]加载PVRTC格式吗?

不应该是这样的,对吧?我找不到任何关于它的文档或讨论,我什至不知道我是否可以依赖它......

但它确实适用于模拟器和真实设备。

这是我测试的一些代码,测试项目不包含OpenGLES.framework。

NSData *data = THE_CONTENT_OF_A_PVR_FILE;
NSString *tempDir = NSTemporaryDirectory();
[data writeToFile:[tempDir stringByAppendingPathComponent:@"temp.pvr"] atomically:YES];
UIImage *tempImage = [UIImage imageWithData:data];
[UIImagePNGRepresentation(tempImage) writeToFile:[tempDir stringByAppendingPathComponent:@"temp.png"] atomically:YES];

保存的两个文件在这里共享:http: //d.pr/f/17ugQ

您可以在 HEX 编辑器中查看 pvr 文件,它符合 PVRTC 格式版本 2 的规范,像素格式为 PVRTC4。

任何想法?

4

0 回答 0