TinyImageLoader (TIL) is an image loading library written in C++. It started because I wanted to load images on Windows Mobile. So I downloaded the FreeImage source and started to include it in my project. Then I noticed it was over 2 MB of static libraries! On a platform that has only 64 to spare! I started to look at alternatives. DevIL didn't work either. Finally, I stumbled on stb_image.c.
I was intrigued. What if I rewrote stb_image.c to not only look better, but support more image formats as well?
From that followed TinyImageLoader. In its most optimized form, TIL is a mere 116 kB.
EDIT REGARDING STB_IMAGE: Mr. Barrett noted below that I did not credit him for his work. An oversight on my part! I have since corrected this. The SVN version of TILImagePNG.cpp has a credit section for his work on stb_image.c and will be included in future versions of TinyImageLoader.
What does TIL support?
TIL supports: PNG, BMP, GIF, ICO and TGA. It also supports APNG (animated PNG) and animated GIF.
What can you do with TIL?
All you can do is load images and convert them to the correct color depth. For example, if you're working on Windows Mobile, you will be using 16-bit color. You would load images like this:
til::Image* load = til::TIL_Load("texture.png", TIL_FILE_ADDWORKINGDIR | TIL_DEPTH_R5G6B5);
How would I use TIL to load a texture?
You can load a texture like so:
// Initialize TinyImageLoader til::TIL_Init(); // [ more code here ] // Load an image // Note: OpenGL reverses the pixel components // TIL_DEPTH_A8B8G8R8 = GL_RGBA til::Image* load = til::TIL_Load("media\\PNG\\avatar.png", TIL_FILE_ADDWORKINGDIR | TIL_DEPTH_A8B8G8R8); // Load the pixel data into the texture glEnable(GL_TEXTURE_2D); glGenTextures(1, &g_Texture); glBindTexture(GL_TEXTURE_2D, g_Texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, load->GetWidth(), load->GetHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, load->GetPixels() ); glBindTexture(GL_TEXTURE_2D, 0);</pre>
This example can be found in the examples solution provided with TinyImageLoader.
How well documented is TIL?
As of version 1.6.0, TinyImageLoader is fully documented. The documentation can be found in the docs folder in the SDK folder. An example of an image viewer using OpenGL is provided.
I want to use TIL in my commercial project. Is that allowed?
TinyImageLoader is free software licensed under the MIT license. This means you can do whatever you want with the code (redistribute, change, use) as long as you attribute the project owner.
I found an image that doesn't load correctly. What should I do?
E-mail me at knight666 (at) gmail (dot) com with the code you were using to load the image and the offending image. You can also try fixing it yourself, using the latest source found on the SVN. If you have fixed it, let me know! I will review your patch and hopefully include it in the next release.
Project home: http://code.google.c...inyimageloader/
Stable release: http://code.google.com/p/tinyimageloader/downloads/detail?name=TinyImageLoader%201.6.3.zip
Changes in 1.6.0
- Fixed all memory leaks.
- Added documentation
- Added DDS loader (DXT1 and DXT5 support)
- Added FileStream abstraction (check the zip loading example)
- Added detailed tutorial
- Fixed tons of bugs
Changes in 1.6.1
- Framework project pointing to wrong GLEW library (glew32_x86.lib instead of the standard glew32.lib)
- Missing third-party libraries page in the documentation
Changes in 1.6.2
- Fixed a serious heap corruption bug caused by til::TIL_AddDebug
- Fixed a serious heap corruption bug caused by til::TIL_AddError
- Fixed memory leak in til::FileStreamStd - path string was not deleted
- Fixed memory leak in til::TIL_Load - FileStream handle was not deleted
- Fixed bug in til::TIL_Load - FileStream was being closed twice
- Fixed memory leaks in til::ImageICO
Changes in 1.6.3
- Added til::TIL_Release function, which releases a handle
- Added TIL_TARGET_DEVEL target for developers
- Removed unnecessary includes (e.g. windows.h, stdlib.h, etc.)
- Fixed a bug where til::TIL_ShutDown could cause a crash by deleting an uninitialized variable