Home     Sign in    
A summer of accomplishments!
Spring Happenings
My Little Helpers
Archived News
(1) Declining divorce rates reveal the urgent need for legal reform
(2) The End of Car Ownership
(3) Oklahoma 911 caller: Three people broke into my house; I shot two
(4) If Hitler Had Won World War II We’d Have A Better, More Just World Today
(5) WORST PRESIDENT EVER: Obama’s Food Stamp Nation
Photo Archive
Browse by Folder
Browse by Calendar
JSON Parser
Neural Circuits
SIF Library

Simbey Interchange Format (SIF)

The SIF library is a project I started in 2005 when I first began playing with OpenGL programming.  One of the first problems I encountered with OpenGL programming was how to store and load images, especially those with alpha channels.  And thus I began writing the SIF library to deal with loading and storing images with alpha channels.

There's really no magic to what the SIF library does, but it does abstract away all the image handling.  It can become confusing quickly working with premultiplied alpha and trying to remember whether the red and blue color channels need to be swapped.  The SIF library uses two rules when working with images:  raw SIF bits are stored in RGBA format, are not premultiplied with the alpha channel, and are stored top-down; 32 bpp DIBs are assumed to be BGRA, premultiplied, and stored bottom-up.

When loading images into a SIF, most formats are loaded internally using GdiPlus, so whatever can be loaded by GdiPlus can be loaded through the SIF.  32 bpp BMPs stored with BI_RGB are loaded directly to preserve the alpha channel, however, because GdiPlus does not recognize alpha channels in BMPs.

After loading images into the library, a SIF file is produced.  I've included a simple tool called Visual SIF that uses the library to load images into SIF files, but everything the tool does with SIF files is done using public SIF library calls.  I've found that a good practice for using the SIF library is to create a custom build step in Visual Studio that ties together all the PNGs in the project into a SIF file, and then the SIF file itself is embedded into the EXE as a resource.  The SIF library includes an API specifically designed for loading a SIF from a resource.

All the images you add to a SIF are stored as layers.  They can overlap, and they can be flattened at run time to produce a single blended texture, or the layers can be retrieved individually.  It's a snap using the SIF to host icons used for the Windows Ribbon UI.

Icons from an embedded SIF
The icons shown on the ribbon were loaded from an embedded SIF

Using Visual SIF to manage multiple layers
MineCraft's images could easily be stored and retrieved from a SIF file

Rendering from a flattened texture in OpenGL
After flattening the layers, a single OpenGL texture can be created and used to render all the blocks in this scene.

As of 7/25/2012, the SIF library contains an object for drawing text to OpenGL scenes!  Click here for details!

As of 9/20/2012, the SIF library can write 24-bit and 32-bit image bits to PNG format using the LodePNG library internally.  Visual SIF has a menu option to export the canvas to PNG format using the SIF's new export.

As of 10/30/2013, the SIF library attempts first to load all images without premultiplied alpha channels, if possible.  Failing that, it then loads with premultiplied alpha channels and expands the alpha channels manually (original behavior).

The SIF library was written in native C++ and should run on Windows XP+.  If you use it and find it useful, please let me know!

Download the SIF library - Updated on 10/30/2013
© 2001-2017 Simbey.com