ImagerExamplesDoc.tioga
Michael Plass, June 27, 1986 9:30:33 am PDT
Imager Examples and Conversion guide
CEDAR 6.1 — FOR INTERNAL XEROX USE ONLY
Imager Examples
Michael F. Plass
© Copyright 1985, 1986 Xerox Corporation. All rights reserved.
Abstract: This package is a guide to the use of the Cedar Imager package, consisting of a collection of examples, useful hints, and a conversion guide to aid in converting packages from earlier Graphics and Imagers to the Cedar 6.1 Imager.
Created by: Michael F. Plass
Maintained by: Michael F. Plass <Plass.pa>
Keywords: image, graphics, font, display, printing, device independence, Interpress, examples
XEROX  Xerox Corporation
   Palo Alto Research Center
   3333 Coyote Hill Road
   Palo Alto, California 94304

For Internal Xerox Use Only
ImagerExamplesImpl
Look at this for some examples of how to use the Imager to do some simple synthetic graphics, and create an Interpress master from them. ImagerExample.cm will run it through its paces.
RandomImagerImpl
A program that stress-tests the Imager. Also makes a flashy demo. To run it continuously, say "RandomImager: to the CommandTool; stop it with the CommandTool's STOP! button. Use the interpreter to change parameters; the following are interesting:
SetGrayImage: PROC [rootName: ROPE];
SetColorImage: PROC [rootName: ROPE];
nfonts: NAT ← 9;
fontName: ARRAY [0..35) OF ROPE;
Converting from Cedar Graphics
Legend:
a => b means a converts directly to b
a ~> b means a converts approximately to b (only trivial changes needed, like renaming parameters)
a ~~> b means a converts to b not trivally, but without great difficulty
a ~~~> b means a converts to b with substantial effort.
a ~~~~ No direct correspondence.
a ~~~~> Consult a wizard.
Graphics:
Graphics.Context => Imager.Context
Graphics.Path ~~> ImagerPath.Trajectory, ImagerPath.Outline
Graphics.FontRef => ImagerFont.Font
Graphics.ImageRef ~~> Imager.Color
Graphics.Box => Imager.Box
Graphics.NewContext => ImagerTerminal.BWContext[InterminalBackdoor.terminal, FALSE]
Graphics.CopyContext ~~~~>
Graphics.GetCP ~> ImagerBackdoor.GetCP
Graphics.SetCP ~> Imager.SetXY
Graphics.NewPath ~~>
Graphics.LastPoint => ImagerPath.LastPoint
Graphics.FlushPath; Graphics.MoveTo ~> ImagerPath.MoveTo
Graphics.LineTo ~> ImagerPath.LineTo
Graphics.CurveTo ~> ImagerPath.CurveTo
Graphics.Rectangle ~~> ImagerPath.LineToX; ImagerPath.LineToY; ImagerPath.LineToX
Graphics.DrawTo ~~> Imager.MaskVector[ImagerBackdoor.GetCP[c], [x, y]]; Imager.SetXYRel[c, [x, y]];
Graphics.DrawStroke ~> Imager.MaskStroke
Graphics.DrawArea ~> Imager.MaskFill
Graphics.DrawBox => Imager.MaskBox, ~~> Imager.MaskRectangleI
Graphics.DrawImage ~> Imager.SetColor; Imager.MaskRectangle
Graphics.Translate ~> Imager.TranslateT
Graphics.Scale ~> Imager.Scale2T, Imager.ScaleT if sx=sy
Graphics.Rotate => Imager.RotateT
Graphics.Concat ~> Imager.ConcatT
Graphics.Map ~~~> ImagerBackdoor.GetT, ImagerTransformation.Concat, ImagerTransformation.Invert, ImagerTransformation.Transform
Graphics.WorldToUser ~~> ImagerBackdoor.GetT; ImagerTransformation.InverseTransform
Graphics.UserToWorld ~~> ImagerBackdoor.GetT; ImagerTransformation.Transform
Graphics.SetColor => Imager.SetColor
Graphics.GetColor => ImagerBackdoor.GetColor
Graphics.SetStipple ~> Imager.SetColor[ImagerBackdoor.MakeStipple[, FALSE]]
Graphics.PaintMode ~~~> ImagerBackdoor.MakeStipple, ImagerBackdoor.invert, Imager.SetColor
Graphics.SetPaintMode ~~~> ImagerBackdoor.MakeStipple, ImagerBackdoor.invert, Imager.SetColor
Graphics.SetFat ~~~~>
Graphics.MakeFont ~~> ImagerFont.Find; ImagerFont.Scale
Graphics.GetDefaultFont ~~~~
Graphics.SetDefaultFont ~~~~
Graphics.DrawRope ~> [Imager.SetFont;] Imager.ShowRope
Graphics.DrawChar => Imager.ShowChar;
Graphics.RopeBox ~> ImagerFont.RopeBoundingBox; ImagerBox.BoxFromExtents
Graphics.RopeWidth ~> ImagerFont.RopeWidth
Graphics.CharBox ~> ImagerBox.BoxFromExtents[ImagerFont.BoundingBox[font, [0, ORD[char]]]];
Graphics.CharWidth ~> ImagerFont.Width[font, [0,ORD[char]]];
Graphics.FontBox ~~> ImagerFont.FontBoundingBox; ImagerBox.BoxFromExtents
Graphics.ClipArea ~~> Imager.Clip
Graphics.ClipBox ~~> Imager.ClipRectangle, ~~> ImagerBackdoor.ViewClipRectangleI
Graphics.IsPointVisible ~~~> ImagerBackdoor.DoIfVisible
Graphics.IsRectangular ~~~> ImagerBackdoor.GetClipper
Graphics.GetBounds => ImagerBackdoor.GetBounds
Graphics.Visible ~~~> ImagerBackdoor.GetClipper
Graphics.Mark ~~~~
Graphics.Save . . . Graphics.Restore ~~~> {proc: PROC ~ { . . . }; Imager.DoSaveAll[context, proc]};
GraphicsBasic.Vec => Vector2.VEC
GraphicsBasic.Transformation => ImagerTransformation.Transformation
GraphicsBasic.Box => Imager.Box
GraphicsBasic.PaintMode ~~~~
GraphicsBasic.Color => Imager.Color
GraphicsBasic.black => Imager.black
GraphicsBasic.white => Imager.white
GraphicsBasic.Texture ~~~> ImagerPixelArray.PixelArray
GraphicsBasic.YMode ~~~~
GraphicsBasic.StrokeEnds => Imager.StrokeEnd
GraphicsBasic.Mark ~~~~
GraphicsBasic.Trap ~~~~
GraphicsBasic.Path ~~~> ImagerPath.Trajectory, ImagerPath.Outline
GraphicsBasic.DeviceRef ~~~~
GraphicsBasic.FontRef ~> ImagerFont.Font
GraphicsBasic.ImageRef ~~> Imager.Color
GraphicsBasic.MapperRef ~~> ImagerTransformation.Transformation
GraphicsBasic.ClipperRef ~~~> ImagerBackdoor.Clipper
GraphicsOps.BitmapRef ~~~> ImagerPixelMap.PixelMap
GraphicsOps.NewBitmap ~~~> ImagerPixelMap.Create
GraphicsOps.NewContextFromBitmap ~~> ImagerRaster.NewBitmapDevice; ImagerRaster.Create
GraphicsOps.SetTargetBitmap ~~~~
GraphicsOps.DrawBitmap ~~~> Imager.MaskBits, ImagerBackdoor.DrawBits
GraphicsOps.ScreenBitmap ~~~> InterminalBackdoor.terminal
GraphicsOps.NewAisImage ~~~> ImagerPixelArray.FromAIS; Inager.SetSampledColor
GraphicsOps.NewAisImageFromCapability ~~~~
GraphicsOps.ImageBox ~~~> pa.fSize, pa.sSize, pa.m, ImagerTransformation.Transform
GraphicsOps.DefaultFont ~~~> VFonts.DefaultFont[];
GraphicsOps.DrawTextFromProc ~~> Imager.Show
GraphicsOps.DrawText => Imager.ShowText
GraphicsOps.TextBox => ImagerFont.TextBoundingBox
GraphicsOps.TextWidth => ImagerFont.TextWidth
GraphicsOps.UserToDevice => ImagerTransformation.Transform
GraphicsOps.DeviceToUser => ImagerTransformation.InverseTransform
GraphicsOps.GetMapper => ImagerBackdoor.GetT
GraphicsOps.SetMapper => ImagerBackdoor.SetT
GraphicsOps.TestVisible => ImagerBackdoor.DoIfVisible
GraphicsOps.TestBounds => ImagerBackdoor.DoIfVisible
GraphicsOps.BeginBox ~~~~
GraphicsOps.EndBox ~~~~
GraphicsOps.GetYMode ~~~~
GraphicsOps.SetYMode ~~~~
GraphicsOps.Texture ~~~> ImagerPixelArray.PixelArray
GraphicsOps.DrawTexturedBox ~~~> Imager.SetSampledBlack; Imager.MaskBox
GraphicsOps.Disable ~~~> Imager.SetNoImage
GraphicsOps.MoveDeviceRectangle => ImagerBackdoor.MoveViewRectangle
GraphicsOps.UnsafeNewFont ~~~~
GraphicsExtras.UnsafeNewContextFromBitmap => ~~~~
GraphicsColor.Color => ImagerColor.Color
GraphicsColor.red, green, blue, magenta, cyan, yellow ~~> ImagerColor.ColorFromAtom
GraphicsColor.black => Imager.black
GraphicsColor.white => Imager.white
GraphicsColor.IntensityToColor ~> ImagerColor.MakeGray[1.0-intensity];
GraphicsColor.HSVToColor ~> ImagerColor.ColorFromRGB[ImagerColor[RGBFromHSV[HSV]]]
GraphicsColor.RGBToColor ~> ImagerColor.ColorFromRGB
GraphicsColor.ColorToIntensity => ImagerColorPrivate.ComponentFromColor
GraphicsColor.ColorToHSV => ImagerColor.ComponentFromColor, ImagerColor.HSVFromRGB
GraphicsColor.ColorToRGB => ImagerColorPrivate.ComponentFromColor
Spline.* ~~~~
Converting from Cedar 5.2 Imager
Legend:
a => b means a converts directly to b
a ~> b means a converts approximately to b (only trivial changes needed, like renaming parameters)
a ~~> b means a converts to b not trivally, but without great difficulty
a ~~~> b means a converts to b with substantial effort.
a ~~~~ No direct correspondence.
a ~~~~> Consult a wizard.
Cedar5.2 Imager to Cedar6.1 Imager (not all direct mappings are shown):
Font ~~> ImagerFont
Imager ~~> Imager
Imager.Create[$LFDisplay] ~> ImagerTerminal.BWContext[]
Imager.Create[$PD] ~~~> ImagerPD.Create[], ImagerPD.CreateFromParameters[] (most clients should use ImagerInterpress instead)
Imager.Create[$Gray8bpp] ~~~> ImagerTerminal.ColorContext[]
Imager.Reset ~~~~
Imager.MakeT, OpenT, Translate, Scale, Scale2, Rotate, Concat, Invert, Transform, TransformVec, RoundXY, RoundXYVec ~~> ImagerTransformation
Imager.Integer* ~> Imager.*I
Imager.MakeGray => ImagerColor.MakeGray
Imager.Trajectory => ImagerPath.Trajectory
Imager.LastPoint => ImagerPath.LastPoint
Imager.MoveTo => ImagerPath.MoveTo
Imager.LineTo => ImagerPath.LineTo
Imager.LineToX => ImagerPath.LineToX
Imager.LineToY => ImagerPath.LineToY
Imager.CurveTo => ImagerPath.CurveTo
Imager.ConicTo => ImagerPath.ConicTo
Imager.ArcTo => ImagerPath.ArcTo
Imager.Polygon ~~~> ImagerPath.PathProc
Imager.MaskStrokeClosed ~> Imager.MaskStroke[..., closed: TRUE]
Imager.MakePixelArrayFromBits ~~~~> To be supplied
Imager.Exclude* ~> Imager.Clip*[..., exclude: TRUE]
Imager.MakeFont ~> ImagerFont.Find, ImagerFont.Scale
Imager.SetFont => Imager.SetFont
Imager.ShowChar => Imager.ShowChar
Imager.ShowCharacters ~> Imager.ShowRope, Imager.ShowText
Imager.DRound ~~~> ImagerBackdoor.GetT, ImagerTransformation.RoundXY
Imager.GetCP ~> ImagerBackdoor.GetCP
Imager.GetCPRounded ~> ImagerBackdoor.GetCP[..., rounded: TRUE]
Imager.MakeStipple ~> ImagerBackdoor.MakeStipple
Imager.XOR => ImagerBackdoor.invert
Imager.TestRectangle ~~> ImagerBackdoor.DoIfVisible
Imager.SpecialOp ~~~~> see ImagerInterpress, ImagerPD, ImagerTerminal, etc.
Imager.NewPage ~~~~> see ImagerInterpress, ImagerPD, ImagerTerminal, etc.
Imager.PutProp => Imager.PutProp
Imager.GetProp => Imager.GetProp
Imager.GetSurfaceBounds, SetViewOrigin, SetViewBox, GetViewBox, ClipView, MoveSurfaceRectangle ~~~> ImagerBackdoor
ImagerBridge ~~~~
ImagerAISUtil ~~> ImagerPixelArray
ImagerPD ~~~> ImagerPD (most clients should use ImagerInterpress instead)
ImagerPDExtras ~~~> ImagerPD
ImagerTransform ~> ImagerTransformation
ImagerBasic ~~~> ImagerTransformation, ImagerColorDefs, ImagerPixelArrayDefs, ImagerState, Imager
ImagerLF ~~> ImagerTerminal
ImagerConic => ImagerConic
ImagerStroke ~~~> ImagerStroke
ImagerMasks ~~~> ImagerMask
ImagerBrick ~~~> ImagerBrick
ImagerHalftone ~~~> ImagerSample
ImagerFrameBuffer.LFDisplay ~~~~> ImagerOps.PixelMapFromFrameBuffer[Terminal.GetBWFrameBuffer[InterminalBackdoor.terminal]]
ImagerPixelMaps ~> ImagerPixelMap
ImagerManhattan => ImagerManhattan
ImagerScanConverter => ImagerScanConverter
ImagerFontCache ~~~~> ImagerCache