2.16.2 Banding Output

The model used by GDI states that any point on an output device can be written to at any time. This model is easily implemented on vector devices but poses a problem on many dot-matrix devices that cannot scroll backward. Banding provides a solution to this problem.

Banding involves several steps:

1.The application creates a metafile and uses it as an intermediate storage device for the output.

2.Beginning at the top of the metafile, GDI translates a rectangular region (band) of output into device-specific commands, and then sends it to a corresponding job.

3.The application repeats this process until the entire metafile has been converted to bands and the output from these bands has been translated into device-specific commands and stored in a job.

4.The application sends the job to the output device.

When creating a device context, GDI verifies whether the device has banding capabilities. If it does, GDI creates the metafile that will be used during the banding process. To implement banding, you call the necessary output functions and the NEXTBAND escape. The NEXTBAND escape requires a long pointer to a RECT data structure as its output parameter. The device driver copies the coordinates of the next band into this structure. When the entire metafile has been converted into device-specific commands, the driver returns four zeros (0,0,0,0) in the RECT structure.

GDI does the banding for you if your output device has banding capabilities and you call the NEWFRAME escape. Although NEWFRAME requires more memory and is slower, it does simplify the output process. After the application creates each page of output, it calls the NEWFRAME escape. If the device is capable of banding, GDI copies output to a metafile and calls the NEXTBAND escape for you. As discussed earlier, the NEXTBAND escape causes the contents of the metafile to be converted into device-specific commands and to be copied to a corresponding job. If a memory problem occurs or the user terminates a job, the NEWFRAME escape returns a message that defines the error or abort message.