Question

Can anyone recommend a decent C image library?

I'm after loaders for bmp, gif, jpg, png and tga.

I want to use this for programming my Sony Playstation Portable, so opensource would be very handy.

After some googleing I've found FreeImage and CImg, but both feel rather heavy, and CImg is C++ not C.

Was it helpful?

Solution

If you control the images you're loading, the lightest loader I know is Sean Barrett's awesome stb_image.c (direct link to single file source code!).

There are also other very worthwhile libraries on Sean's site such as a tiny TrueType rasterizer and Vorbis decompressor, btw.

If you need OpenGL image loading that uses stb_image, I'll humbly point you to SOILex...

OTHER TIPS

I used FreeImage for PSP games in the past, but it was for pre-processing the data rather than in-game.

DevIL is often recommended. Whether or not it does what you want, I don't know.

I will second Thomas Owens's ImageMagick suggestion. It is mind-boggling just how comprehensive the library is, and how much time it saves you in the end.

Here is some code I wrote for handling images. It is in c++ ( not c ) but you should be able to easily extract the BMP and GIF load code. It's licensed LGPL.

I use the libpng and jpeglib for decompressing those formats.

For one of my project, I am using CImg Library. It's very useful to start with. Moreover, they also have a decent documentations.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top