views:

198

answers:

7

I have an app that uses this library (actually a direct port to D) for some image processing. I'm looking for some other libraries of a similar style to use to load other file types.

Things I need/want:

  • Loss less format.
  • Simple C API.
  • Loads data into buffers in a raw pixel format.
  • Open source (as in I can get source files and compile them for my own use, aside from that, licensing doesn't matter)

Anyone know of anything like that?

+1  A: 

You might want to try libpng, although I wouldn't exactly call it easy to use.

Other than that, you might try working directly on bitmaps, with no libraries at all.

mingos
Any tips on how to extract the data from the file? (I'm willing to assume that the file is encoded in 24bit color)
BCS
Maybe this code will be of some help: http://doryen.eptalys.net/svn-libtcod/trunk/src/sys_sdl_img_png.c --- it's well documented and written in a readable manner. It's from a library that a friend of mine maintains. Basically, what these two functions do is importing a png image from file to a SDL surface and exporting it back, respectively.
mingos
You might also want to have look at this: http://www.libpng.org/pub/png/book/chapter13.html
mingos
Sorry, that should have been: Any tips on how to extract the data from the **Bitmap** file?
BCS
Oh, sorry. Well, bitmaps are raw pixel colour data. You just read the R,G,B values one by one. You just have to figure out where the file header ends and start reading from there.
mingos
Cool. I guess a little fun with mspaint and a hex vewier would let me find that.
BCS
Yeah, I guess. You can have a look at the format specification too: http://www.fileformat.info/format/bmp/corion.htm - Hope it's of use to you. Have fun!
mingos
A: 

You could always try the gdimage library. I've never had any problems with it, though mist of the work I've done with it has been in PHP.

amphetamachine
+1  A: 

I'd consider using imageMagick ( http://www.imagemagick.org/script/index.php ) for all your image loading needs. It supports a lot of formats in a lot of different bit depths, reading and writing for most of them.

It may do a lot more than you need, but its a very well designed library and I've used it in several projects.

It is GPL compatible. (And I think commercial licenses are available too)

Michael Anderson
+1  A: 

PNG: for loading and saving you can try LodePNG library

C/C++: http://members.gamedev.net/lode/projects/LodePNG/

D port: www.dsource.org/projects/scrapple/wiki/LodePngLibrary

Michal Minich
It's ironic you should mention that one because I already had it downloaded as a result of me being the admin for scrapple. OTOH given scrappls is more of a flea market than a parts store, it's not that surprising that I didn't know what I had.
BCS
+1  A: 

devIL and SDL_Image supports a good deal of formats. Derelict provides their bindings.

My own code for using these and have a raw buffer:

ponce
SDL_Image talks with libpng, libjpeg and libtiff for you.
ponce
A: 

You can use software such as Netpbm to convert to/from PPM format, which is extremely easy to read/write from any program without needing external libraries.

A PPM file either looks like this:

P6
800 600 255
# followed by 800x600x3 bytes of values between 0 and 255, i.e.
\xFF\x00\x00\x80\x80\x00\x00\xFF\x00\x00\x80\x80\x00\x00\xFF...
# but not escaped

or like this:

P3
800 600 255
# followed by 800x600x3 decimal numbers between 0 and 255, i.e.
255 0 0  128 128 0  0 255 0  0 128 128  0 0 255  ...
ephemient
A: 

I think SOIL (Simple OpenGl Image Library) fits your description nicely. It has many formats, iirc the jpg code is even ported from the same source as yours.

Lutger