SOIL: new lightweight image loading lib

Started by
129 comments, last by GenPFault 13 years, 11 months ago
OK, new SOIL release with some fixes and some new features. Here is a Copy-n-Paste of the changelog:

* correctly reports when there is no OpenGL context (thanks Merick Zero!)
* upgraded to stb_image 1.03 with support for loading the HDR image format
* fixed loading JPEG images while forcing the number of channels (e.g. to RGBA)
* changed SOIL_DDS_CUBEMAP_FACE_ORDER to a #define (thanks Dancho!)
* reorganized my additions to stb_image (you can define STBI_NO_DDS to compile SOIL without DDS support)
* added SOIL_FLAG_CoCg_Y, will convert RGB or RGBA to YCoCg color space (link)

Thanks again to everyone for your feedback and helping find bugs!
Advertisement
@lonesock

that snippet is now working ok with your lib,
but when I try to compile a VC8 SOIL.sln I get this error:

1>LIB : fatal error LNK1181: cannot open input file '.\lib\stb_image.obj'

regards,
Dancho



Quote:Original post by Dancho
...when I try to compile a VC8 SOIL.sln...

Argh! I renamed a few files in my quest to make DDS loading easy to compile in/out of SOIL, and forgot to update all the Visual Studio projects (I do all my hobby stuff on CodeBlocks). I'm so sorry, I'll get that updated soon.

Thanks,
Hey Lonesock,

Your SOIL is great, thanks. Just a couple problems building on OSx.

Soil.c line 1428 should be

CFRelease( extensionName ); (I think)


and SOIL.c line 78 (I just deleted APIENTRY)

after that, it builds and works fine (I only tried SOIL_load_OGL_texture with PNGs)


Matt
Once I've used SOIL_load_OGL_texture to load a texture, how do I remove it from memory? SOIL_free_image_data doesn't seem to do anything
Hi

Thanks for this great library, I'm probably going to integrate it into my own library to get rid of DevIL for image loading. As in public domain, I should be able to include the SOIL files directly into my project instead of building it as a separate library, right (my library is open-source, under the zlib/png license) ?

Just a few suggestions to improve integration of SOIL into other libraries :

- You should split the functions into 2 separate sets of files : those for pure image loading / saving, and those related to OpenGL textures. Then you can add the ability to use the first subset of the whole library with a define, like SOIL_USE_OPENGL or SOIL_DONT_USE_OPENGL. Your library is very useful to add image loading to higher-level libraries (like mine), but not everybody will want the OpenGL stuff.

- There are still a lot of warnings when compiling (I use level 4 in Visual Studio), mainly due to implicit casts or signed/unsigned mismatches. They can be easily corrected, so I think it would be a good idea to fix them to make compiling cleaner.

- There is a bug (or at least an inconsistent behavior) when loading a DDS : if the source image has no alpha, it will convert the output to 3 components even when the caller requested 4.

- Do you think PNG and JPEG formats can be supported for saving ? Or maybe I should rather contact the author of stb_image ?
@Mogui: Thanks for letting me know. I was pointed towards another error I had with that segment of code, which might fix this problem too. The next release will have the fix and I'll try to PM you to see if it fixed the issue.

@Merick Zero: Sorry if the docs are unclear. The SOIL_free_image_data() function is actually for use with SOIL_load_image() or similar which returns an array of unsigned chars. If you are done with the OpenGL texture, simply call the glDeleteTextures() function, like this:
glDeleteTextures( 1, &my_tex_ID );

@LaurentGom: You're welcome! "Public Domain" as in if you want to take the code, rename it LOIS and sell it as a closed source project to Microsoft, that's OK with me [8^) Your suggestions are excellent. If I may comment on them very quickly:
1) People can just use stb_image if they want image loading only (with my DDS additions if so desired). What other functionality does SOIL offer that you would want with the image loading stuff?
2) I am leaving the stb_image code mostly untouched, but if you find any of those warning in any other piece of code, please PM or email the list to me and I would be happy to fix them!
3) Ouch! I'll look into that.
4) I think contacting Sean (see his site here) would be a good idea.

Again, thank you all for your feedback & bug reports!
Thanks for the informations.

Just a few precisions for 1) : in the version I downloaded (a few days ago), DDS and PNG was not part of stb_image. Same for the general load / save functions (they were mixed with the OpenGL ones in SOIL.h).
It seems to have changed, so I should just get the latest version.
when using soil to load an image, is there any way to get the alpha value from a certain pixel inside the image, either from the image buffer created by SOIL_load_image or from the gl texture itself? Basically what I want to do is create an array with 0's and 1's to use as data for pixel perfect collision in 2d games
has anywhere libSoil.a for Linux?

Joshy
Sorry about my bad English.

This topic is closed to new replies.

Advertisement