DIRECTORY ImagerColor, ImagerDisplayPrivate, ImagerMask, ImagerPixelMap; ImagerDisplayLFImpl: CEDAR PROGRAM IMPORTS ImagerColor, ImagerMask ~ BEGIN Display: TYPE ~ ImagerDisplayPrivate.Display; Color: TYPE ~ ImagerColor.Color; ConstantColor: TYPE ~ ImagerColor.ConstantColor; SampledColor: TYPE ~ ImagerColor.SampledColor; Mask: TYPE ~ ImagerMask.Mask; Data: TYPE ~ REF DataRep; DataRep: TYPE ~ RECORD[ value: CARDINAL, -- for ApplyMaskConstant function: ImagerMask.Function, -- for ApplyMaskConstant or ApplyMaskTile frame: ImagerPixelMap.PixelMap -- the bitmap ]; SetColor: PROC[display: Display, color: Color, vx, vy: INTEGER] ~ { data: Data ~ NARROW[display.data]; SELECT color FROM ImagerColor.black => { data.value _ 1; data.function _ [null, null]; display.ApplyMask _ ApplyMaskConstant; RETURN; }; ImagerColor.white => { data.value _ 0; data.function _ [null, null]; display.ApplyMask _ ApplyMaskConstant; RETURN; }; ImagerColor.XOR => { data.value _ 1; data.function _ [xor, null]; display.ApplyMask _ ApplyMaskConstant; RETURN; }; ENDCASE; ERROR; -- not yet implemented }; ApplyMaskConstant: PROC[display: Display, mask, clipper: Mask, sTranslate, fTranslate: INTEGER] ~ { data: Data ~ NARROW[display.data]; ImagerMask.ApplyConstant[mask: mask, clipper: clipper, dest: data.frame, value: data.value, function: data.function, sTranslate: sTranslate, fTranslate: fTranslate]; }; END. ´ImagerDisplayLFImpl.mesa Copyright c 1984 Xerox Corporation. All rights reserved. Michael Plass, June 19, 1984 1:19:53 pm PDT Doug Wyatt, October 6, 1984 4:03:08 pm PDT Data: TYPE ~ REF DataRep; DataRep: TYPE ~ RECORD[ value: CARDINAL, -- for ApplyMaskConstant tile: ImagerPixelMap.Tile, -- for ApplyMaskTile tileSamples: ImagerColor.SampledColor, -- for ApplyMaskTile function: ImagerMask.Function, -- for ApplyMaskConstant or ApplyMaskTile invertOutput, transparent: BOOL, -- for ApplyMaskHalftone source: PixelArray, -- for ApplyMaskHalftone transformation: Transformation, -- for ApplyMaskHalftone deviceBrick: ImagerHalftone.DeviceBrick _ NIL, -- for ApplyMaskHalftone deviceBrickMaxSampleValue: INT _ -1, frame: ImagerPixelMap.PixelMap -- the bitmap ]; lfBrick: ImagerHalftone.DeviceBrick _ ImagerHalftone.MakeSquareBrick[4, 3, 2, 1, 1, 255]; IntensityFromColor: PROC[c: ConstantColor] RETURNS[REAL] ~ { WITH c SELECT FROM c: REF ImagerColor.ColorRep[constant][gray] => RETURN[c.f]; c: REF ImagerColor.ColorRep[constant][cie] => RETURN[c.Y]; ENDCASE => ERROR; }; SetTileSamples: PROC [tileSamples: SampledColor, intensity: [0..255]] ~ { WITH tileSamples.pa.data SELECT FROM n: REF NAT => n^ _ intensity; ENDCASE => ERROR; }; WITH color SELECT FROM color: ConstantColor => { tile: ImagerPixelMap.Tile ~ data.tile; Runs: PROC[run: PROC[sMin, fMin: INTEGER, fSize: NAT]] ~ { FOR s: INTEGER IN [tile.sOrigin..tile.sOrigin + tile.sSize) DO run[s, tile.fOrigin, tile.fSize]; ENDLOOP; }; SetTileSamples[data.tileSamples, Real.RoundC[IntensityFromColor[color]*255]]; ImagerHalftone.Halftone[ dest: [sOrigin: tile.sOrigin, fOrigin: tile.fOrigin, sMin: 0, fMin: 0, sSize: tile.sSize, fSize: tile.fSize, refRep: tile.refRep], runs: Runs, source: data.tileSamples.pa, transformation: ImagerTransformation.Rotate[0], deviceBrick: lfBrick ]; tile.sOrigin _ tile.sOrigin + SurfaceOriginS[data]-vy; tile.fOrigin _ tile.fOrigin + vx; data.function _ [null, null]; display.ApplyMask _ ApplyMaskTile; }; color: SampledColor => { pa: PixelArray ~ color.pa; data.source _ pa; data.transformation^ _ display.surfaceToDevice^; data.transformation.PreTranslate[vx, vy]; -- view to device data.transformation.PreMultiply[color.m]; -- color to device data.transformation.PreMultiply[pa.m]; -- pa to device IF data.deviceBrickMaxSampleValue#pa.maxSampleValue THEN { data.deviceBrickMaxSampleValue _ pa.maxSampleValue; data.deviceBrick _ ImagerHalftone.MakeSquareBrick[4, 3, 2, 1, 1, pa.maxSampleValue]; }; SELECT color.colorOperator FROM $SampledBlack => data.invertOutput _ TRUE; $Intensity => data.invertOutput _ FALSE; ENDCASE => Imager.Error[$UnknownColorModel]; data.transparent _ color.transparent; display.ApplyMask _ ApplyMaskHalftone; }; color: SpecialColor => { WITH color.ref SELECT FROM stipple: REF CARDINAL => { data.tile _ ImagerPixelMaps.TileFromStipple[stipple: stipple^, scratch: data.tile.refRep]; data.function _ [null, null]; display.ApplyMask _ ApplyMaskTile; }; ENDCASE => ERROR Imager.Error[$UnknownSpecialColor]; }; ENDCASE => Imager.Error[$Bug]; USING [frame, value, function] ApplyMaskTile: PROC[display: Display, mask, clipper: Mask, sTranslate, fTranslate: INTEGER] ~ { data: Data ~ NARROW[display.data]; USING [frame, tile, function] ImagerMask.ApplyTile[mask: mask, clipper: clipper, dest: data.frame, tile: data.tile, function: data.function, sTranslate: sTranslate, fTranslate: fTranslate]; }; ApplyMaskHalftone: PROC[display: Display, mask, clipper: Mask, sTranslate, fTranslate: INTEGER] ~ { data: Data ~ NARROW[display.data]; USING [frame, source, transformation, deviceBrick, invertOutput, transparent] Runs: PROC[run: PROC[sMin, fMin: INTEGER, fSize: NAT]] ~ { ImagerMask.GenerateRuns[mask, clipper, run, sTranslate, fTranslate]; }; ImagerHalftone.Halftone[dest: data.frame, runs: Runs, source: data.source, transformation: data.transformation, deviceBrick: data.deviceBrick, invertOutput: data.invertOutput, transparent: data.transparent]; }; ImagerPrivate.RegisterDevice[LFDisplayClass]; ʯ˜šœ™Jšœ Ïmœ.™9J™+J™*—J˜šÏk ˜ Jšœ ˜ Jšœ˜Jšœ ˜ Jšœ˜—J˜Jšœžœž˜"Jšžœ˜Jšœž˜J˜Jšœ žœ ˜-Jšœžœ˜ Jšœžœ˜0Jšœžœ˜.Jšœžœ˜J˜Jšœžœžœ ˜šœ žœžœ˜JšœžœÏc˜)JšœŸ)˜HJšœŸ ˜,J˜J˜—Jšœžœžœ ™šœ žœžœ™JšœžœŸ™)JšœŸ™/Jšœ*Ÿ™;JšœŸ)™HJšœžœŸ™9JšœŸ™,Jšœ Ÿ™8Jšœ*žœŸ™GJšœžœ™$JšœŸ ™,J™J™—J˜JšœY™YJ˜šÏnœžœžœžœ™<šžœžœž™Jšœžœ)žœ™;Jšœžœ(žœ™:Jšžœžœ™—J™J™—š œžœ5™Išžœžœž™$Jšœžœžœ™Jšžœžœ™—Jšœ™J™—š œžœ)žœ˜CJšœ žœ˜"šžœž˜šœ˜Jšœ-˜-Jšœ&˜&Jšžœ˜Jšœ˜—šœ˜Jšœ-˜-Jšœ&˜&Jšžœ˜Jšœ˜—šœ žœ˜Jšœ,˜,Jšœ&˜&Jšžœ˜Jšœ˜—Jšžœ˜—JšžœŸ˜šžœžœž™šœ™Jšœ&™&š  œžœžœ žœ žœ™:šžœžœžœ+ž™>Jšœ!™!Jšž™—Jšœ™—JšœM™Mšœ™šœ4™4JšœM™M—Jšœ ™ Jšœ™Jšœ/™/Jšœ™Jšœ™—Jšœ6™6Jšœ!™!Jšœ™Jšœ"™"Jšœ™—šœ™Jšœ™J™J™0Jšœ*Ÿ™;Jšœ*Ÿ™