Why [UIImage imageWithData:] supports PVRTC format?

282 Views Asked by At

I suddenly find out that in iOS 8.3 SDK (I didn't test other versions), I can use [UIImage imageWithData:] to load PVRTC format directly?

It isn't supposed to be like that, right? I can't find any documentation or discussion about it, I don't even know if I can rely on it...

But it does work in both simulators and real devices.

Here are some codes of my test, the test project doesn't include 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];

The two saved files are shared here: http://d.pr/f/17ugQ

You can check the pvr file in a HEX editor, it coresponds to the specifications of PVRTC format version 2, with pixel format in PVRTC4.

Any idea?

0

There are 0 best solutions below