Color400DirectPDImpl.mesa
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
Michael Plass, July 13, 1987 8:12:16 pm PDT
This creates PD files for the 400 bpi color thermal transfer printer. It is meant not as a production program, but merely as a testbed for getting the color correction parameters, special colors, etc. debugged. It builds each separation in memory before writing the bits to the PD file, so the resulting file is always about 11 megabytes for each page.
DIRECTORY Convert, Interpress, Imager, PDFileWriter, ImagerPrintContext, ImagerSample, IO, Real, Rope, SF, Vector2, ImagerMemory, ProcessProps, Process, PrintColor;
Color400DirectPDImpl: CEDAR PROGRAM
IMPORTS Interpress, PDFileWriter, ImagerPrintContext, ImagerSample, IO, Real, Rope, ImagerMemory, Convert, ProcessProps
~ BEGIN
ROPE: TYPE ~ Rope.ROPE;
Log: PROC [class: INT, code: ATOM, explanation: ROPE] ~ {
WITH ProcessProps.GetProp[$StdOut] SELECT FROM
msg: IO.STREAM => {
msg.PutRope[
SELECT class FROM
Interpress.classMasterError => "Master Error: ",
Interpress.classMasterWarning => "Master Warning: ",
Interpress.classAppearanceError => "Appearance Error: ",
Interpress.classAppearanceWarning => "Appearance Warning: ",
Interpress.classComment => "Comment: ",
ENDCASE => Rope.Cat["Class ", Convert.RopeFromInt[class], " Error: "]
];
msg.PutRope[explanation];
msg.PutRope[" . . . "];
};
ENDCASE => NULL;
};
pixelsPerHalftoneDot: REAL ← 7;
writePD: BOOLTRUE;
InterpressToPD: PROC [inputName, outputName: ROPE] ~ {
interpress: Interpress.Master ~ Interpress.Open[fileName: inputName, log: Log];
size: SF.Vec ~ [s: Real.Round[13.75*400], f: Real.Round[10.24*400]];
bitmap: ImagerSample.RasterSampleMap ~ ImagerSample.ObtainScratchMap[box: [max: size]];
context: Imager.Context ~ ImagerPrintContext.SimpleCreate[deviceSpaceSize: size, scanMode: [slow: down, fast: right], surfaceUnitsPerInch: [400, 400], logicalDevice: 9, pixelsPerHalftoneDot: pixelsPerHalftoneDot, toners: [black: TRUE, cyan: TRUE, magenta: TRUE, yellow: TRUE]];
bandSSize: NAT ← 50;
wordsPerLine: CARDINAL ~ (INT[size.f]+BITS[WORD]-1)/BITS[WORD];
bitsPerLine: NAT ~ wordsPerLine*BITS[WORD];
pdState: PDFileWriter.PDState ~ PDFileWriter.Create[fileName: outputName, deviceCode: VAL[9], sResolution: 400, fResolution: 400, imageSSize: size.s, imageFSize: size.f, bandSSize: bandSSize, copies: 1, leftOverMode: FALSE, maxLoadWords: 0];
pdTonerForPass: ARRAY [0..4) OF PDFileWriter.Toner ~ [yellow, magenta, cyan, black];
tonerForPass: ARRAY [0..4) OF PrintColor.Toner ~ [yellow, magenta, cyan, black];
ropeTonerForPass: ARRAY [0..4) OF Rope.ROPE ~ ["yellow", "magenta", "cyan", "black"];
ImagerPrintContext.SetBitmap[context: context, bitmap: bitmap];
FOR page: INT IN [1..interpress.pages] DO
memory: Imager.Context ~ ImagerMemory.NewMemoryContext[];
Interpress.DoPage[master: interpress, page: page, context: memory, log: Log, copy: 1];
Log[Interpress.classComment, $page, IO.PutFR["page %g", [integer[page]]]];
FOR pass: NAT IN [0..4) DO
tonerSet: PDFileWriter.TonerSet ← ALL[FALSE];
Log[Interpress.classComment, $pass, ropeTonerForPass[pass]];
tonerSet[pdTonerForPass[pass]] ← TRUE;
PDFileWriter.StartImage[pdState: pdState, toners: tonerSet, feed: pass=0, strip: pass=3];
ImagerPrintContext.SetSeparation[context, tonerForPass[pass]];
ImagerSample.Clear[bitmap];
ImagerMemory.Replay[c: memory, into: context];
FOR s: NAT ← 0, s + bandSSize UNTIL s >= size.s DO
sMax: NAT ~ MIN[s+bandSSize, size.s];
sSize: NAT ~ sMax-s;
band: ImagerSample.RasterSampleMap ~ NARROW[ImagerSample.Clip[map: bitmap, box: [min: [s, 0], max: [sMax, size.f]]]];
Deliver: PROC [doLine: PDFileWriter.CaptureScanLineProc] = TRUSTED {
p: LONG POINTER ← ImagerSample.GetBase[band].word;
THROUGH [0..sSize) DO
doLine[p];
p ← p + wordsPerLine;
ENDLOOP;
};
Process.CheckForAbort[];
IF writePD THEN PDFileWriter.MaskSamples[pdState: pdState, sMin: s, fMin: 0, sSize: sSize, fSize: size.f, deliverProc: Deliver];
TRUSTED { ImagerSample.ReleaseDescriptor[band] };
ENDLOOP;
PDFileWriter.EndPage[pdState];
ENDLOOP;
ENDLOOP;
PDFileWriter.Close[pdState: pdState];
ImagerSample.ReleaseScratchMap[bitmap];
};
END.