views:

244

answers:

3

I'm looking for a library to save an array of colour data to a PNG file. (That's all there is to it, right? I know very little about the internals of a PNG.)

This is for use in Nintendo DS development, so something lightweight is preferable. I don't need any other fancy features like rotation, etc.

+1  A: 

Have you looked at libpng? http://www.libpng.org/pub/png/libpng.html

I'm not sure whether the memory footprint will be acceptable, but you should probably be aware that PNG files are a lot more involved than just an array of colors. Performance is likely to be a concern on a DS.

If you go with libpng, you'll also need zlib, and if you're using DevKitPro, you'll probably run into some missing functions (from playing with the code for 5 minutes, it looks like it relies on pow() which doesn't seem to be in libnds.) I have no idea what the official Nintendo SDK offers in the way of a standard library - you might be in better shape if that's what you're using.

Ori Pessach
+1  A: 

To encode any kind of PNG file, libpng is the way of the walk.

However, on small devices like the DS you really want to store your image data in the format which the display hardware expects. It is technically possible to get libpng working on the platform, but it will add significant overhead, both in terms of loadtimes and footprint.

Rune Braathen
A: 

I managed to find a library that supports PNG (using libpng) and allows you to just give it raw image data.

It's called LibPicture. It's a bit hefty though: ~1MB.

Ryan Fox