Image handling on iPhone

At first it looks good… but (like most things) when you get into the details, you realize there are some klunky bits. So, I was just looking how to open a png file and it’s dead easy and you can do all sorts of sophisticated transformations, but if – for any reason, you need a simple pointer to the pixel data – you’re boned. It requires you to go around in hoops. And to load a texture you need the pixel data. So, how does Apple do it in their examples? Have a look:

yep, they’re pretty much forced to go around in hoops themselves. This must be some pretty inefficient code, though because you have to copy the data twice, once from the file, then from the UIImage to some sort of wierd memory bitmap and then uploading with glTexImage2D.

I already have a tga class, so I’ll just store my images as tga for the time being. It looks like it’ll work a lot better than using the cocoa classes.

Anyways, In the final game I should use powervr compressed images. I have to look into that more, but I assume the data is just dumped into glTexImage2D as it’s read from the file. Powervr compressed images are a dark art. They can only be created via a windows tool and can’t be displayed in the emulator. Quite, ironic that Apple says in their guidlines  “use PVRTC”, and yet there’s no mac tool to create it.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: