PDA

View Full Version : Looking for ANSI c free BMP code



jmathies
02-08-2002, 11:38 AM
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

nexusone
02-08-2002, 12:26 PM
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:

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

jmathies
02-08-2002, 03:20 PM
Originally posted by nexusone:
Have you thought about using TGA format.


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

Jim

MrShoe
02-08-2002, 10:33 PM
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...

rpxmaster
02-09-2002, 08:17 PM
Doesn't the width and height of the bitmap have to be of a power of two if you do it that way?

jmathies
02-09-2002, 08:24 PM
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

SysCo
02-10-2002, 04:48 AM
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.

rpxmaster
02-10-2002, 10:01 PM
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 (http://www.imagelib.org) but I don't believe it fits all the criteria that you're looking for.