What Is Rendering?

Because we will spend a great deal of time talking about rendering, it will be useful to create an operational definition. Rendering is the process of making graphics and images objects appear on an output device. An output device is most often the screen, a printer, or a memory area.

Although that sounds pretty simple, the actual implementation is a fairly involved process. Consider the challenge of rendering a simple blue square or other shape to a monitor. A major problem is that the device space of the monitor is likely to be completely different from the user space that the programmer has used for defining the graphics to be output. This is especially true for an application written for the Internet or an intranet where literally hundreds of different monitors will be the output target of a rendering. Additionally, the user might want to print on any number of printers, each with a different resolution and color palette.

As stated earlier, much of this can remain transparent to the programmer because of the user- and device-space paradigm. Ignoring the details, however, will eventually be limiting. It will become important to understand the rendering process in order to develop a robust graphics and imaging application. This knowledge will prove invaluable when moving onto the JAI as well as the Java 3D and JMF portions of this book.

The rendering process is shown schematically in Figure 2.2. The graphics or images to be rendered begin as defined in user space and undergo a series of transformations in the Graphics2D object (represented by the large box outlined in black) before being output to the device (that is, printer, file, or screen).

Figure 2.2. Rendering steps in Java.


Because this series of steps is so important to our discussion, let's examine it in more detail. Note how we transition from user space to device space as we move through the rendering pipeline.

Determine the Appropriate Rendering Area of the Output Device

This step depends on the graphics object to be rendered. If it is a shape or text, all that is needed is the outline of the shape. The outline is determined by computing a stroke for the shape (basically turning the shape outline into a sequence of primitives). For images, a bounding box is created that surrounds the whole (or parts of the image) to render. Next, the shape or image bounding box is transformed from user space to device space using a set of linear transforms. The proper linear transforms are derived from the manufacturer-supplied drivers of the target device.

Rasterize

Rasterization is the process of turning ideal shapes into a list of pixels. Ultimately, the renderer has to send a stream of values to the output device. A video monitor, for example, scans across the screen, tuning on red, green, or blue guns in sequence. This sequence is determined by rasterization. During the rasterization process, rendering options such as antialiasing and dithering are applied.

Clip the Rendering Operation to Render Only the Desired Parts

After the graphics are transformed to the device space and rasterized, they are clipped. Clipping refers to limiting the rendering to particular portions of the output device.

Determine the Colors to Render and Convert to the Device Color Space

Much as it is necessary to apply a transformation to a shape or image in order to make the rendering compatible with the resolution of the target output device, it is also necessary to transform the colors and paints from user space to the palette of device space. This step includes applying transparency values.

By the time the renderer has completed the second step, the graphics objects have entered device space. The color information still is in user space until this step.

To summarize, rendering is the process of taking the graphics or images that are defined in user space and transforming them into the proper description for a particular output device.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset