DIRECTORY CII, CIIPrivate, Imager, ImagerBrick, ImagerDevice, ImagerDeviceInterchange, ImagerDeviceVector, ImagerError, ImagerFourColorContext, ImagerManhattan, ImagerPrintColor, ImagerPrintContext, ImagerPrintDevice, ImagerRaster, ImagerSample, ImagerTransformation, PrintColor, RuntimeError; CIIHalftoneDeviceImpl: PROGRAM IMPORTS CII, CIIPrivate, Imager, ImagerBrick, ImagerDeviceInterchange, ImagerError, ImagerFourColorContext, ImagerManhattan, ImagerPrintContext, ImagerPrintDevice, ImagerRaster, ImagerTransformation, ImagerPrintColor, RuntimeError ~ BEGIN ExternalNames: PROC = MACHINE CODE { "^ExternalNames BWHalftoneDeviceSetup CII_BWHalftoneDeviceSetup CMYKHalftoneDeviceSetup CII_CMYKHalftoneDeviceSetup CMYKHalftoneSeparationDeviceSetup CII_CMYKHalftoneSeparationDeviceSetup "; }; SetupDataRep: TYPE = RECORD [ nRasters: NAT, toners: PrintColor.TonerUniverse ]; RES: TYPE = CII.RES; nilFault: RES = CII.RESFromErrorCode[$nilFault]; bounds: RES = CII.RESFromErrorCode[$bounds]; wrongShape: RES = CII.RESFromErrorCode[$wrongShape]; wrongType: RES = CII.RESFromErrorCode[$wrongType]; defaultDotShape: REAL ¬ 0.48; defaultScreenAngle: ARRAY PrintColor.Toner[black..yellow] OF REAL ¬ [ black: 45, cyan: 75, magenta: 105, yellow: 90 ]; MakeHalftoneProperties: PROC [logicalDevice: PrintColor.LogicalDevice, pixelsPerHalftoneDot: REAL, toners: PrintColor.TonerUniverse] RETURNS [h: PrintColor.HalftoneProperties ¬ NIL] ~ { angle: ARRAY PrintColor.Toner[black..yellow] OF REAL ¬ defaultScreenAngle; FOR t: PrintColor.Toner IN PrintColor.Toner[black..yellow] DO IF toners[t] THEN { angle: REAL ~ defaultScreenAngle[t]; brick: ImagerBrick.Brick ~ ImagerBrick.BrickFromDotScreen[pixelsPerDot: pixelsPerHalftoneDot, degrees: angle, shape: defaultDotShape]; h ¬ CONS[[type: NIL, toner: t, brick: brick], h]; }; ENDLOOP; }; SetSeparationSingle: PROC [h: CII.Handle, toner: CII.Toner] RETURNS [res: RES ¬ ok] = { ENABLE { ImagerError.Error => { res ¬ CII.RESFromErrorCode[error.code]; CONTINUE }; RuntimeError.BoundsFault => { res ¬ bounds; CONTINUE }; RuntimeError.NilFault => { res ¬ nilFault; CONTINUE }; }; state: REF CIIPrivate.StateRep = NARROW[h.data]; deviceColorData: ImagerPrintColor.DeviceColorData = ImagerPrintDevice.GetColorData[state.device]; IF deviceColorData = NIL THEN RETURN [wrongType]; IF toner NOT IN [black..yellow] THEN RETURN [bounds]; ImagerPrintColor.SetSeparation[deviceColorData, VAL[ORD[toner]]]; }; SetOutputBuffersSingle: PROC [h: CII.Handle, nBuffers: INT, outputBuffers: POINTER TO ARRAY [0..0) OF CII.RasterRep] RETURNS [res: CII.RES¬ok] = { ENABLE { ImagerError.Error => { res ¬ CII.RESFromErrorCode[error.code]; CONTINUE }; RuntimeError.BoundsFault => { res ¬ bounds; CONTINUE }; RuntimeError.NilFault => { res ¬ nilFault; CONTINUE }; }; IF nBuffers # 1 THEN RETURN [CII.RESFromErrorCode[$wrongShape]] ELSE { state: REF CIIPrivate.StateRep = NARROW[h.data]; map: ImagerSample.SampleMap = CIIPrivate.MakeSampleMap[@(outputBuffers[0])]; IF ImagerPrintDevice.SetDeviceBitmap[state.device, map].clipperNeedsFixing THEN { CIIPrivate.ValidateClipper[state]; }; }; }; CreateHandleFromRasters: PROC [s: CIIPrivate.SetupHandle, logicalDevice: CARDINAL, nRasters: CARDINAL, rasters: POINTER TO ARRAY [0..0) OF CII.RasterRep, handleResult: POINTER TO CII.Handle] RETURNS [res: CII.RES ¬ ok] = { ENABLE { ImagerError.Error => { res ¬ CII.RESFromErrorCode[error.code]; CONTINUE }; RuntimeError.BoundsFault => { res ¬ bounds; CONTINUE }; RuntimeError.NilFault => { res ¬ nilFault; CONTINUE }; }; shd: CIIPrivate.SetupHandleData = s.data; data: REF SetupDataRep = NARROW[shd.data]; sm: ARRAY [0..4) OF ImagerSample.RasterSampleMap ¬ ALL[NIL]; IF nRasters # data.nRasters THEN RETURN [wrongShape] ELSE { setSeparation: CII.SetSeparationProc ¬ CII.DefaultSetSeparation; setOutputBuffers: CII.SetOutputBuffersProc ¬ CII.DefaultSetOutputBuffers; context: Imager.Context ¬ NIL; halftoneProperties: PrintColor.HalftoneProperties = MakeHalftoneProperties[logicalDevice, 5.656, data.toners]; FOR i: NAT IN [0..nRasters) DO sm[i] ¬ CIIPrivate.MakeSampleMap[@(rasters[i])]; ENDLOOP; SELECT nRasters FROM 1 => { context ¬ ImagerPrintContext.Create[logicalDevice: logicalDevice, deviceSpaceSize: [shd.sSizeDevice, shd.fSizeDevice], scanMode: shd.scanMode, surfaceUnitsPerInch: [shd.surfaceUnitsPerInchX, shd.surfaceUnitsPerInchY], halftoneProperties: halftoneProperties]; ImagerPrintContext.SetSeparation[context, $black]; ImagerPrintContext.SetBitmap[context, sm[0]]; setSeparation ¬ SetSeparationSingle; setOutputBuffers ¬ SetOutputBuffersSingle; }; 4 => { context ¬ ImagerFourColorContext.Create[deviceSpaceSize: [shd.sSizeDevice, shd.fSizeDevice], surfaceUnitsPerInch: [shd.surfaceUnitsPerInchX, shd.surfaceUnitsPerInchY], scanMode: shd.scanMode, logicalDevice: logicalDevice, halftoneProperties: halftoneProperties, correction: NIL, interpolate: FALSE, bitmaps: [sm[0], sm[1], sm[2], sm[3]]]; }; ENDCASE => ERROR; { iState: ImagerDeviceInterchange.InterchangeState ~ ImagerRaster.GetInterchangeState[context]; device: ImagerDevice.Device ~ iState.device; state: REF CIIPrivate.StateRep ~ NEW[CIIPrivate.StateRep ¬ [ device: iState.device, color: Imager.MakeGray[1.0], dcolor: NIL, transformation: ImagerTransformation.Scale[1], viewClipper: NEW[ImagerDevice.DeviceClipperRep ¬ [clipBox: device.state.bounds, clipMask: ImagerManhattan.CreateFromBox[device.state.bounds]]], clientClipper: NIL, cp: NEW[ImagerDeviceVector.DVecRep] ]]; iState.device ¬ NIL; ImagerDeviceInterchange.DestroyInterchangeState[iState]; handleResult­ ¬ CII.MakeHandle[data: state, SetOutputBuffers: setOutputBuffers, SetSeparation: setSeparation]; }; }; }; BWHalftoneDeviceSetup: PROC RETURNS [CIIPrivate.SetupHandle] = { data: REF SetupDataRep = NEW[SetupDataRep ¬ [nRasters: 1, toners: [black: TRUE]]]; RETURN [CIIPrivate.CreateSetupHandle[data: data, CreateHandleFromRasters: CreateHandleFromRasters]] }; CMYKHalftoneDeviceSetup: PROC RETURNS [CIIPrivate.SetupHandle] = { data: REF SetupDataRep = NEW[SetupDataRep ¬ [nRasters: 4, toners: [black: TRUE, cyan: TRUE, magenta: TRUE, yellow: TRUE]]]; RETURN [CIIPrivate.CreateSetupHandle[data: data, CreateHandleFromRasters: CreateHandleFromRasters]] }; CMYKHalftoneSeparationDeviceSetup: PROC RETURNS [CIIPrivate.SetupHandle] = { data: REF SetupDataRep = NEW[SetupDataRep ¬ [nRasters: 1, toners: [black: TRUE, cyan: TRUE, magenta: TRUE, yellow: TRUE]]]; RETURN [CIIPrivate.CreateSetupHandle[data: data, CreateHandleFromRasters: CreateHandleFromRasters]] }; ExternalNames[]; END. Î CIIHalftoneDeviceImpl.mesa Copyright Ó 1993 by Xerox Corporation. All rights reserved. Michael Plass, October 29, 1993 1:09 pm PDT setOutputBuffers ¬ SetOutputBuffersQuad; -- Need more interfacing Ê,•NewlineDelimiter ™code™Kšœ Ïeœ1™