ImagerPixelArray.mesa
Copyright © 1984, 1985 by Xerox Corporation. All rights reserved.
Michael Plass, August 1, 1984 9:59:33 am PDT
Doug Wyatt, May 19, 1985 2:49:54 pm PDT
DIRECTORY
ImagerPixelArrayDefs USING [PixelArray],
ImagerPixelMap USING [PixelMap],
ImagerSample USING [SampleBuffer, Sample, UnsafeSamples],
ImagerTransformation USING [Transformation],
PrincOps USING [BitAddress, DstFunc, SrcFunc],
Rope USING [ROPE];
ImagerPixelArray: CEDAR DEFINITIONS
~ BEGIN
PixelMap: TYPE ~ ImagerPixelMap.PixelMap;
Transformation: TYPE ~ ImagerTransformation.Transformation;
ROPE: TYPE ~ Rope.ROPE;
Basic operations
PixelArray: TYPE ~ ImagerPixelArrayDefs.PixelArray;
The pixel array contains sSize*fSize pixels, samplesPerPixel*sSize*fSize samples.
A sample is named by a triple: i IN[0..samplesPerPixel), s IN[0..sSize), f IN[0..fSize).
Sample: TYPE ~ ImagerSample.Sample;
UnsafeSamples: TYPE ~ ImagerSample.UnsafeSamples;
SampleBuffer: TYPE ~ ImagerSample.SampleBuffer;
ErrorDesc: TYPE ~ RECORD [code: ATOM, explanation: ROPE];
Error: ERROR [error: ErrorDesc];
GetClass: PROC [pa: PixelArray] RETURNS [ATOM];
... returns an ATOM that identifies the PixelArray's class.
MaxSampleValue: PROC [pa: PixelArray, i: NAT] RETURNS [Sample];
... returns the maximum sample value for the ith sample.
For all i IN[0..pa.samplesPerPixel), s IN[0..pa.sSize), f IN[0..pa.fSize):
pa.GetSample[i, s, f] IN[0..pa.MaxSampleValue[i]].
GetSample: PROC [pa: PixelArray, i: NAT, s, f: INT] RETURNS [Sample];
... returns the sample value with indices [i, s, f].
! BoundsFault if i ~IN[0..pa.samplesPerPixel) OR s ~IN[0..pa.sSize) OR f ~IN[0..pa.fSize).
UnsafeGetSamples: UNSAFE PROC [pa: PixelArray, i: NAT, s, f: INT,
samples: UnsafeSamples, count: NAT];
... fetches a run of samples into raw storage; same effect as the following, but faster:
FOR k: NAT IN[0..count) DO samples[k] ← GetSample[pa, i, s, f+k] ENDLOOP
! BoundsFault if any index into pa is out of range
GetSamples: PROC [pa: PixelArray, i: NAT, s, f: INT,
buffer: SampleBuffer, bi, bj: NAT ← 0, count: NAT];
... fetches a run of samples into a buffer; same effect as the following, but faster:
FOR k: NAT IN[0..count) DO buffer.PutSample[bi, bj+k, GetSample[pa, i, s, f+k]] ENDLOOP
! BoundsFault if any index into pa is out of range
GetPixels: PROC [pa: PixelArray, s, f: INT,
buffer: SampleBuffer, bj: NAT ← 0, count: NAT];
... fetches a run of pixels into a buffer; same effect as the following, but faster:
FOR i: NAT IN[0..pa.samplesPerPixel) DO GetSamples[pa, i, s, f, buffer, i, bj, count] ENDLOOP
! BoundsFault if any index into pa or samples is out of range
UnsafeGetBits: UNSAFE PROC [pa: PixelArray, i: NAT ← 0, s, f: INT,
dst: PrincOps.BitAddress, dstBpl: INTEGER, width, height: CARDINAL,
srcFunc: PrincOps.SrcFunc ← null, dstFunc: PrincOps.DstFunc ← null];
... does a BITBLT-like transfer of samples [i, [s..s+height), [f..f+width)].
! Error[[$samplesTooBig, ...]] if pa.MaxSampleValue[i]>1
! BoundsFault if any sample index is out of range
Creating pixel arrays
Extract: PROC [old: PixelArray, samplesPerPixel: NAT, select: PROC [NAT] RETURNS [NAT]]
RETURNS
[new: PixelArray];
... extracts selected sample layers from a pixel array.
new.samplesPerPixel = samplesPerPixel
new.sSize = old.sSize, new.fSize = old.fSize
ImagerTransformation.Equal[new.m, old.m]
new.MaxSampleValue[i] = old.MaxSampleValue[select[i]]
new.GetSample[i, s, f] = old.GetSample[select[i], s, f]
! BoundsFault if for any i IN[0..samplesPerPixel), select[i] ~IN[0..pa.samplesPerPixel).
Join: PROC [list: LIST OF PixelArray] RETURNS [PixelArray];
Join3: PROC [pa1, pa2, pa3: PixelArray] RETURNS [PixelArray];
... joins multiple sample planes into one PixelArray.
! Error[[$incompatibleJoin, ...]] if sizes or transformations do not match.
FromAIS: PROC [name: ROPE] RETURNS [PixelArray];
... makes a pixel array from an AIS file with the specified name.
! FS.Error if the named file cannot be opened.
! Error[[$malformedAISFile, ...]] if the file is not a valid AIS file.
Join3AIS: PROC [name1, name2, name3: ROPE] RETURNS [PixelArray];
A convenience, equivalent to Join3[FromAIS[name1], FromAIS[name2], FromAIS[name3]].
! FS.Error or Error, as for FromAIS or Join.
END.