A peculiar thing with ofxiPhone and alpha blended textures

Ok, so I’m not deeply familiar with openFrameworks or the iPhone yet, but I came across a strange behavior today that drove me mad for a bit, but I’ve now got it solved. It might be a bug, but I don’t feel qualified to decide.

So I’m loading OpenGL textures using the ofImage class. Now, if my .png files are in the data folder inside the main project folder, i can load them and draw them no problem.

I would load the image like so:


Everything seemed to be going well. My image drew how I expected it to using the iPhone simulator… BUT… when I went ahead to test it on my actual iPhone, the alpha blending didn’t work at all. I was sure I had all my render states set correctly and I could figure out what was going on. Totally boggling my mind.

So I went back to the graphics example for iPhone that came with the examples. It has a png with transparency that it draws. I loaded it onto my iPhone and the transparency looked fine. In order to make this example more consistent with my own app, I made a copy of “transparency.png” and put it inside the data folder rather than data/images where all the images from that demo come stored.

I changed transparency.load(“images/transparency.png”) to transparency.load(“transparency.png”) and the alpha blending problem reproduced on my iPhone.

Once I put the stuff in my own project in an “images” sub directory of the data folder, my transparency woes were solved. So there you have it… I supposed it might have something to do with the way filesystems work once the app is on the iPhone, but this was a pretty confusing thing for me to get through. Anyway, the steps above ought to let anyone reproduce this problem. The really weird part is that it works fine while you are still using the simulator… its only when you put it on your iPhone that it becomes a problem.

Anyway, there you go. Sorry for the long-winded explanation.


Hey Aaron, yea this is a known issue, sorry you had to learn the hard way :stuck_out_tongue:

Basically when xcode is copying the data to the iPhone, it applies an ‘optimization’ to the PNGs. This makes them a non-standard PNG. Because we are using freeimage to load the png, and not the normal apple cocoa-touch api, the images cannot be loaded correctly. The workaround solutions are:

  • right click on the png in the project folder and goto properties. It will be image.png, change that to anything else e.g image.tiff. Then xcode will not process the file file as a PNG (ie. change encoding), but as a tiff (straight copy).
  • OR you can do what you did, and place the file inside a folder, and add the folder to your project. Then again xcode won’t process it.
    We were also looking into an option to disable this PNG optimization completely, but we kinda got caught on other things…

good luck!

Just found the option:

Go to your projects build settings.
In the lower left hand corner is a menu you icon that looks like a GEAR
Choose Add User-Defined Setting
Set the Value to: -skip-PNGs
Do a clean build and your good to go as far as I can tell.
I checked my bundle here and it worked.

We’ll probably change the default projects to have that option on by default for the future.

A lot more useful iphone dev tips at

also just saw this is mentioned in the wiki (along with a lot of other tips for openFrameworks on iPhone)

Hi, I find myself having the same problem as mentioned above… the only thing is that none of the solutions mentioned seem to work :frowning:

I’m using xcode 3.2.4 and ios simulator 4.1.

I know this issue is thought of as resolved for most part… but any help would be appreciated.


I just wanted to say, for some reason i dont see this problem in the other iphone examples.
I just ran iphone graphics example and the transparency is working fine both on the simulator and the device…

So i think ill work with that project as the basis…