<<>> <> <> <> DIRECTORY Basics, CII, CIIPrivate, Imager, ImagerColor, ImagerDevice, ImagerDeviceInterchange, ImagerDeviceVector, ImagerError, ImagerHighlightContext, ImagerHighlightContextBackdoor, ImagerHighlightContextBackdoorExtras, ImagerManhattan, ImagerRaster, ImagerSample, ImagerTransformation, RuntimeError; CIIHighlightDeviceImpl: PROGRAM IMPORTS CII, CIIPrivate, Imager, ImagerColor, ImagerDeviceInterchange, ImagerError, ImagerHighlightContext, ImagerHighlightContextBackdoorExtras, ImagerManhattan, ImagerRaster, ImagerTransformation, RuntimeError ~ BEGIN ExternalNames: PROC = MACHINE CODE { "^ExternalNames HighlightDeviceSetup CII_HighlightDeviceSetup "; }; SetupDataRep: TYPE = RECORD [ highlight: Imager.ConstantColor ¬ NIL ]; RES: TYPE = CII.RES; nilFault: RES = CII.RESFromErrorCode[$nilFault]; bounds: RES = CII.RESFromErrorCode[$bounds]; wrongType: RES = CII.RESFromErrorCode[$wrongType]; notImplemented: RES = CII.RESFromErrorCode[$notImplemented]; malformedDataFile: RES = CII.RESFromErrorCode[$malformedDataFile]; CString: TYPE = CII.CString; SetColorTable: PROC [h: CII.Handle, name: CString, identification: CString, format: CString, tableBase: POINTER, tableByteLength: CARD, replacementHint: CARD, stampValueResult: POINTER TO CARD] RETURNS [res: RES ¬ ok] = { ENABLE { ImagerError.Error => { res ¬ CII.RESFromErrorCode[error.code]; CONTINUE }; RuntimeError.BoundsFault => { res ¬ bounds; CONTINUE }; RuntimeError.NilFault => { res ¬ nilFault; CONTINUE }; RuntimeError.NarrowRefFault => { res ¬ wrongType; CONTINUE }; }; state: REF CIIPrivate.StateRep = NARROW[h.data]; IF CIIPrivate.MatchCString[format, "BruteForceHighlight"] THEN { IF tableByteLength # BYTES[ImagerHighlightContextBackdoor.ColorLookupArray] THEN RETURN [malformedDataFile]; ImagerHighlightContextBackdoorExtras.DeviceSetColorLookupTable[state.device, NEW[ImagerHighlightContextBackdoor.ColorLookupTableRep ¬ [toner: CIIPrivate.AtomFromCString[name], tablePointer: tableBase]]]; stampValueResult ­ ¬ 0; }; IF CIIPrivate.MatchCString[format, "RGBPictorialMapColor"] THEN { p: POINTER TO Basics.RawBytes = tableBase; IF tableByteLength # 3 THEN RETURN [malformedDataFile]; ImagerHighlightContextBackdoorExtras.DeviceSetHighlight[state.device, ImagerColor.ColorFromRGB[[p[0]/255.0, p[1]/255.0, p[2]/255.0]]]; stampValueResult ­ ¬ 0; }; RETURN CII.DefaultSetColorTable[h, name, identification, format, tableBase, tableByteLength, replacementHint, stampValueResult]; }; 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 }; RuntimeError.NarrowRefFault => { res ¬ wrongType; CONTINUE }; }; shd: CIIPrivate.SetupHandleData = s.data; data: REF SetupDataRep = NARROW[shd.data]; IF nRasters # 1 THEN RETURN [CII.RESFromErrorCode[$wrongShape]] ELSE { map: ImagerSample.SampleMap = CIIPrivate.MakeSampleMap[@(rasters[0])]; context: Imager.Context = ImagerHighlightContext.Create[deviceSpaceSize: [shd.sSizeDevice, shd.fSizeDevice], scanMode: shd.scanMode, surfaceUnitsPerInch: [shd.surfaceUnitsPerInchX, shd.surfaceUnitsPerInchY], pixelUnits: TRUE, fontCacheName: ImagerHighlightContext.classCode, highlight: data.highlight]; ImagerHighlightContext.SetSampleMap[context, map]; { 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, SetColorTable: SetColorTable, SetOutputBuffers: SetOutputBuffers]; }; }; }; SetOutputBuffers: 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 ImagerHighlightContextBackdoorExtras.DeviceSetSampleMap[state.device, map].clipperNeedsFixing THEN { CIIPrivate.ValidateClipper[state] }; }; }; HighlightDeviceSetup: PROC RETURNS [CIIPrivate.SetupHandle] = { data: REF SetupDataRep = NEW[SetupDataRep ¬ [ImagerColor.Find["Xerox/Solid/Red"]]]; RETURN [CIIPrivate.CreateSetupHandle[data: data, CreateHandleFromRasters: CreateHandleFromRasters]] }; ExternalNames[]; END.