Developing Imaging Applications with XIElib, 1/e

Syd Logan, Carlsbad, California

Preface

One of the factors contributing to the longevity of the X Window System is the extensibility of the protocol between the client and server. X extensions are the mechanism by which this extensibility is achieved. An X extension is invented, when the need arises, to provide functionality in an area previously unaddressed by the core protocol or an existing X extension. In this way, the X Window System is able to stay current with the technology of the day.

XIE is an X extension that provides long-awaited functionality in the area of image display and enhancement, and has the notable feature that it supports the decompression of several popular image encodings on the server side. This not only relieves the client of the responsibility for decompressing image data, but it also reduces the time that image data takes to travel between the client and the server (or, the other way around, between the server and client).

XIE has yet to take off, even though almost three years have passed since X11R6 and XIE were first released. Perhaps the reason is that the world is still one largely dominated by X11R5. Server vendors usually take a few years to create and release products which are based upon a new release of the X Consortium sample server, and additional time is needed for users to make the switch once these products are made available. However, since there are now a number of X terminals, Macintosh and PC X servers, and workstation X servers that support X11R6 (and therefore, support XIE), this excuse is quickly becoming one that can no longer stand up to scrutiny.

I think the true reason for the current lack of activity surrounding XIE is that, until now, little or no documentation has been available from which developers could learn how to write XIElib clients, not to mention a shortage of sample code. My goal in writing the first edition of this book was to address both of these problems directly.

Book Organization

Chapter 1 introduces the subject of image processing to those readers who may be approaching this discipline for the first time. Chapter 2 provides an overview of image processing using the facilities provided by core X. A sample client that performs median filtering on an image, based upon Xlib APIs, is discussed. Chapter 3 provides an overview of XIE, and discusses motivations that led to its development. It also discusses the architecture of XIE, and then goes on to present the source code of a sample XIE client in detail. Information on how to build the client in a generic Unix environment is also provided. Problems associated with the client that are presented are also described to motivate the discussion of several topics that are presented later in the book, most notably those in Chapter 19. Chapter 4 discusses photoflos and resources in detail, presenting the XIElib API that is used to create, execute, modify, and destroy photoflos as well as work with the various resource types XIE introduces. XieGetClientData, which can be used to read resource, histogram, and image data from the server, is also discussed. Because I/O between the server and a client is, in my opinion, provided at too low of a level by XIElib, and requires a knowledge of XIE event processing to be done successfully, a higher-level routine that is designed to ease this task considerably is presented and discussed in detail. Chapter 5 introduces the import element, which is the point at which resource and image data enters a photoflo from the outside world. XIElib provides no facility for reading image data that is embedded in a file format such as TIFF or determining its attributes; Chapter 6 contrasts file formats and image encodings, and provides a detailed overview of the TIFF file format. Programming tasks related to file formats that the XIElib programmer must address are clearly defined. Routines that can be used to read and write CCITT FAX image data from and to TIFF files, as well as readers and writers for PPM, PGM, and JFIF (JPEG) file formats, are provided on the CD that accompanies this book. Chapter 7 describes XIE's export elements in detail. Export elements are used to write image and resource data from a photoflo to a resource, or make it available for reading by the client. Chapters 8, 9, 10, and 11 discuss process elements. After one is familiar with XIElib programming a bit, these four chapters can be used as a reference to the XIElib APIs that can be used to add process elements to a photoflo graph. Chapter 12 introduces the reader to the various events and errors that are defined by XIE. An overview of error and event handling in Xlib and Xt is provided. Strategies for dealing with events and errors in XIElib clients are then presented. Chapters 13 through 18 introduce and discuss XIE techniques. Techniques allow a client to specify the algorithm that is to be used by a photoflo element when performing its task. For example, the Dither process element supports both error-diffusion and ordered dither techniques. Chapter 15 provides a detailed discussion of colorspaces as related to the colorspace conversion techniques that are supported by XIE. Chapters 16 and 17 describe the various image encode and decode techniques supported by the ImportClientPhoto and ExportClientPhoto elements, with Chapter 17 devoted exclusively to a discussion of JPEG. Chapter 18 discusses Geometry techniques; significant portions of this chapter were taken from the XIE Protocol Specification and edited where necessary. Finally, Chapter 19 discusses the important topic of preparing image data for display in an X window of an arbitrary visual class and depth. Code is developed in this chapter that can, when given information about the image data that is to be displayed and the visual class and depth of the window into which it will be rendered, append the appropriate process elements to the end of a photoflo graph in order for the image to display correctly. Appendices are also provided following Chapter 19.

Source Code CD

A CD with source code is provided with this book. Release notes and descriptions of each client are provided in the file named README. Current versions of the software are available via FTP from my Web site located at http://www.users.cts.com/crash/s/slogan.

Acknowledgments

A book like this cannot be written without the help of others.

Bob Shelley, the author of the XIE protocol, as well as the architect of the X11R6 XIE-SI while at AGE Logic, was kind enough to carefully review significant portions of this manuscript. His comments led to the discovery of many errors in an early draft of the book, for which I am most grateful. Similar thanks go to Larry Hare, another member of the XIE-SI team, who was a constant source of constructive criticism, inspiration, and guidance during the XIE-SI project. Daniel Dardailler (formerly of the X Consortium) and Greg Baxes both provided useful comments after reading an early version of the manuscript. Al Tabayoyon also provided a careful review of an early draft of the chapter that deals with colorspace conversions, for which I am grateful.

Dr. J. Ben Fahy was an active participant in the design of the 5.0 protocol, and was responsible for the material in the XIE 5.0 Protocol Specification that describes the Geometry sample techniques. Major portions of that material were edited by me and included in Chapter 18 of this book. Ben, along with Drs. Dean Verheiden and Gary Rogers, the remaining members of the XIE-SI development team at AGE Logic, deserve my thanks for helping me to learn various aspects of XIE. Robert Alford, former Vice President of Engineering at AGE Logic, deserves special thanks for believing in my capabilities, and for allowing me to participate as a member of the XIE-SI team.

I'd also like to thank Greg Doench of Prentice Hall, for taking the time to talk with me about my ideas for a book (ideas that came to me moments after I strolled past the Prentice Hall booth at X World '94 in New York), for considering my formal proposal that followed, and for consenting to the project that led to this book. Mary Treacy and Leabe Berman, Greg's editorial assistants, handled my numerous phone calls and e-mail queries graciously.

The production editor for this project, Mary Sudul, was responsible for getting the manuscript into good shape prior to its publication, and deserves thanks for her efforts. Christina Carroll was the copyeditor for the book. Christina was inhumanly thorough in her critique of the manuscript, which I appreciate (I think :-). I can only hope that while reading my manuscript she learned as much about XIE as I learned about punctuation, grammar, capitalization, and so forth, while reviewing her comments. Lisa Iarkowski skillfully guided the book and CD-ROM through the final review process.

My family (Mom, Dad, and Rod) deserve many thanks for their support. I'd also like to thank Nguyen Hoang and her cat, "Mr. Meo" for their patience and understanding, especially for the many evenings and weekends that both were forced to spend alone while I put in the long hours needed to complete this project.

I'd like to say a few words about the photographs that were used in this book, as well as the software and equipment that I used to prepare the manuscript.

Most of the photographs in this book were obtained from Corel Photo CDs. Some of the images came from transparencies that were taken by me and later transferred to Photo CD so that they could be read into Adobe Photoshop. Others were scanned from print into Adobe Photoshop using a Microtek ScanMaker E3 scanner. The image of the Piper Tripacer flying over San Diego Bay (Chapter 19) was created by Randy Stambook, and I'd like to thank him for allowing me to reproduce his fine work in my book.

On the software side, all of the sample clients were written on a Linux-based system using GNU development tools. The majority of the development work was done on a 486-based system that was running Linux 1.0.9. Late in the project, I upgraded to a Pentium system and to Linux 1.2.13. Microsoft Word 6.0.2 and Adobe Photoshop 2.5 were used in the preparation of the manuscript. The line art was developed using SuperPaint 2.0 (an ancient precursor to Aldus Paint). Manuscript preparation was performed on a Macintosh LC 475. The xv imaging client was used to obtain screen captures and perform format conversions.

I can hardly imagine that the first edition of a book of this length doesn't have at least a few uncaught errors, or cannot be improved in some way. All errors that remain in this book are my responsibility alone. If something seems wrong, or is hard to read, or you have a suggestion, please don't hesitate to let me know; I can be reached on the Internet at slogan@cts.com.

Carlsbad, CA. June, 1997

  • [Return to Syd's Home Page]