Developing Imaging Applications with XIElib

The X Image Extension, more commonly known as XIE, provides a mechanism for graphic image management in the client/server environment of X11.
  • Author: Syd Logan

  • Publisher: Prentice Hall

  • URL: http://www.prenhall.com/

  • Price: $54 US

  • ISBN: 0-13-442914-1

  • Reviewer: Michael J. Hammel

Computer graphics have come a long way for Linux users in the past two years. Applications of all kinds have started to show up in many places, coming from both the Open Source community as well as commercial vendors. One reason for this recent growth is the flexibility and extensibility of the native windowing system: the X Window System, also known as X11. Although end users are the eventual benefactors of this flexibility, it is the development side of Linux that will be most interested in one of X11's least-known extensions—the X Image Extension.

The X Image Extension, as the name implies, is not part of the core X11 distribution, although any system using X11 Release 6 (aka X11R6) should have this extension included. The X Image Extension, more commonly known as XIE, provides a mechanism for graphic image management in the client/server environment of X11. Image decompression, for example, can be handled on the server side (the display side) instead of overloading clients with this common and resource-consuming task.

Some time back, the author of Developing Imaging Applications with XIElib, Syd Logan, contacted me about this extension and recommended the GIMP developers take a look at it. At the time, I was modestly involved in GIMP development, back in the very early days when the GIMP was still a Motif application. XIE never really seemed to catch on in the developer community for the GIMP. Perhaps it was simply because no text was available from which to learn the API (the applications programming interface or the interface into XIE's software library). It may also have been due to the fact that not all developers were on Linux at the time and not all UNIX vendors had migrated to X11R6, a situation that continues to this day.

Despite the GIMP not using XIE, I've still been interested in what XIE is all about. What can it be used for? How difficult is adding it to an existing application? Does it help solve some of the more mundane problems in computer graphics, or is it more focused on specific types of problems?

Syd's book is well-organized and provides answers to most of these questions. The text is thick—well over 600 pages—with chapters ranging from introductions to existing image handling methods in Xlib to the nuts and bolts of XIE's API and its underlying data structures. The chapters flow from an overview of the XIE architecture into high-level concepts such as “photoflo elements” and image file formats to more detailed descriptions of using “process elements” to do format conversions and the use of “techniques”, the algorithms used by the server side for image processing.

Even with my self-taught experience in graphics terminology, I discovered XIE has a whole new set of terms to learn. A fairly complete glossary of these terms is included at the end of the text, but you'll find Syd's definitions within the text to be a better source of information. He does a good job explaining new terms quickly and fitting them into the larger picture that is XIE.

Accompanying the text is a CD with a modest bit of sample code from the text. The README on the CD is quite extensive and should be read before trying to build or run any of the software on the CD. Some of the files on the CD do not have read permissions for anyone but the file owner, so you'll have to copy the files from the CD as the root user and then do a chown/chmod sequence to get them installed properly.

The libtiff and jpeg libraries, required to build the XIE samples, don't build easily from the CD. I downloaded the latest libtiff source from the FTP sites specified in the README file (found in the libtiff directory on the CD) and replaced the old version with the new version. I couldn't do that with the JPEG library, because the main archive location of ftp//ftp.uu.net/ doesn't allow connections from dial-up hosts whose names don't resolve in DNS. So, I grabbed the source from the GIMP server (ftp//ftp.gimp.org/pub/libs/). The new versions built much more easily. I did not, however, install these libraries on my system, as I already had working versions installed. The /xiesamples directory hard codes the library paths to these image libraries (libtiff and libjpeg) to be relative to the samples directory. I simply built the libraries and then renamed the default directories (from the archive files) to the directories expected by the XIE CD software. After this, the CD software built fine.

The sample software under the /xiesamples directory covers most, if not all, examples from the text. Since all of the sample clients on the CD were written on Linux, they all built fine (after updating the two libraries described previously). Programs here are small examples of the base features of XIE as described in the text. From the README file on the CD:

Most of the samples work with gray-scale JPEGs, a few work with CCITT images stored in TIFF files, PGM, PPM, color JPEGs, or raw SingleBand (gray-scale) images.

Unfortunately, I had problems running these sample programs on my system. After rereading the README file, I discovered some of the samples work only on 8-bit PseudoColor visuals. I have my system running in TrueColor mode. Take a look at the README file for explanations of each sample; it will tell you if you can specify a visual and/or the type of color map to use. However, in my limited tests, the only sample program I was able to run under a TrueColor visual was the backendtest program.

Chapter 2 has a fairly good discussion on using Xlib for image manipulation for anyone who had problems understanding it from the O'Reilly Xlib manuals. This text is a programming guide, not a reference guide. To my knowledge, a printed reference guide for XIE is not yet available.

Throughout the text, Syd provides examples of how to make XIE API calls, including well-commented data structures used in the API. It's obvious Syd understands the ins and outs of the API. He provides extensive source code examples—I hardly went through three pages without seeing at least one snippet of code.

Plenty of gray-scale example images are printed in the text, and at least a few of these lose some of their impact without color. An eight-page color gallery is in the center of the book. However, these images are useful only for explaining some general graphics terminology and techniques and are not really descriptive of XIE itself.

I found Chapter 15 to be one of the best chapters simply because of its application to other graphics areas. Color space conversion is a common task and one that is not well-supported by many Linux graphics applications. For example, three paragraphs into this chapter, I learned that

YCbCr images represent color and luminosity as separate channels in the image. Humans are more sensitive to changes in luminosity than to changes in color, [so] compression algorithms can apply greater compression ratios to the color bands than are applied to the luminance band (Y) without degrading the perceptible quality of the image.

This sort of information, while explaining why certain color spaces are supported by XIE, also provides definitions that are applicable to other color management tools.

One issue not covered well in this text is how XIE might be used, if it can be used, with tools like OpenGL or Mesa. It might not make sense to combine the two, but there doesn't seem to be any mention of how XIE fits into the overall X11 collection of core features, extensions and third-party graphics libraries.

______________________

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix