Looking for ANSI c free BMP code

Hey all,

I’m looking around for some BMP loader code that fits the following criteria:

  • in the public domain
  • ANSI c, cross platform in design
  • single .c/.h
  • support for indexed, 24 and 32 bit BMP’s

I’d like to add the code to my OpenGL
framework. I’ll give credit in the docs/src
to the author.

Please lemmie know if you’ve seen something like this…

Regards,
Jim

Have you thought about using TGA format.
There are lot’s of examples of loading TGA images into opengl and most paint programs will convert any image to TGA.

Also TGA supports a alpha channel which you will find usefull in making games.

BMP is a Microsoft format and copy righted by them. So any thing you write to support BMP will fall under any restrictions MS puts on the BMP format.

Originally posted by jmathies:
[b]
Hey all,

I’m looking around for some BMP loader code that fits the following criteria:

  • in the public domain
  • ANSI c, cross platform in design
  • single .c/.h
  • support for indexed, 24 and 32 bit BMP’s

I’d like to add the code to my OpenGL
framework. I’ll give credit in the docs/src
to the author.

Please lemmie know if you’ve seen something like this…

Regards,
Jim

[/b]

Originally posted by nexusone:
Have you thought about using TGA format.

Already have that. :slight_smile: thanks for the feedback. I just wanted to support two common
formats without having to link in complex external libs. (jpeg, png, etc)

Jim

Im tired of posting my code so go to the NeHe website and basically all of his tutorials will have a good bitmap loader. If you add a VERY small amount of modifications his bitmap loader will load any quality bmp file, 16bit 24 bit etc…

Doesn’t the width and height of the bitmap have to be of a power of two if you do it that way?

Originally posted by MrShoe:
Im tired of posting my code so go to the NeHe website and basically all of his tutorials will have a good bitmap loader. If

I believe they use auxDIBload which is
ms specific. I’ll check though to make
sure - thanks for the reply.

Jim

I recomand you jpeglib6b from Independent Jpeg Group, it can load jpg, bmp, tga, rle,ppm ….
If you want to decompress in memory files you have to modify the code, but it not so hard.
It is writen in C is portable and is free.
Full sources included.

Originally posted by jmathies:
I believe they use auxDIBload which is
ms specific. I’ll check though to make
sure - thanks for the reply.

Perhaps it’s even compiler specific, because I can’t even get that function to work on Borland. Then again, I haven’t tried linking the version of glaux.lib that comes with NeHe’s Borland C++ downloads. Oh well…

I use DevIL myself for loading images into OpenGL. You might want to check it out at www.imagelib.org but I don’t believe it fits all the criteria that you’re looking for.