views:

132

answers:

6

What's the simplest C image library for loading and saving? I just want a 2D array to test some algorithms, and built-in functions are not needed.

+1  A: 

You definitely want to look at the imagemagik c connector api. It is very easy to get going, and the linked page has some nice code samples.

And there is always the ubiquitous GD library. It is not hard to use either.

Byron Whitlock
+2  A: 

I think FreeImage is the best one out there:

http://freeimage.sourceforge.net/

Andreas Brinck
it looks in C++
Timmy
No FreeImage is a pure C library, although there is a C++ version called FreeImagePlus which wraps the C structs and functions in classes.
Andreas Brinck
+1  A: 

I like gd. Real popular.

link text

xcramps
+1  A: 

Simple Direct-media Layer (SDL) with SDL_image

Judge Maygarden
+2  A: 

You could also just read and write raw image RGB values to a binary file, if that is really all you need, and if you know the image size ahead of time.

bde
That's true. BMP and TGA file formats are also very simple to parse or generate.
Judge Maygarden
+3  A: 

All these libraries are way too complicated for me. In your place I'd grit my teeth, define an abstraction for a dynamic two-dimensional array, and I'd read and write plain ASCII PNM format.

Norman Ramsey
I have done the same before to test some image processing algorithms. It is very easy. Just write header (in ascii) and put you pixel data after.
Ross
this is wat i ended up doing, using convert to switch between fmts
Timmy