Basic Numbers and Shapes
Vec: TYPE = RECORD [x, y: REAL];
IntVec: TYPE = RECORD [x, y: INTEGER];
Edge: TYPE = RECORD [a, b: Vec];
IntEdge: TYPE = RECORD [a, b: IntVec];
Rectangle: TYPE = RECORD [x, y, w, h: REAL];
IntRectangle: TYPE = RECORD [x, y, w, h: INTEGER];
Context
ImagingSpace: TYPE = { client, viewer, device };
Context: TYPE = REF ContextRep; -- Holds the imager state
ContextRep:
TYPE =
RECORD [
procs: Procs,
interactive: BOOLEAN,
device: ImagingDevice,
deviceProcs: DeviceProcs, -- Procedures supplied by device
currentSource: SourceRecord,
currentFont: Font,
currentIntPosition: IntVec, -- CP kept in device space
currentPosition: Vec, -- For those with floating point devices
-- ********* Transformations ************
clientTransform: TransformRecord ← DefaultTransformRecord,
viewerTransform: TransformRecord ← DefaultTransformRecord,
deviceTransform: TransformRecord ← DefaultTransformRecord,
transform: TransformRecord, -- composite transformation
-- ***************** Clipping ***********
clientClipper: ClipperRecord ← DefaultClipperRecord,
viewerClipper: ClipperRecord ← DefaultClipperRecord,
deviceClipper: ClipperRecord ← DefaultClipperRecord,
clipper: ClipperRecord, -- composite clipper
noClipArmed, noClip: BOOLEAN,
data: REF -- Interpretation of this depends on the procs
];
Transformations
TransformType: TYPE = { none, identity, rot90, rot180, rot270, mirrorX, mirrorY, mirror45Deg, mirror135Deg, hard };
TransformRecord:
TYPE =
RECORD [
x, y: INTEGER,
type: TransformType,
transformation: Transformation -- used if type is "hard"
];
DefaultTransformRecord: TransformRecord = [0, 0, identity, NIL];
Transformation: TYPE = REF TransformRep;
TransformRep:
TYPE =
RECORD [
a, b, c, d, e, f: REAL
];
Representation of the transformation matrix
a b 0
c d 0
e f 1 (or tx ty 1)
Clipping
Visibility: TYPE = {visible, partlyVisible, invisible};
ClipperType: TYPE = {none, rectangle, path};
ClipperRecord:
TYPE =
RECORD [
xMin, xMax, yMin, yMax: INTEGER,
type: ClipperType,
clipper: Clipper -- used if type is "path"
];
DefaultClipperRecord: ClipperRecord = [0, 1024, 0, 1024, rectangle, NIL];
Clipper: TYPE = REF ClipperRep;
ClipperRep:
TYPE =
RECORD [
xMin, xMax, yMin, yMax: REAL,
paths: LIST OF RECORD [exclude: BOOLEAN, path: Path]
];
Devices
ImagingDevice: TYPE = ATOM; -- i.e. $LF, $CRT8, $CRT24, $PD, $IP, etc.
InteractiveImagingDevice: TYPE = ATOM; -- i.e. $LF, $CRT8, $CRT24
PxlValue: TYPE = LONG CARDINAL;
ByteSequence: TYPE = REF ByteSequenceRep;
ByteSequenceRep: TYPE = RECORD [PACKED SEQUENCE COMPUTED CARDINAL OF [0..256)];
SetUpProc: TYPE = PROC [] RETURNS [TransformRecord, ClipperRecord, DeviceProcs]; -- get memory, pin it, set the transform, clipper, and device procs
ShutDownProc: TYPE = PROC []; -- free memory
OpenPixelBufferProc: TYPE = PROC [buffer: PixelArray ← NIL] RETURNS [PixelArray]; -- redirect writes for double-buffer
ClosePixelBufferProc: TYPE = PROC []; -- drop pixel buffer ref
RGBtoPixelProc: TYPE = PROC [color: RGBValue] RETURNS [PxlValue]; -- Color to device transform
PixeltoRGBProc: TYPE = PROC [pxlValue: PxlValue] RETURNS [RGBValue];
HilitePxlsProc: TYPE = PROC [area: IntRectangle]; -- Device dependent highlighting scheme
MovePxlsProc: TYPE = PROC [source: IntRectangle, destination: IntVec]; -- move on display
GetPxlsProc: TYPE = PROC [source: IntRectangle] RETURNS [PixelArray];
LoadPxlsProc: TYPE = PROC [source: PixelArray ← NIL, destination: IntVec];
LoadScanSegProc: TYPE = PROC [x, y, length: CARDINAL, segment: ByteSequence];
LoadTrapezoidProc: TYPE = PROC [top, bottom, leftTop, leftBot, rightTop, rightBot: CARDINAL, pxlValue: PxlValue]; -- Scan convert trapezoid, constant color
SetPixelProc: TYPE = PROC [x, y: CARDINAL, pxlValue: PxlValue];
GetPixelProc: TYPE = PROC [x, y: CARDINAL] RETURNS [PxlValue];
DrawLineProc: TYPE = PROC [a, b: IntVec, pxlValue: PxlValue]; -- fast line, constant color
DeviceProcs: TYPE = REF DeviceProcsRec;
DeviceProcsRec:
TYPE =
RECORD[
setUp: SetUpProc,
shutDown: ShutDownProc,
openPixelBuffer: OpenPixelBufferProc,
closePixelBuffer: ClosePixelBufferProc,
RGBtoPixel: RGBtoPixelProc,
pixeltoRGB: PixeltoRGBProc,
hilitePxls: HilitePxlsProc,
movePxls: MovePxlsProc,
getPxls: GetPxlsProc,
loadPxls: LoadPxlsProc,
loadScanSeg: LoadScanSegProc,
loadTrapezoid: LoadTrapezoidProc,
setPixel: SetPixelProc,
getPixel: GetPixelProc,
drawLine: DrawLineProc
]; -- this doesn't seem to help PD and InterPress master devices much, what to do??
Sources
SourceType: TYPE = { black, white, constant, pixelarray, sampled, functional };
RGBValue: TYPE = RECORD [ red, green, blue: REAL];
AISFile: TYPE[1]; -- to be filled in
SourceRecord:
TYPE =
RECORD [
type: SourceType,
color: RGBValue,
pxlValue: PxlValue, -- TYPE = LONG CARDINAL
samples: REF ANY ← NIL -- gets NARROWed by called procedure
];
Sampled Sources - Interpress model
SampleSequence: TYPE = REF SampleSequenceRep;
SampleSequenceRep:
TYPE =
RECORD [
length: NAT,
seq: SEQUENCE maxLength: NAT OF LONG CARDINAL
];
SampledSource: TYPE = REF SampledSourceRep;
SampledSourceRep:
TYPE =
RECORD [
transformation: Transformation,
From the SampledImage's coordinate system to the standard coordinate system.
colorModel: ColorModel,
maximumSampleValue: LONG CARDINAL,
sampledSourceProc:
PROC [sampledSource: SampledSource,
sampleSequence: SampleSequence,
The samples should be appended onto the end of this sequence.
numberOfSamples: NAT,
x0, y0, deltaX, deltaY: INTEGER -- Description of the sample line, in the SampledImage's coordinate system. The delta values tell how to get to the next point.
] ← NIL,
data: REF ANY
];
ColorModel: TYPE = ATOM;
PixelArrays
Pixel arrays are scanned in a standard way. Therefore BitBlt can be used to move them around. They are intended to be the fast form of Sample Arrays.
PixelArray: TYPE = REF PixelArrayRep;
PixelArrayRep:
TYPE =
RECORD [
pixelsPerWord: CARDINAL,
numberOfRows: CARDINAL,
pixelsPerRow: CARDINAL,
array: LONG POINTER, -- pointer to block of memory representing pixels
colorTable: REF -- nil, or pointer to pixel-to-color translation table
];