Archive for January 2005

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