DIRECTORY Imager USING [Box, Context, ErrorCode, IntKey, RealKey, StrokeStyle], ImagerColor USING [Color, ColorOperator, ColorOperatorRep, MakeGray], ImagerFont USING [Char, CharSet, Font, MapRope, MapText], ImagerPath USING [Clipper, PathProc], ImagerPixelArray USING [PixelArray], ImagerTransformation USING [Transformation], Prop USING [Get, PropList, Put, Rem], Rope USING [ROPE], Vector2 USING [VEC]; ImagerImpl: CEDAR PROGRAM IMPORTS ImagerColor, ImagerFont, Prop EXPORTS Imager ~ BEGIN BYTE: TYPE ~ [0..377B]; ROPE: TYPE ~ Rope.ROPE; Char: TYPE ~ ImagerFont.Char; CharSet: TYPE ~ ImagerFont.CharSet; Font: TYPE ~ ImagerFont.Font; VEC: TYPE ~ Vector2.VEC; Transformation: TYPE ~ ImagerTransformation.Transformation; Color: TYPE ~ ImagerColor.Color; ColorOperator: TYPE ~ ImagerColor.ColorOperator; ColorOperatorRep: TYPE ~ ImagerColor.ColorOperatorRep; PixelArray: TYPE ~ ImagerPixelArray.PixelArray; PathProc: TYPE ~ ImagerPath.PathProc; Clipper: TYPE ~ ImagerPath.Clipper; Context: TYPE ~ Imager.Context; Error: PUBLIC ERROR[errorCode: Imager.ErrorCode] ~ CODE; DoSave: PUBLIC PROC[context: Context, action: PROC] ~ { props: Prop.PropList ~ context.props; context.class.DoSave[context, action ! UNWIND => context.props _ props]; context.props _ props; }; DoSaveAll: PUBLIC PROC[context: Context, action: PROC] ~ { props: Prop.PropList ~ context.props; context.class.DoSaveAll[context, action ! UNWIND => context.props _ props]; context.props _ props; }; GetProp: PUBLIC PROC[context: Context, key: REF] RETURNS[value: REF] ~ { RETURN[Prop.Get[context.props, key]]; }; PutProp: PUBLIC PROC[context: Context, key: REF, value: REF] ~ { context.props _ Prop.Put[context.props, key, value]; }; RemProp: PUBLIC PROC[context: Context, key: REF] ~ { context.props _ Prop.Rem[context.props, key]; }; ConcatT: PUBLIC PROC[context: Context, m: Transformation] ~ { context.class.ConcatT[context, m]; }; ScaleT: PUBLIC PROC[context: Context, s: REAL] ~ { context.class.Scale2T[context, [s, s]]; }; Scale2T: PUBLIC PROC[context: Context, s: VEC] ~ { context.class.Scale2T[context, s]; }; RotateT: PUBLIC PROC[context: Context, a: REAL] ~ { context.class.RotateT[context, a]; }; TranslateT: PUBLIC PROC[context: Context, t: VEC] ~ { context.class.TranslateT[context, t]; }; Move: PUBLIC PROC[context: Context] ~ { context.class.Move[context]; }; Trans: PUBLIC PROC[context: Context] ~ { context.class.Trans[context]; }; black: PUBLIC Color _ ImagerColor.MakeGray[1]; white: PUBLIC Color _ ImagerColor.MakeGray[0]; SetColor: PUBLIC PROC[context: Context, color: Color] ~ { context.class.SetColor[context, color]; }; SetGray: PUBLIC PROC[context: Context, f: REAL] ~ { context.class.SetGray[context, f]; }; SetSampledColor: PUBLIC PROC[context: Context, pa: PixelArray, m: Transformation, colorOperator: ColorOperator] ~ { context.class.SetSampledColor[context, pa, m, colorOperator]; }; SetSampledBlack: PUBLIC PROC[context: Context, pa: PixelArray, m: Transformation, clear: BOOL _ FALSE] ~ { colorOperator: ColorOperator ~ NEW[ColorOperatorRep.black _ [black[clear: clear]]]; context.class.SetSampledColor[context, pa, m, colorOperator]; }; MaskFill: PUBLIC PROC[context: Context, pathProc: PathProc, pathData: REF] ~ { context.class.MaskFill[context, pathProc, pathData, FALSE]; }; MaskFillParity: PUBLIC PROC[context: Context, pathProc: PathProc, pathData: REF] ~ { context.class.MaskFill[context, pathProc, pathData, TRUE]; }; MaskRectangle: PUBLIC PROC[context: Context, x, y, w, h: REAL] ~ { context.class.MaskRectangle[context, x, y, w, h]; }; MaskBox: PUBLIC PROC[context: Context, box: Imager.Box] ~ { context.class.MaskRectangle[context, box.xmin, box.ymin, box.xmax-box.xmin, box.ymax-box.ymin]; }; SetStrokeWidth: PUBLIC PROC[context: Context, width: REAL] ~ { context.class.SetReal[context, $strokeWidth, width]; }; SetStrokeStyle: PUBLIC PROC[context: Context, style: Imager.StrokeStyle] ~ { context.class.SetInt[context, $strokeStyle, ORD[style.end]+4*ORD[style.joint]]; }; MaskStroke: PUBLIC PROC[context: Context, pathProc: PathProc, pathData: REF] ~ { context.class.MaskStroke[context, pathProc, pathData, FALSE]; }; MaskStrokeClosed: PUBLIC PROC[context: Context, pathProc: PathProc, pathData: REF] ~ { context.class.MaskStroke[context, pathProc, pathData, TRUE]; }; MaskVector: PUBLIC PROC[context: Context, p1, p2: VEC] ~ { context.class.MaskVector[context, p1, p2]; }; MaskPixel: PUBLIC PROC[context: Context, pa: PixelArray] ~ { context.class.MaskPixel[context, pa]; }; MaskBits: PUBLIC PROC[context: Context, base: LONG POINTER, wordsPerLine: NAT, sMin, fMin, sSize, fSize: NAT, sOffset, fOffset: INTEGER] ~ { context.class.MaskBits[context: context, base: base, wordsPerLine: wordsPerLine, sMin: sMin, fMin: fMin, sSize: sSize, fSize: fSize, sOffset: sOffset, fOffset: fOffset]; }; SetPriorityImportant: PUBLIC PROC[context: Context, priorityImportant: BOOL] ~ { context.class.SetInt[context, $priorityImportant, IF priorityImportant THEN 1 ELSE 0]; }; SetNoImage: PUBLIC PROC[context: Context, noImage: BOOL] ~ { context.class.SetInt[context, $noImage, IF noImage THEN 1 ELSE 0]; }; SetXY: PUBLIC PROC[context: Context, p: VEC] ~ { context.class.SetXY[context, p]; }; SetXYRel: PUBLIC PROC[context: Context, v: VEC] ~ { context.class.SetXYRel[context, v]; }; SetXRel: PUBLIC PROC[context: Context, x: REAL] ~ { context.class.SetXYRel[context, [x, 0]]; }; SetYRel: PUBLIC PROC[context: Context, y: REAL] ~ { context.class.SetXYRel[context, [0, y]]; }; SetFont: PUBLIC PROC[context: Context, font: Font] ~ { context.class.SetFont[context, font]; }; Show: PUBLIC PROC[context: Context, chars: PROC[PROC[Char]], xrel: BOOL _ FALSE] ~ { context.class.Show[context, chars, xrel]; }; ShowChar: PUBLIC PROC[context: Context, char: CHAR, set: CharSet _ 0] ~ { chars: PROC[action: PROC[Char]] ~ { action[set*256+ORD[char]] }; context.class.Show[context, chars, FALSE]; }; ShowRope: PUBLIC PROC[context: Context, rope: ROPE, start: INT _ 0, len: INT _ INT.LAST, set: CharSet _ 0] ~ { chars: PROC[action: PROC[Char]] ~ { ImagerFont.MapRope[action, rope, start, len, set] }; context.class.Show[context, chars, FALSE]; }; ShowText: PUBLIC PROC[context: Context, text: REF READONLY TEXT, start: NAT _ 0, len: NAT _ NAT.LAST, set: CharSet _ 0] ~ { chars: PROC[action: PROC[Char]] ~ { ImagerFont.MapText[action, text, start, len, set] }; context.class.Show[context, chars, FALSE]; }; SetAmplifySpace: PUBLIC PROC[context: Context, amplifySpace: REAL] ~ { context.class.SetReal[context, $amplifySpace, amplifySpace]; }; StartUnderline: PUBLIC PROC[context: Context] ~ { context.class.StartUnderline[context]; }; MaskUnderline: PUBLIC PROC[context: Context, dy, h: REAL] ~ { context.class.MaskUnderline[context, dy, h]; }; CorrectMask: PUBLIC PROC[context: Context] ~ { context.class.CorrectMask[context]; }; CorrectSpace: PUBLIC PROC[context: Context, v: VEC] ~ { context.class.CorrectSpace[context, v]; }; Space: PUBLIC PROC[context: Context, x: REAL] ~ { context.class.Space[context, x]; }; SetCorrectMeasure: PUBLIC PROC[context: Context, v: VEC] ~ { context.class.SetCorrectMeasure[context, v]; }; SetCorrectTolerance: PUBLIC PROC[context: Context, v: VEC] ~ { context.class.SetCorrectTolerance[context, v]; }; SetCorrectShrink: PUBLIC PROC[context: Context, correctShrink: REAL] ~ { context.class.SetReal[context, $correctShrink, correctShrink]; }; Correct: PUBLIC PROC[context: Context, action: PROC] ~ { context.class.Correct[context, action]; }; ClipOutline: PUBLIC PROC[context: Context, pathProc: PathProc, pathData: REF] ~ { context.class.ClipOutline[context, pathProc, pathData, FALSE]; }; ExcludeOutline: PUBLIC PROC[context: Context, pathProc: PathProc, pathData: REF] ~ { context.class.ClipOutline[context, pathProc, pathData, TRUE]; }; ClipRectangle: PUBLIC PROC[context: Context, x, y, w, h: REAL] ~ { context.class.ClipRectangle[context, x, y, w, h, FALSE]; }; ExcludeRectangle: PUBLIC PROC[context: Context, x, y, w, h: REAL] ~ { context.class.ClipRectangle[context, x, y, w, h, TRUE]; }; SetT: PUBLIC PROC[context: Context, m: Transformation] ~ { context.class.SetT[context, m]; }; SetClipper: PUBLIC PROC[context: Context, clipper: Clipper] ~ { context.class.SetClipper[context, clipper]; }; SetReal: PUBLIC PROC[context: Context, key: Imager.RealKey, value: REAL] ~ { context.class.SetReal[context, key, value]; }; SetInt: PUBLIC PROC[context: Context, key: Imager.IntKey, value: INT] ~ { context.class.SetInt[context, key, value]; }; GetT: PUBLIC PROC[context: Context] RETURNS[Transformation] ~ { RETURN[context.class.GetT[context]]; }; GetFont: PUBLIC PROC[context: Context] RETURNS[Font] ~ { RETURN[context.class.GetFont[context]]; }; GetColor: PUBLIC PROC[context: Context] RETURNS[Color] ~ { RETURN[context.class.GetColor[context]]; }; GetClipper: PUBLIC PROC[context: Context] RETURNS[Clipper] ~ { RETURN[context.class.GetClipper[context]]; }; GetReal: PUBLIC PROC[context: Context, key: Imager.RealKey] RETURNS[REAL] ~ { RETURN[context.class.GetReal[context, key]]; }; GetInt: PUBLIC PROC[context: Context, key: Imager.IntKey] RETURNS[INT] ~ { RETURN[context.class.GetInt[context, key]]; }; GetCP: PUBLIC PROC[context: Context] RETURNS[VEC] ~ { RETURN[context.class.GetCP[context, FALSE]]; }; GetCPRounded: PUBLIC PROC[context: Context] RETURNS[VEC] ~ { RETURN[context.class.GetCP[context, TRUE]]; }; END. tImagerImpl.mesa Copyright c 1984, Xerox Corporation. All rights reserved. Michael Plass, February 20, 1984 9:15:15 am PST Doug Wyatt, November 30, 1984 2:02:34 pm PST MakePixelArrayFromBits: PUBLIC PROC[ bitPointer: LONG POINTER TO PACKED ARRAY [0..0) OF [0..1], bitsPerLine, samplesPerLine, numberOfLines: NAT] RETURNS [pixelArray: PixelArray] ~ TRUSTED { pixelMap: ImagerPixelMap.PixelMap _ ImagerPixelMap.Create[0, [0, 0, numberOfLines, samplesPerLine]]; bbTableSpace: PrincOps.BBTableSpace; bb: PrincOps.BBptr ~ PrincOpsUtils.AlignedBBTable[@bbTableSpace]; bb^ _ [ dst: [word: pixelMap.refRep.pointer, bit: 0], dstBpl: pixelMap.refRep.rast*Basics.bitsPerWord, src: [word: bitPointer, bit: 0], srcDesc: [srcBpl[bitsPerLine]], height: numberOfLines, width: samplesPerLine, flags: [direction: forward, disjoint: TRUE, disjointItems: TRUE, gray: FALSE, srcFunc: null, dstFunc: null] ]; PrincOpsUtils.BITBLT[bb]; pixelArray _ ImagerMask.PixelArrayFromPixelMap[pixelMap]; pixelArray.m.PostRotate[-90]; pixelArray.m.PostTranslate[0, numberOfLines]; }; DrawBitmap: PUBLIC PROC[context: Imager.Context, pa: Imager.PixelArray, x, y: REAL] ~ { action: PROC ~ { Imager.SetXY[context, [x, y]]; Imager.Trans[context]; Imager.SetSampledBlack[context, pa]; Imager.ConcatT[context, pa.m]; Imager.MaskRectangle[context, 0, 0, pa.sPixels, pa.fPixels]; }; Imager.DoSave[context, action]; }; Ê ³˜šœ™Jšœ Ïmœ/™:J™/Jšœ,™,J™—šÏk ˜ Jšœžœ9˜EJšœ žœ4˜EJšœ žœ)˜9Jšœ žœ˜%Jšœžœ˜$Jšœžœ˜,Jšœžœ˜%Jšœžœžœ˜Jšœžœžœ˜J˜—Jšœ žœž˜Jšžœ˜%Jšžœ˜Jšœž˜J˜Jšžœžœ ˜Jšžœžœžœ˜Jšœžœ˜Jšœ žœ˜#Jšœžœ˜Jšžœžœ žœ˜Jšœžœ'˜;Jšœžœ˜ Jšœžœ˜0Jšœžœ ˜6Jšœ žœ˜/Jšœ žœ˜%Jšœ žœ˜#J˜Jšœ žœ˜J˜Jšœžœžœ žœ˜8J˜šÏnœžœžœžœ˜7Jšœ%˜%Jšœ'žœ˜HJšœ˜J˜J˜—šŸ œžœžœžœ˜:Jšœ%˜%Jšœ*žœ˜KJšœ˜J˜J˜—J˜š Ÿœžœžœžœžœžœ˜HJšžœ˜%J˜J˜—š Ÿœžœžœžœ žœ˜@Jšœ4˜4J˜J˜—šŸœžœžœžœ˜4Jšœ-˜-Jšœ˜J˜—J˜šŸœžœžœ)˜=J˜"J˜J˜—šŸœžœžœžœ˜2Jšœ'˜'J˜J™—šŸœžœžœžœ˜2Jšœ"˜"J˜J˜—šŸœžœžœžœ˜3Jšœ"˜"J˜J˜—šŸ œžœžœžœ˜5Jšœ%˜%J˜J™—šŸœžœžœ˜'Jšœ˜J˜J™—šŸœžœžœ˜(Jšœ˜J˜J˜—J˜Jšœžœ!˜.šœžœ!˜.J˜—šŸœžœžœ$˜9Jšœ'˜'J˜J˜—šŸœžœžœžœ˜3Jšœ"˜"J˜J˜—šŸœžœžœ˜.JšœD˜DJšœ=˜=J˜J˜—šŸœžœžœ˜.Jšœ*žœžœ˜;Jšœžœ1˜SJšœ=˜=J˜J˜—J˜šŸœžœžœ1žœ˜NJšœ4žœ˜;J˜J˜—šŸœžœžœ1žœ˜TJšœ4žœ˜:J˜J˜—šŸ œžœžœžœ˜BJšœ1˜1J˜J™—šŸœžœžœ'˜;šœ$˜$Jšœ:˜:—J˜J™—šŸœžœžœžœ˜>Jšœ4˜4J˜J˜—šŸœžœžœ1˜LJšœ,žœžœ˜OJ˜J˜—šŸ œžœžœ1žœ˜PJšœ6žœ˜=J˜J™—šŸœžœžœ1žœ˜VJšœ6žœ˜Jšœ.˜.J˜J˜—šŸœžœžœ"žœ˜HJšœ>˜>J˜J˜—šŸœžœžœžœ˜8Jšœ'˜'J˜J˜—˜J˜—šŸ œžœžœ1žœ˜QJšœ7žœ˜>J˜J˜—šŸœžœžœ1žœ˜TJšœ7žœ˜=J˜J˜—šŸ œžœžœžœ˜BJšœ1žœ˜8J˜J˜—šŸœžœžœžœ˜EJšœ1žœ˜7J˜J˜—J˜šŸœžœžœ)˜:Jšœ˜J˜—šŸ œžœžœ(˜?Jšœ+˜+J˜—šŸœžœžœ/žœ˜LJšœ+˜+J˜—šŸœžœžœ.žœ˜IJšœ*˜*J˜—J˜šŸœžœžœžœ˜?Jšžœ˜$J˜—šŸœžœžœžœ ˜8Jšžœ!˜'J˜—šŸœžœžœžœ ˜:Jšžœ"˜(J˜—šŸ œžœžœžœ ˜>Jšžœ$˜*J˜—š Ÿœžœžœ(žœžœ˜MJšžœ&˜,J˜—š Ÿœžœžœ'žœžœ˜JJšžœ%˜+J˜—J˜š Ÿœžœžœžœžœ˜5Jšžœžœ˜,J˜—š Ÿ œžœžœžœžœ˜