ImagerPixel.mesa
Copyright Ó 1985, 1986, 1987, 1991 by Xerox Corporation. All rights reserved.
Michael Plass, August 17, 1991 0:22 am PDT
Doug Wyatt, March 7, 1986 2:41:21 pm PST
DIRECTORY
ImagerSample USING [Function, maxCount, nullFunction, Sample, SampleBuffer, SampleMap],
ImagerTransformation USING [Transformation],
Prop USING [PropList],
SF USING [Box, BoxGenerator, Vec, zeroVec];
ImagerPixel: CEDAR DEFINITIONS
~ BEGIN
Function: TYPE ~ ImagerSample.Function;
maxCount: NAT ~ ImagerSample.maxCount;
nullFunction: Function ~ ImagerSample.nullFunction;
Sample: TYPE ~ ImagerSample.Sample;
SampleBuffer: TYPE ~ ImagerSample.SampleBuffer;
SampleMap: TYPE ~ ImagerSample.SampleMap;
Transformation: TYPE ~ ImagerTransformation.Transformation;
Pixels, PixelBuffers and PixelMaps
PixelProc: TYPE ~ PROC [i: NAT] RETURNS [Sample];
PixelBuffer: TYPE ~ REF PixelBufferRep;
PixelBufferRep: TYPE ~ RECORD [
length: NAT,
sampleBuffers: SEQUENCE samplesPerPixel: NAT OF SampleBuffer
];
NewPixels: PROC [samplesPerPixel: NAT, length: NAT,
scratch: PixelBuffer ¬ NIL] RETURNS [PixelBuffer];
ObtainScratchPixels: PROC [samplesPerPixel: NAT, length: NAT] RETURNS [PixelBuffer];
ReleaseScratchPixels: PROC [pixels: PixelBuffer];
DoWithScratchPixels: PROC [samplesPerPixel: NAT, length: NAT, action: PROC [PixelBuffer]];
PixelMap: TYPE ~ REF PixelMapRep;
PixelMapRep: TYPE ~ RECORD [
propList: Prop.PropList ¬ NIL,
box: SF.Box,
sampleMaps: SEQUENCE samplesPerPixel: NAT OF SampleMap
];
NewPixelMap: PROC [samplesPerPixel: NAT, box: SF.Box, maxSample: PixelProc] RETURNS [PixelMap];
MakePixelMap: PROC [s0, s1, s2, s3, s4: SampleMap ¬ NIL] RETURNS [PixelMap];
Convenience for creating a PixelMap from up to 5 existing SampleMaps. The boxes of the SampleMaps must all be the same.
GetPixels: PROC [self: PixelMap, initIndex: SF.Vec ¬ SF.zeroVec, delta: SF.Vec ¬ [s: 0, f: 1],
pixels: PixelBuffer, start: NAT ¬ 0, count: NAT ¬ maxCount];
Gets a run of pixels from a pixel map into a pixel buffer. The effect is:
FOR i: NAT IN [0..self.samplesPerPixel) DO
self[i].GetSamples[initIndex, delta, pixels[i], start, count];
ENDLOOP;
PutPixels: PROC [self: PixelMap, initIndex: SF.Vec ¬ SF.zeroVec, delta: SF.Vec ¬ [s: 0, f: 1],
pixels: PixelBuffer, start: NAT ¬ 0, count: NAT ¬ maxCount,
function: Function ¬ nullFunction];
Stores a run of pixels into a pixel map from a pixel buffer. The effect is:
FOR i: NAT IN [0..self.samplesPerPixel) DO
self[i].PutSamples[initIndex, delta, pixels[i], start, count, function];
ENDLOOP;
ResampleAction: TYPE ~ PROC [pixels: PixelBuffer, min: SF.Vec];
For output of Resample.
Resample: PROC [self: PixelMap, m: Transformation, interpolate: BOOL,
boxes: SF.BoxGenerator, bounds: SF.Box, action: ResampleAction];
Resamples the image according to the provided transformation, which transforms the coordinates of the source into destination coordinates. The action procedure is called with the PixelBuffer filled with the resampled pixels. If interpolate is TRUE, the values from the source pixels surrounding each transformed point will be averaged together to find the output value; otherwise each result value will be the value of the closest source pixel.
The source PixelMap is considered to be replicated to fill the plane; this should be taken into account particularly when interpolate is TRUE, since the values from the opposite edge may bleed over, even when it was intended that only one instance of the tiled pattern be visible.
The bounds and the boxes are expressed in terms of the destination coordinates.
END.