NewPDFileWriter.mesa
Michael Plass, April 9, 1984 9:57:08 am PST
This interface provides a way of creating a pd (printer-dependent) image file.
DIRECTORY Rope, PDFileFormat;
PDFileWriter: CEDAR DEFINITIONS = BEGIN
PDState: TYPE = REF PDStateRec;
PDStateRec: TYPE;
DeviceCode: TYPE = PDFileFormat.DeviceCode;
Toner: TYPE = PDFileFormat.Toner;
LoadReference: TYPE = NAT;
LoadReferenceRep: TYPE = RECORD [
assignedLoadAddress: INT ← -1,
sSize, fSize: CARDINAL,
data:
SELECT tag: * FROM
samples => [],
tile => [],
runGroup => [],
ENDCASE
];
TFlag: TYPE = {opaque, transparent};
Creating a new PD file.
Create: PROC [fileName: Rope.ROPE, deviceCode: DeviceCode, sResolution, fResolution, imageSSize, imageFSize: CARDINAL, bandSSize: CARDINAL ← 16, copies: CARDINAL ← 1, leftOverMode: BOOLEANTRUE, maxLoadWords: INT ← 60000] RETURNS [pdState: PDState];
SetPriorityImportant: PROC [pdState: PDState, priorityImportant: BOOLEAN]
RETURNS [previousValue: BOOLEAN];
priorityImportant is initially FALSE
TonerSet: TYPE ~ PACKED ARRAY Toner OF InitiallyFalse;
InitiallyFalse: TYPE ~ BOOLEANFALSE;
StartImage: PROC [pdState: PDState, toners: TonerSet ← [black: TRUE], feed, strip: BOOLEANTRUE];
This interface may be used to create color PD files either one layer at a time, or all layers simultaneously. The toners parameter specifies which layers are to be created in the current pass; feed applies to the first of the layers, and strip to the last. The call to StartImage may be omitted if the default parameters suffice.
Callback mechanisms for passing variable length items.
The procedures PutColorSamples, PutMaskSamples, LoadSampleArray, PutMaskRunGroup, and LoadRunGroup require a variable amount of data, perhaps a very large amount. To maintain flexibility, a callback mechanism is used to pass the data into these routines. A PDFileWriter routine takes a delivery routine as a parameter; when it needs the data, it calls the delivery routine, passing it a capture routine to call with each unit of data. Note that it is inadvisable for the delivery routine to make any use of the PDState while it has control.
DeliverRunGroupProc: TYPE = PROC [CaptureRunProc];
CaptureRunProc: TYPE = PROC [sMin, fMin, fSize: CARDINAL];
DeliverSampleArrayProc: TYPE = PROC [CaptureScanLineProc];
CaptureScanLineProc: TYPE = PROC [LONG POINTER];
Extracting information from the handle.
GetBounds: PROC [pdState: PDState] RETURNS [sMax, fMax: CARDINAL];
DoForEachToner: PROC [pdState: PDState, proc: PROC[Toner]];
Calls the proc for each toner being used.
Setting the current color.
SetColorInk: PROC [pdState: PDState, toner: Toner];
SetColorClear: PROC [pdState: PDState, toner: Toner];
SetColorOff: PROC [pdState: PDState, toner: Toner];
Masking commands have no effect for the specified toner until a new color is set for it.
SetColorTile: PROC [pdState: PDState, toner: Toner, tileRef: LoadReference, tFlag: TFlag ← opaque];
Imaging operators.
MaskRectangle: PROC [pdState: PDState, sMin, fMin: CARDINAL, sSize, fSize: CARDINAL];
MaskTrapezoid: PROC [pdState: PDState, sMin, sSize: CARDINAL, fMin, fSize: CARDINAL, fMinLast, fSizeLast: CARDINAL];
MaskSamplesRef: PROC [pdState: PDState, samplesRef: LoadReference, sMin, fMin: CARDINAL];
MaskSamples: PROC [pdState: PDState, sMin, fMin: CARDINAL, sSize, fSize: CARDINAL, deliverProc: DeliverSampleArrayProc];
MaskRunGroupRef: PROC [pdState: PDState, runGroupRef: LoadReference, sMin, fMin: CARDINAL];
MaskRunGroup: PROC [pdState: PDState, deliverProc: DeliverRunGroupProc];
ColorSamples: PROC [pdState: PDState, toner: Toner, sMin, fMin: CARDINAL, sSize, fSize: CARDINAL, deliverProc: DeliverSampleArrayProc, tFlag: TFlag ← opaque];
Load management.
RemainingLoadSize: PROC [pdState: PDState] RETURNS [words: INT];
Tells the amount of load the writer can be sure is available.
LoadRunGroup: PROC [pdState: PDState, deliverProc: DeliverRunGroupProc] RETURNS [loadReference: LoadReference];
LoadContiguousSampleArray: PROC [pdState: PDState, sSize, fSize: CARDINAL, bitsPtr: LONG POINTER] RETURNS [loadReference: LoadReference];
LoadContiguousColorTile: PROC [pdState: PDState, phase: CARDINAL, sMin, fMin: CARDINAL, sSize, fSize: CARDINAL, bitsPtr: LONG POINTER] RETURNS [loadReference: LoadReference];
Terminators.
EndPage: PROC [pdState: PDState];
FlushPage: PROC [pdState: PDState];
In case the client needs to remove a partially-written page. Note that changes to the load are not flushed.
Close: PROC [pdState: PDState];
END.
Changes:
Michael Plass, April 9, 1984: Added StartImage and SetColorOff. nColors removed from Create.