16

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.

Lucas Jones
  • 19,767
  • 8
  • 75
  • 88
Timmy
  • 12,468
  • 20
  • 77
  • 107

7 Answers7

17

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
  • 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
  • this is wat i ended up doing, using convert to switch between fmts – Timmy Apr 30 '10 at 14:50
7

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

Community
  • 1
  • 1
Michas
  • 8,534
  • 6
  • 38
  • 62
4

I think FreeImage is the best one out there:

http://freeimage.sourceforge.net/

Andreas Brinck
  • 51,293
  • 14
  • 84
  • 114
4

Simple Direct-media Layer (SDL) with SDL_image

Judge Maygarden
  • 26,961
  • 9
  • 82
  • 99
3

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.

WildCrustacean
  • 5,896
  • 2
  • 31
  • 42
2

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
  • 52,691
  • 28
  • 123
  • 168
2

I like gd. Real popular.

link text

xcramps
  • 1,203
  • 1
  • 9
  • 9