New version 0.0.2

I have released a new version. This is mostly just an update of the Cairo libraries to the latest snapshot from CVS.

I made a minor change in Fl_SVG_Image so that the ARGB byte swapping is done on all platforms. This makes is easier for me to update the Cairo libraries (less changes to the Cairo code base).

As usual, let me know if you run into any problems. This should work out of the box on Linux, OS X, and Windows.

Download Imago

The latest release is 0.0.2. This an alpha release and may be totally broken while I work on getting everything together and solidifying the API. I will do a 0.1.0 release once everything is straight and seems to work.

Binaries of the library are available (shared and static library for use with FLTK). The Linux version was compiled on i386 Ubuntu Linux (Hoary) using gcc 3.3.5. MacOS X version on 10.3 (Panther). Windows version using Visual Studio .NET 2003. Be aware that just like FLTK, this is a C++ library so you generally must use the same compiler for linking against it or you need to compile the library yourself.

All of my source in this library is released under the LGPL with an explicit exception that allows static linking. You are advised to look at the other libraries for their respective licensing as some of them are plain LGPL. All included SVG images are Copyright © 2005 Chris Osgood.

Binaries:

Get the source code:

Imago Documentation

When compiling, the build system assumes fltk-1.1.6 is in the same directory as the Imago source. For example, you should have something like the following:

/home/user/devel/fltk-1.1.6
/home/user/devel/imago
or C:\devel\fltk-1.1.6
C:\devel\imago

The API reference is available in Doxygen form.

I have a number of outstanding issues with Cairo:

  • Image renderer is a bit too slow.
  • Image renderer outputs in different formats on platforms with different endianness.
  • The formats that that the image renderer outputs (ARGB and BGRA) are incompatible with FLTK’s imaging layer.
  • XML parser can not handle out of order items causing some legal SVG elements to not be rendered.
  • No SVG “filter” support.

Currently the Windows version needs to have the fontconfig “fonts.conf” file compiled into your executable if you are statically linking. The resource ID is 17987 (0x4643 or “FC” in ASCII). The resource is automatically included in the Imago DLL when not using the static library. If this resource is missing then the Windows application will most likely crash. I need to fix this in the fontconfig library for Windows.

Because FLTK currently does not support translucency you must set the background color of SVG images if you want them to appear smooth against the background. I hope to eliminate this issue at some point by patching FLTK.

Here is a simple FLTK application that uses an SVG image loaded from a file:

#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Box.H>
#include "Fl_SVG_Image.H"
int main(int argc, char* argv[])
{
   Fl_Double_Window* win = new Fl_Double_Window(800, 600);
   Fl_Box* box = new Fl_Box(0, 0, win->w(), win->h());
   Fl_SVG_Image* img = new Fl_SVG_Image(argv[1], box->w(), box->h(), box->color());
   box->image(img);
   win->end();
   win->show();
   Fl::run();
   return 0;
}

Or to load an image from memory (note this doesn’t actually work because the SVG image data is invalid):

#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Box.H>
#include "Fl_SVG_Image.H"

const char* sample_svg_image = “<svg …> … SVG data here, gziped or plain text</svg>”;

int main(int argc, char* argv[])
{
   Fl_Double_Window* win = new Fl_Double_Window(800, 600);
   Fl_Box* box = new Fl_Box(0, 0, win->w(), win->h());
   Fl_SVG_Image* img = new Fl_SVG_Image(sample_svg_image, strlen(sample_svg_image), box->w(), box->h(), box->color());
   box->image(img);
   win->end();
   win->show();
   Fl::run();
   return 0;
}

FLTK Imago

Welcome. Imago aims to be a set of advanced imaging extensions for FLTK. This first release adds basic SVG (Scalable Vector Graphics) image support. SVG is similar to Postscript or PDF except it is based on an XML file format with optional gzip compression. Take a look at the specifications if you are interested in learning more.

Imago uses Cairo and other supporting libraries from the freedesktop.org project to supply the underlying SVG drawing support. Currently these libraries are in heavy development and need a lot of improvement before they will be fully usable.

Imago adds two new classes to the 1.1.x series of FLTK. “Fl_SVG_Image” works similar to the other image classes in FLTK, and “Fl_SVG_Button” makes it easy to create custom buttons that are based on SVG images.

Orginally I developed this to make it easy to create fully scalable interfaces. I am currently using it for development of kiosk systems, TV and media systems, and applications for controlling hardware where I want the application to look similar to the hardware it is controlling.

There are a few things that might be interesting to add to this library. The ability to actually create the GUI in SVG might be fun. This would mean that all the buttons and controls would be defined inside the SVG file. Font access via SVG would also be useful. That would be future functionality though.

In the downloads section you can find the source. The Imago source is released under the same license as FLTK (LGPL with static link exception). Also inside the full source download are several other libraries needed to make everything work. All of those libraries have either BSD-style or LGPL licenses. I have tweeked many of these libraries so that they compile and work on all the platforms (eg. Windows). I have also compiled shared and static binaries for Linux, Windows, and MacOS. Using the libfltk_imago binaries is probably the easiest method to start using the new functionality. Compiling everything from source can be complex due to all the libraries required. However, I have tried to make it simple. There are autoconf/Makefiles and a Visual Studio solution for building on the various platforms.

Contact me at mailto:imago@functionalfuture.com

For an excellent free SVG drawing program, take a look at Inkscape.

Screenshots of FLTK Imago test application (Linux, Windows, MacOS X):

screenshot1 screenshot2 screenshot3