views:

246

answers:

1

I am having trouble getting Cocoahttpserver from Duesty Designs (awesome open source library makers of CocoaAsyncSocket) to serve images from my app bundle. Using the example iPhone project I can serve up an html file from the Resources dir in my project, but images refernced like:

<img src='foo.png' />

are not rendered.

Does anyone know why or what I need to do to make this work?

+3  A: 

PNG images in your Resources directory are encoded in a funky format. modmyi has a good article on the subject.

My approach would probably be to name them with .png_unconverted, and rewrite the code in Cocoahttpserver to translate requests for .png into .png_unconverted.

Another solution would be to investigate the CopyPNGFile rule in the build system and see if you can get it to knock it off with the converting (this will probably make it impossible to render the PNG from within your app, however).

Finally, you could switch to JPEG. I don't believe that these files get modified.

Rob Napier