image/texture library

I’m posting in the advanced forum in hopes that some of the more senior members can offer some suggestions based upon experience.

Anyway, I’m looking for an imaging library to read various file formats from disk with the explicit purpose of creating OpenGL textures. Performance of the library will be an issue. I absolutely must have support for the following formats:

  • SGI
  • TGA
  • BMP
  • DDS (DDS1 and DDS3)
  • JPG
  • TIF (not GeoTIFF, just plain old TIF)

It would be helpful if the library supported other formats such as PNG, GIF, PCX, etc, but not necessary.

Some of the formats I already have code for (TGA, BMP, some DDS, and SGI) but what I don’t have is a unified library with a single coherent interface. If I had more time I’d clean up what I already have and start a library off my existing code base, but I’m short of time.

I had considered using DevIL, but it’s LGPL and the app I’m working on is closed source. The company (their legal dept. actually) I’m working with has concerns with the LGPL and won’t allow me to use DevIL.

I’m willing to pay for a library, that’s no problem. I just don’t want to end up with something that I’ll regret later.

Please, I don’t want this thread to turn into a LGPL debate, just looking for a good library with a BSD style license or something I can buy off the shelf.

I found FreeImage, http://freeimage.sourceforge.net any comments?

Suggestions?

This one rocks…
http://openil.sourceforge.net/

Supports loading of:

    * .bmp
    * .cut
    * .dcx
    * .dds
    * .ico
    * .gif
    * .jpg
    * .lbm
    * .lif
    * .mdl
    * .pcd
    * .pcx
    * .pic
    * .png
    * .pnm
    * .psd
    * .psp
    * .raw
    * .sgi
    * .tga
    * .tif
    * .wal
    * .act
    * .pal
    * Doom graphics 

yooyo

Originally posted by yooyo:
This one rocks…
http://openil.sourceforge.net/

Go back and read my original message. I can’t use DevIL, formerly known as OpenIL.

Taken from http://openil.sourceforge.net/about.php

“Many people may have known DevIL as OpenIL, but the name was changed due to SGI’s request.”

Originally posted by cru:
I had considered using DevIL, but it’s LGPL and the app I’m working on is closed source. The company (their legal dept. actually) I’m working with has concerns with the LGPL and won’t allow me to use DevIL.
Then they probably won’t allow the use of FreeImage either since it’s released under de GPL and the FreeImage Public License .

Originally posted by ^Fishman:
Then they probably won’t allow the use of FreeImage either since it’s released under de GPL and the FreeImage Public License .
I don’t think FreeImage is encumbered by both licenses. It’s more of an either or situation. You can choose GPL or the FreeImage Public License. The ‘FPL’ seems to be liberal enough to use in a closed source product. I’ll let the lawyers make that call.

I’m not looking for some library I can take and claim ownership. I have no problem with providing credit where credit is due. I’d be more than happy to accept a license where I have to give improvements I make back to the community. I’m just looking for a library that this legal team deems commercially friendly AND has the features I desire. I’m more than willing to pay for such a library.

Hi cru!
Maybe this will help you:
NexgenIPL
DDS codec at bottom of the page.
But I think it only works with VC++… :frowning:

What are you talking about?

It’s LGPL not GPL.

Specifically that’s not a viral license. You can link to that library with a closed source app and there’s no obligation to publish your own source.

Only if you modify the library will you have to release the modified library code. So, why should you care if you link to a library that’s already in the public domain?

I’ve linked to LGPL libs in closed source apps that shipped (GDAL and zlib), the company at the time even paid one author to enhance a library we used, those enhancements became part of the published LGPL library back in the original repository, but our application remained closed source. The relationship worked very well with te full knowledge of the authors.

Originally posted by dorbie:
[b]What are you talking about?

It’s LGPL not GPL.

Specifically that’s not a viral license. You can link to that library with a closed source app and there’s no obligation to publish your own source.

Only if you modify the library will you have to release the modified library code. So, why should you care if you link to a library that’s already in the public domain?

I’ve linked to LGPL libs in closed source apps that shipped (GDAL and zlib), the company at the time even paid one author to enhance a library we used, those enhancements became part of the published LGPL library back in the original repository, but our application remained closed source. The relationship worked very well with te full knowledge of the authors.[/b]
Refer back to my original message.

The company I am writing an app for has a legal department that has deemed the LGPL untested and ambiguous. The attorneys that work for this company agree that industry consensus is that the intent of the LGPL is to allow commercial entities to use LGPL’d software with propriety code without exposing closed software to liability. However, they (the attorneys) are concerned that the LGPL hasn’t been tested in a court of law and they feel it is too ambiguous. This company doesn’t want to have to defend themselves against a potential junk lawsuit. I think the attorneys are being over-protective, but I also agree that they have a point. None of that matters. It’s their (and many other companies) decision not to use LGPL software not mine. If it were mine I’d feel comfortable using the code. They would much rather spend the cash on a library with a clear license. Like I said earlier, I don’t want this thread to delve into a LGPL debate.

So, in that vein, if you have some suggestions as to other imaging libraries, I’d love to hear them.

Right now, I’m leaning toward FreeImage (it has a dual license). Anyone have any experince using this library?

Well perhaps your company should purchase a proper library for you then :wink: Or give a developer a week and code the library you need.

Originally posted by rcpedersen:
Well perhaps your company should purchase a proper library for you then :wink:
No problem. Suggestions?

Well, I’m sure the code for loading all the file formats you need is freely available on the internet, so why not just spend a few hours pulling it all together into a single library?
Then let me have a copy :wink:

I think his lawyers might have a thing or two to say about using downloaded ‘free’ code from the internet.

Without being able to channel your lawyers it’s impossible to recommend something. We can’t know what they’d approve of. All software is released under some license whether it’s open or closed source.

I guess it’s true that some lawyers can cost you a lot more than their fees.

Try here:
http://www.wotsit.org/

…and get coding.

Watch out though, a game company I worked for had some spectacularly inept lawyers who wanted to yank in house sorting code because a comment said the algorithm was published in a Knuth CS textbook, yea Knuth!!! I let the manager know exactly what I thought about that one, some people need to get the hell out of the way when it comes to writing code.

You can also have a look to GDI+ (for Windows XP) or Quicktime (for MacOS).

This will give you JPG, PNG, GIF, BMP, TIF with a very minimal size and memory overhead. (TIF is a large library).

And it fixes all possible ‘legal’ issues :wink:

Originally posted by dorbie:

Watch out though, a game company I worked for had some spectacularly inept lawyers who wanted to yank in house sorting code because a comment said the algorithm was published in a Knuth CS textbook, yea Knuth!!! I let the manager know exactly what I thought about that one, some people need to get the hell out of the way when it comes to writing code.

You should be able to use the code from any book, else why buy it? There are so many programming books that are about algorithms.

IANAL but not necessarily.

In this case it wasn’t even code but a new implementation of a standard widespread algorithm.

I did say they were spectacularly inept.

I’ve just used freeimage to load a texture, I was curious.

It seems quite powerful. The data can come in in a format you can send straight to OpenGL, if not then there appears to be powerful in memory conversion routines.

Here’s the quick and dirty code showing how you can load an image to a texture (there are ways of loading any format, in the examples provided using a file handle, I wanted to strip it to the basics here though). I’m not deriving the texture format from the loaded dib because I know what I’m loading but I left the calls in there to show how you can get this information and decide the byte ordering:

	unsigned char *image;
	long x_image, y_image;
	FreeImageIO io;
	FIBITMAP *dib;
	int pix_size;
	int line_size;
	unsigned int r_mask;
	unsigned int g_mask;
	unsigned int b_mask;

	dib = FreeImage_Load(FIF_PNG, "Textures\\altimeter.png", 0);
        if (dib != NULL) {

            y_image = FreeImage_GetHeight(dib); 
            x_image = FreeImage_GetWidth(dib);
            pix_size = FreeImage_GetBPP(dib);
            line_size = FreeImage_GetLine(dib);
            r_mask = FreeImage_GetRedMask(dib);
            g_mask = FreeImage_GetGreenMask(dib);
            b_mask = FreeImage_GetBlueMask(dib);
            image = FreeImage_GetBits(dib);
	    glBindTexture(GL_TEXTURE_2D, 1);
	    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	    glTexImage2D(GL_TEXTURE_2D, 0, 4, x_image, y_image, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, image);

        }

This is just illustrative. The texture formats need to be based on the image content but that looks easy to do.

Alpha seems to work from a loaded PNG, but I don’t see a function to get the alpha mask (mask bits seem to ignore alpha completely), I do see the tokens elsewhere so there’s a slight negative on that score but I want to poke around it a bit more and maybe see if there’s more/other API calls I can use.

Anyway, this shows it can be used with OpenGL and quite easily & efficiently, the info you need to support and query byte ordering is there as well as a native in memory format that ‘just works’ right out the gate.