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.
-
Voting to close as tool rec. Similar: http://stackoverflow.com/questions/50079/c-image-library – Ciro Santilli OurBigBook.com Apr 01 '16 at 17:33
7 Answers
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.

- 198,648
- 61
- 360
- 533
-
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 Apr 30 '10 at 11:43
-
You could try stb_image for reading and stb_image_write for writing. These are very small libraries.
http://nothings.org/
https://github.com/nothings/stb
Link to my question on gamedev I've got to know about this site:
https://gamedev.stackexchange.com/questions/9083/library-to-load-images-into-textures-linux-c-and-opengl
I think FreeImage is the best one out there:

- 51,293
- 14
- 84
- 114
-
4No 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 Apr 29 '10 at 20:34
-
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.

- 5,896
- 2
- 31
- 42
-
1That's true. BMP and TGA file formats are also very simple to parse or generate. – Judge Maygarden Apr 30 '10 at 13:37
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.

- 52,691
- 28
- 123
- 168