Chapter 1. Introduction

A graphics file format is the format in which graphics data--data describing a graphics image--is stored in a file. Graphics file formats have come about from the need to store, organize, and retrieve graphics data in an efficient and logical way. Sounds like a pretty straightforward task, right? But there's a lot under the covers, and that's what we're going to talk about.

Contents:
The Basics
Graphics Files
Graphics Data
Types of Graphics File Formats
Elements of a Graphics File
Converting Formats
Compressing Data
Format Summary

File formats can be complex. Of course they never seem complex until you're actually trying to implement one in software. They're also important, in ways that often aren't obvious. You'll find, for instance, that the way a block of data is stored is usually the single most important factor governing the speed with which it can be read, the space it takes up on disk, and the ease with which it can be accessed by an application. A program simply must save its data in a reasonable format. Otherwise, it runs the risk of being considered useless.

Practically every major application creates and stores some form of graphics data. Even the simplest character-mode text editors allow the creation of files containing line drawings made from ASCII characters or terminal escape sequences. Graphical user interface (GUI)-based applications, which have proliferated in recent years, now need to support hybrid formats to allow the incorporation of bitmap data in text documents. Database programs with image extensions also let you store text and bitmap data together in a single file. In addition, graphics files are an important transport mechanism that allows the interchange of visual data between software applications and computer systems.

There is currently a great deal of work being done on object-based file systems, where a "data file" may appear as a cluster of otherwise unrelated elements and may be just as likely to incorporate graphics data as not. Clearly, traditional data classification schemes are in need of revision. Nevertheless, there will remain an enormous amount of graphics data accessible only by virtue of our ability to decode and manipulate the files we find around us today.

The Basics

Before we explore the details of any particular file formats, we first need to establish some basic background and terminology. Because we're assuming you have a general working knowledge of computers and know some programming, we'll start with some definitions. You'll find that we've simplified and condensed some of the terminology found in standard computer graphics references. The changes, however, always reflect modern usage. (You'll find a discussion of our rationale in the Preface.)

In what follows, we will be speaking of the output of a computer graphics process, or the production of a graphic work by a program. We don't mean to seem anthropomorphic here. The author of the work is usually human, of course, but his or her contribution is input from the point of view of this book. We're mainly concerned about the portion of the output that comes from a program and winds up in a file. Because the program is the last thing that "touches" the data before it winds up on disk or tape, we say that a graphic work is produced by a program, rather than by a human being. (In this case, we are referring to the form in which the data is stored, and not its meaning or content.)

Graphics and Computer Graphics

Traditionally, graphics refers to the production of a visual representation of a real or imaginary object created by methods known to graphic artists, such as writing, painting, imprinting, and etching. The final result of the traditional graphics production process eventually appears on a 2D surface, such as paper or canvas. Computer graphics, however, has expanded the meaning of graphics to include any data intended for display on an output device, such as a screen, printer, plotter, film recorder, or videotape.

Notice what's happened here. Graphics used to refer to the actual output, something you could see. Now it means something only intended for display, or something meant to be turned into output. This distinction may seem silly to experienced users, but we've watched artists new to computers struggle with this. Where is the graphic output from a paint program? Does it appear as you compose something on the screen? Where is the representation when you write your work to a file? Does it appear for the first time when another program displays it on a screen or paper?

In the practice of computer graphics, creation of a work is often separate from its representation. One way to put it is that a computer graphics process produces virtual output in memory, or persistent output in a file on permanent media, such as a disk or tape. In other words, even though a program has written a file full of something, output doesn't yet exist from a traditional point of view because nothing has been displayed anywhere. So we say that graphics data is the virtual output of a program, from which a representation of the work can be constructed, or can be reconstructed from the persistent graphics data saved to a file, possibly by the same program.

Rendering and Images

In the interest of clarity, most people make a distinction between creation and rendering (sometimes also called realization). Traditionally, an image is a visual representation of a real-world object, captured by an artist through the use of some sort of mechanical, electronic, or photographic process. In computer graphics, the meaning of an image has been broadened somewhat to refer to an object that appears on an output device. Graphics data is rendered when a program draws an image on an output device.

You will also occasionally hear people speak of the computer graphics production pipeline. This is the series of steps involved in defining and creating graphics data and rendering an image. On one end of the production pipeline is a human being; on the other end is an image on paper, screen, or another device. Figure 1-1 illustrates this process.

Figure 1-1: The graphics production pipeline

[Graphic: Figure 1-1]



Copyright © 1996, 1994 O'Reilly & Associates, Inc. All Rights Reserved.

Hosted by uCoz