VI.3

Faster “Pixel-Perfect” Line Clipping

Eker Steven,     Brunel University Uxbridge, United Kingdom

Introduction

This gem considers the problem of “pixel-perfect” line clipping. The task is to generate precisely those pixels of a rasterized line that lie within a given clipping rectangle. This requirement arises naturally in window systems when redrawing an exposed rectangle containing part of a rasterized line. Any pixel imperfection will show up as a discontinuity in the line. Clipping the line to the rectangle, rounding each clipped endpoint to the nearest pixel, and rasterizing the resulting line is not an adequate solution ( Figure 1). Rasterizing the line and then clipping the pixels is inefficient; an improved method is known (Pike ...

Get Graphics Gems V (IBM Version) now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.