PixelsDoc.tioga
Crow, March 31, 1986 7:38:24 pm PST
PixelsDoc
CEDAR 6.0 — FOR INTERNAL XEROX USE ONLY
Pixels
Pixel Operations on Cedar Displays
Frank Crow
© Copyright 1985 Xerox Corporation. All rights reserved.
Abstract: This package provides basic operations on 2-dimensional arrays of pixels. A pixel consists of an arbitrary number of values (samples) representing the information stored behind a displayed spot, not all of which is necessarily visible to the observer. Operations are provided for reading and writing individual pixels or scan segments. Use of an alpha channel or depth buffer for matting images together is supported, as is scan conversion for thin lines and convex polygons. Polygons may be rendered with constant shading, bilinear shading, or simulated highlights. The package is built on top of ImagerExtras/SampleMapOps.
Created by: Frank Crow
Maintained by: Frank Crow <Crow.pa>
Keywords: pixels, scan conversion, matting, lines, polygons, shading, highlights
XEROX  Xerox Corporation
   Palo Alto Research Center
   3333 Coyote Hill Road
   Palo Alto, California 94304

For Internal Xerox Use Only
1. Pixel Access
PixelBuffers
All operations expecty to use a structure called a PixelBuffer. These may be created in plain memory with a Create call, or imposed on the color display with a GetFromTerminal call or, sometimes imposed on an Imager context using the GetFromImagerContext call. In the case of an imager context, the context must have been created using a compatible device (see some working code for examples).
Operations on PixelBuffers include:
- Fill - fill with constant values.
- Transfer - move the contents of one buffer into another (good for double-buffering).
- Copy - copy part of a buffer into another buffer or itself.
Scan Segments and Pixels
Individual pixels and runs of pixels on a single scan line may be accessed using the following operations:
- GetPixel - returns the set of values stored at a pixel.
- PutPixel - stores a set of values at a pixel.
- GetScanSeg - returns values for a contiguous run of pixels.
- PutScanSeg - stores values for a contiguous run of pixels.
- PixelOp - combines a set of values with all pixels in a rectangular area of the PixelBuffer, logical operations (AND, OR XOR) and matting operations (WriteUnder, WriteOver) are performed, as well as simple writes.
Individual Values
Individual values within a pixel may be accessed using the following operations:
- GetValue - returns one of the values stored at a pixel.
- PutValue - stores one of the values at a pixel.
- ValueOp - combines a value with all corresponding values in a rectangular area of the PixelBuffer, logical operations (AND, OR XOR) are performed, as well as simple writes.
2. Scan Conversion
Spots and Lines
Simple lines are supported vai calls to PutLine. The lines are intended for speed and are therefore drawn only one pixel wide using a variant of Bresenham's algorithm.
Individual pixels may be read or written using GetSpot and PutSpot. The Spot structure holds an arbitrary number of values associated with a given position. In addition to scalar values a spot also carries a property list and a reference to a procedure for converting a subset of its associated values into displayable color values.
Convex Polygons
Convex polygons are put in three classes: Constant colored for representing faceted shapes or 2-d areas (ConstantPoly). Smoothly shaded, using bilinear interpolation, for simulating curved surfaces or creating smoothly varying shades over an area (SmoothPoly). To aid in the visualization of 3-d surfaces, "shiny" shading is supported which calculates an approximation to highlights caused by reflection of simulated light sources in three-space (ShinyPoly). Smooth and Shiny shading support use of a depth buffer for pixel-by-pixel depth comparisons to determine visibility. Constant shading prohibits the use of the depth buffer because it uses bitblt to render scan segments. Therefore, pixel-by-pixel operations would cause an unacceptable bottleneck.
Rendering Modes and Dithering
A few procedures are provided for aiding in the rendering of arbitrary colors on pseudo-color displays. Two standard color maps are supported, (1) the standard map used by the Imager for dithering, and (2) a map implementing a color cube with 6 values for red and blue and 7 values for green:
- DitheredRGB - returns a map table address given an RGB value and a position. Ordered dither is used.
- MappedRGB - returns a map table address calculated directly from an RGB value.
- RGBFromMap - calculates the RGB value which should have produced the supplied map table address.
Different rendering modes a re distinguished by passing an atom as an argument to these procedures. The recognized atoms are:
- $Dithered - uses Imager calls wherever possible, supported by ImagerDitheredDevice.
- $PseudoClr - makes use of the 6 x 7 x 6 color cube color table. The fastest display modes are targeted on this mode.
- $Grey - for smooth shading, matting, or antialiasing using less than 24-bit displays.
- $FullClr - assumes 3 8-bit values for each pixel one each for red, green and blue.
- $Dorado24 - for full color on the Dorado color display. Cobbles up interleaved pixel storage to support the weirdities of the Dorado color board hardware.