DIRECTORY AIS, FS, Imager, ImagerColorOperator, ImagerColorPrivate, ImagerPixelArray, ImagerTransformation, ReadAIS, Real, Rope, SV2d, SVError, SVFiles, SVImage, SVModelTypes, SVVector2d; SVImageImpl: PROGRAM IMPORTS AIS, FS, Imager, ImagerColorOperator, ImagerColorPrivate, ImagerPixelArray, ImagerTransformation, ReadAIS, Real, Rope, SVError, SVFiles, SVVector2d EXPORTS SVImage = BEGIN Image: TYPE = REF ImageObj; ImageObj: TYPE = SVImage.ImageObj; BoundBox: TYPE = REF BoundBoxObj; BoundBoxObj: TYPE = SVModelTypes.BoundBoxObj; Color: TYPE = Imager.Color; Point2d: TYPE = SV2d.Point2d; WRef: TYPE = AIS.WRef; FRef: TYPE = AIS.FRef; IsEven: PRIVATE PROC [n: NAT] RETURNS [BOOL] = { RETURN [(n/2)*2 = n]; }; RoundDown: PRIVATE PROC [r: REAL] RETURNS [rDown: INTEGER] = { IF r = 0 THEN RETURN[0]; IF r > 0 THEN { rDown _ Real.FixI[r]; RETURN} ELSE { r _ -r;-- make it positive rDown _ Real.FixI[r]; rDown _ rDown + 1; rDown _ - rDown; }; }; RoundUp: PRIVATE PROC [r: REAL] RETURNS [rUp: INTEGER] = { IF r = 0 THEN RETURN[0]; IF r > 0 THEN { rUp _ Real.FixI[r]; rUp _ rUp + 1; RETURN} ELSE { r _ -r;-- make it positive rUp _ Real.FixI[r]; rUp _ - rUp; }; }; CountSamples: PRIVATE PROC [realMinX, realMinY, realMaxX, realMaxY, resolution: REAL] RETURNS [numberOfSamplesX, numberOfSamplesY: NAT] = { xExtent, yExtent, realSamplesX, realSamplesY: REAL; xExtent _ realMaxX - realMinX; -- x extent in screen dots yExtent _ realMaxY - realMinY; -- y extent in screen dots realSamplesX _ (xExtent*resolution)/72.0; realSamplesY _ (yExtent*resolution)/72.0; numberOfSamplesX _ Real.FixI[realSamplesX] + 2; numberOfSamplesY _ Real.FixI[realSamplesY] + 2; IF NOT IsEven[numberOfSamplesX] THEN numberOfSamplesX _ numberOfSamplesX + 1; IF NOT IsEven[numberOfSamplesY] THEN numberOfSamplesY _ numberOfSamplesY + 1; }; -- end of CountSamples OpenImage: PUBLIC PROC [aisRope: Rope.ROPE, bAndWOnly: BOOL, realMinX, realMinY, realMaxX, realMaxY, resolution: REAL, commentString: Rope.ROPE] RETURNS [I: Image, numberOfSamplesX, numberOfSamplesY: NAT] = { f: AIS.FRef; raster: AIS.Raster; I _ NEW[ImageObj]; [numberOfSamplesX, numberOfSamplesY] _ CountSamples[realMinX, realMinY, realMaxX, realMaxY, resolution]; raster _ NEW[AIS.RasterPart _ [numberOfSamplesY, numberOfSamplesX, rd, 8, -1, 65535]]; IF bAndWOnly THEN { I.bAndWOnly _ TRUE; f _ ReadAIS.CreateFile[aisRope, raster, commentString, TRUE, 0, resolution]; I.bwWindow _ AIS.OpenWindow[f]; SVError.Append[" New "]; SVError.Append[aisRope]; SVError.Append[" created.", FALSE, TRUE]; } ELSE { redRope: Rope.ROPE _ Rope.Concat[SVFiles.FilenameMinusExtension[aisRope], "-red.ais"]; greenRope: Rope.ROPE _ Rope.Concat[SVFiles.FilenameMinusExtension[aisRope], "-grn.ais"]; blueRope: Rope.ROPE _ Rope.Concat[SVFiles.FilenameMinusExtension[aisRope], "-blu.ais"]; bwRope: Rope.ROPE _ aisRope; I.bAndWOnly _ FALSE; f _ ReadAIS.CreateFile[redRope, raster, commentString, TRUE, 0, resolution]; I.redWindow _ AIS.OpenWindow[f]; f _ ReadAIS.CreateFile[greenRope, raster, commentString, TRUE, 0, resolution]; I.greenWindow _ AIS.OpenWindow[f]; f _ ReadAIS.CreateFile[blueRope, raster, commentString, TRUE, 0, resolution]; I.blueWindow _ AIS.OpenWindow[f]; f _ ReadAIS.CreateFile[bwRope, raster, commentString, TRUE, 0, resolution]; I.bwWindow _ AIS.OpenWindow[f]; SVError.Append[" New color "]; SVError.Append[aisRope]; SVError.Append["'s created.", FALSE, TRUE]; }; }; -- end of OpenImage DeleteFile: PRIVATE PROC [name: Rope.ROPE] = { AIS.DeleteFile[name]; SVError.Append[name]; SVError.Append["... "]; }; -- end of DeleteFile Truncate: PROC [value: REAL] RETURNS [m: CARDINAL] = { SELECT value FROM <0 => ERROR; >255.0 => m _ 255; ENDCASE => m _ Real.FixC[value]; }; PutImage2: PROC [I: Image, i, j: INTEGER, color: Color, minX, maxX, minY, maxY: INTEGER] = { intRed, intGreen, intBlue, intIntensity: CARDINAL; red, green, blue, intensity: REAL; red _ ImagerColorPrivate.ComponentFromColor[NARROW[color], $Red]; green _ ImagerColorPrivate.ComponentFromColor[NARROW[color], $Green]; blue _ ImagerColorPrivate.ComponentFromColor[NARROW[color], $Blue]; intensity _ ImagerColorPrivate.ComponentFromColor[NARROW[color], $Intensity]; intRed _ Truncate[red*255.0]; intGreen _ Truncate[green*255.0]; intBlue _ Truncate[blue*255.0]; intIntensity _ Truncate[intensity*255.0]; AIS.WriteSample[I.redWindow, intRed, maxY - i, j - minX]; AIS.WriteSample[I.greenWindow, intGreen, maxY - i, j - minX]; AIS.WriteSample[I.blueWindow, intBlue, maxY - i, j - minX]; AIS.WriteSample[I.bwWindow, intIntensity, maxY - i, j - minX]; }; PutImage: PUBLIC PROC [I: Image, i, j: INTEGER, color: Color, xSamples, ySamples: NAT] = { IF I.bAndWOnly THEN { intIntensity: CARDINAL; intensity: REAL; intensity _ ImagerColorPrivate.ComponentFromColor[NARROW[color], $Intensity]; intIntensity _ Truncate[intensity*255.0]; AIS.WriteSample[I.bwWindow, intIntensity, ySamples-i, j]; } ELSE { intRed, intGreen, intBlue, intIntensity: CARDINAL; red, green, blue, intensity: REAL; red _ ImagerColorPrivate.ComponentFromColor[NARROW[color], $Red]; green _ ImagerColorPrivate.ComponentFromColor[NARROW[color], $Green]; blue _ ImagerColorPrivate.ComponentFromColor[NARROW[color], $Blue]; intensity _ ImagerColorPrivate.ComponentFromColor[NARROW[color], $Intensity]; intRed _ Truncate[red*255.0]; intGreen _ Truncate[green*255.0]; intBlue _ Truncate[blue*255.0]; intIntensity _ Truncate[intensity*255.0]; AIS.WriteSample[I.redWindow, intRed, ySamples-i, j]; AIS.WriteSample[I.greenWindow, intGreen, ySamples-i, j]; AIS.WriteSample[I.blueWindow, intBlue, ySamples-i, j]; AIS.WriteSample[I.bwWindow, intIntensity, ySamples-i, j]; }; }; CloseImage: PUBLIC PROC [I: Image, aisRope: Rope.ROPE] = { f: AIS.FRef; IF I.bAndWOnly THEN { f _ I.bwWindow.fref; AIS.CloseWindow[I.bwWindow]; AIS.CloseFile[f]; SVError.Append[aisRope]; SVError.Append[" now closed", FALSE, TRUE]; SVError.Blink[]; } ELSE { f _ I.blueWindow.fref; AIS.CloseWindow[I.blueWindow]; AIS.CloseFile[f]; f _ I.bwWindow.fref; AIS.CloseWindow[I.bwWindow]; AIS.CloseFile[f]; f _ I.redWindow.fref; AIS.CloseWindow[I.redWindow]; AIS.CloseFile[f]; f _ I.greenWindow.fref; AIS.CloseWindow[I.greenWindow]; AIS.CloseFile[f]; SVError.Append[" (red grn blu BandW) "]; SVError.Append[aisRope]; SVError.Append[" now closed", FALSE, TRUE]; SVError.Blink[]; }; }; -- end of CloseImage BoundBoxOfImage: PRIVATE PROC [image: ImagerPixelArray.PixelArray, resolution: REAL _ 72.0] RETURNS [boundBox: BoundBox] = { xExtent, yExtent: REAL; xExtent _ (image.fSize/resolution)*72.0; yExtent _ (image.sSize/resolution)*72.0; boundBox _ NEW[BoundBoxObj]; boundBox.minVert _ [0,0,0]; boundBox.maxVert _ [xExtent,yExtent, 0]; }; NewBlackAndWhiteImage: PUBLIC PROC [imageName: Rope.ROPE] RETURNS [image: ImagerPixelArray.PixelArray, success: BOOL] = { bwName: Rope.ROPE _ Rope.Concat[SVFiles.FilenameMinusExtension[imageName],".ais"]; success _ TRUE; image _ ImagerPixelArray.FromAIS[imageName !FS.Error => {success _ FALSE; CONTINUE}]; IF NOT success THEN { SVError.Append["Open AIS file failed", TRUE, TRUE]; SVError.Blink[]; RETURN}; }; NewColorImage: PUBLIC PROC [imageName: Rope.ROPE] RETURNS [image: ImagerPixelArray.PixelArray, success: BOOL] = { redName: Rope.ROPE _ Rope.Concat[SVFiles.FilenameMinusExtension[imageName],"-red.ais"]; greenName: Rope.ROPE _ Rope.Concat[SVFiles.FilenameMinusExtension[imageName],"-grn.ais"]; blueName: Rope.ROPE _ Rope.Concat[SVFiles.FilenameMinusExtension[imageName],"-blu.ais"]; success _ TRUE; image _ ImagerPixelArray.Join3AIS[redName, greenName, blueName !FS.Error => {success _ FALSE; CONTINUE}]; IF NOT success THEN { SVError.Append["Open AIS file failed", TRUE, TRUE]; SVError.Blink[]; RETURN}; }; DrawAlignedBlackAndWhiteImage: PUBLIC PROC [dc: Imager.Context, imageName: Rope.ROPE, resolution: REAL, screenWRTCamera: Point2d, boundBox: BoundBox] = { stepSize, xStart, yStart: REAL; samplesX, samplesY: NAT; aisFile: AIS.FRef; raster: AIS.Raster; originScreen, screenExtent: Point2d; originCameraX, originCameraY: REAL; DrawAlignedBlackAndWhiteImageAux: SAFE PROC = TRUSTED { Imager.TranslateT[dc, [xStart, yStart]]; DrawBlackAndWhiteImage[dc, imageName, screenExtent, resolution]; }; aisFile _ AIS.OpenFile[imageName, FALSE]; raster _ AIS.ReadRaster[aisFile]; AIS.CloseFile[aisFile]; samplesX _ raster.scanLength; samplesY _ raster.scanCount; stepSize _ 72.0/resolution; -- in screen dots per sample IF boundBox = NIL THEN { originCameraX _ 0.0; originCameraY _ 0.0; } ELSE { originCameraX _ (boundBox.maxVert[1] + boundBox.minVert[1])/2.0; originCameraY _ (boundBox.maxVert[2] + boundBox.minVert[2])/2.0; }; originScreen _ SVVector2d.Sub[[originCameraX, originCameraY], screenWRTCamera]; screenExtent[1] _ Real.Float[samplesX-1]*stepSize; -- screen dots screenExtent[2] _ Real.Float[samplesY-1]*stepSize; -- screen dots xStart _ originScreen[1] - screenExtent[1]/2.0; yStart _ originScreen[2] - screenExtent[2]/2.0; Imager.DoSaveAll[dc, DrawAlignedBlackAndWhiteImageAux]; }; DrawAlignedColorImage: PUBLIC PROC [dc: Imager.Context, imageName: Rope.ROPE, resolution: REAL, screenWRTCamera: Point2d, boundBox: BoundBox] = { stepSize, xStart, yStart: REAL; samplesX, samplesY: NAT; aisFile: AIS.FRef; raster: AIS.Raster; originScreen, screenExtent: Point2d; originCameraX, originCameraY: REAL; redName: Rope.ROPE _ Rope.Concat[SVFiles.FilenameMinusExtension[imageName],"-red.ais"]; DrawAlignedColorImageAux: SAFE PROC = TRUSTED { Imager.TranslateT[dc, [xStart, yStart]]; DrawColorImage[dc, imageName, screenExtent, resolution]; }; aisFile _ AIS.OpenFile[redName, FALSE]; raster _ AIS.ReadRaster[aisFile]; AIS.CloseFile[aisFile]; samplesX _ raster.scanLength; samplesY _ raster.scanCount; stepSize _ 72.0/resolution; -- in screen dots per sample IF boundBox = NIL THEN { originCameraX _ 0.0; originCameraY _ 0.0; } ELSE { originCameraX _ (boundBox.maxVert[1] + boundBox.minVert[1])/2.0; originCameraY _ (boundBox.maxVert[2] + boundBox.minVert[2])/2.0; }; originScreen _ SVVector2d.Sub[[originCameraX, originCameraY], screenWRTCamera]; screenExtent[1] _ Real.Float[samplesX-1]*stepSize; -- screen dots screenExtent[2] _ Real.Float[samplesY-1]*stepSize; -- screen dots xStart _ originScreen[1] - screenExtent[1]/2.0; yStart _ originScreen[2] - screenExtent[2]/2.0; Imager.DoSaveAll[dc, DrawAlignedColorImageAux]; }; OldDrawBlackAndWhiteImage: PUBLIC PROC [dc: Imager.Context, imageName: Rope.ROPE, clipBox: BoundBox _ NIL, resolution: REAL _ 72.0, raw: BOOL] = { minX, maxX, minY, maxY: REAL; lowerLeft, upperRight: Point2d; image: ImagerPixelArray.PixelArray; success: BOOL; scale: REAL; colors: Imager.ColorOperator _ ImagerColorOperator.GrayLinearColorModel[255, 0, 255]; DrawBlackAndWhiteImageAux: SAFE PROC = TRUSTED { Imager.SetXY[dc, [0, 0]]; -- put lower left corner of image at this new origin Imager.SetSampledColor[dc, image, ImagerTransformation.Scale[scale], colors]; Imager.MaskBox[dc, [minX, minY, maxX, maxY]]; }; [image, success] _ NewBlackAndWhiteImage[imageName]; IF NOT success THEN RETURN; IF clipBox = NIL THEN clipBox _ BoundBoxOfImage[image, resolution]; lowerLeft _ [0,0];-- screen coords upperRight _ SVVector2d.Add[[clipBox.maxVert[1], clipBox.maxVert[2]], lowerLeft];-- screen coords scale _ 72.0/resolution; minX _ lowerLeft[1]; minY _ lowerLeft[2]; maxX _ upperRight[1]*scale +1; maxY _ upperRight[2]*scale +1; Imager.DoSaveAll[dc, DrawBlackAndWhiteImageAux]; }; DrawBlackAndWhiteAtOrigin: PUBLIC PROC [dc: Imager.Context, imageName: Rope.ROPE, resolution: REAL _ 72.0] = { stepSize: REAL; samplesX, samplesY: NAT; aisFile: AIS.FRef; raster: AIS.Raster; screenExtent: Point2d; aisFile _ AIS.OpenFile[imageName, FALSE]; raster _ AIS.ReadRaster[aisFile]; AIS.CloseFile[aisFile]; samplesX _ raster.scanLength; samplesY _ raster.scanCount; stepSize _ 72.0/resolution; -- in screen dots per sample screenExtent[1] _ Real.Float[samplesX-1]*stepSize; -- screen dots screenExtent[2] _ Real.Float[samplesY-1]*stepSize; -- screen dots DrawBlackAndWhiteImage[dc, imageName, screenExtent, resolution]; }; DrawColorImageAtOrigin: PUBLIC PROC [dc: Imager.Context, imageName: Rope.ROPE, resolution: REAL _ 72.0] = { stepSize: REAL; samplesX, samplesY: NAT; aisFile: AIS.FRef; redName: Rope.ROPE _ Rope.Concat[SVFiles.FilenameMinusExtension[imageName],"-red.ais"]; raster: AIS.Raster; screenExtent: Point2d; aisFile _ AIS.OpenFile[redName, FALSE]; raster _ AIS.ReadRaster[aisFile]; AIS.CloseFile[aisFile]; samplesX _ raster.scanLength; samplesY _ raster.scanCount; stepSize _ 72.0/resolution; -- in screen dots per sample screenExtent[1] _ Real.Float[samplesX-1]*stepSize; -- screen dots screenExtent[2] _ Real.Float[samplesY-1]*stepSize; -- screen dots DrawColorImage[dc, imageName, screenExtent, resolution]; }; DrawBlackAndWhiteImage: PROC [dc: Imager.Context, imageName: Rope.ROPE, screenExtent: Point2d, resolution: REAL _ 72.0] = { minX, maxX, minY, maxY: REAL; image: ImagerPixelArray.PixelArray; success: BOOL; scale: REAL; colors: Imager.ColorOperator _ ImagerColorOperator.GrayLinearColorModel[255, 0, 255]; DrawBlackAndWhiteImageAux: SAFE PROC = TRUSTED { Imager.SetSampledColor[dc, image, ImagerTransformation.Scale[scale], colors]; Imager.MaskBox[dc, [minX, minY, maxX, maxY]]; }; [image, success] _ NewBlackAndWhiteImage[imageName]; IF NOT success THEN RETURN; scale _ 72.0/resolution; minX _ 0.0; minY _ 0.0; maxX _ screenExtent[1]; maxY _ screenExtent[2]; Imager.DoSaveAll[dc, DrawBlackAndWhiteImageAux]; }; DrawColorImage: PROC [dc: Imager.Context, imageName: Rope.ROPE, screenExtent: Point2d, resolution: REAL _ 72.0] = { minX, maxX, minY, maxY: REAL; image: ImagerPixelArray.PixelArray; success: BOOL; scale: REAL; colors: Imager.ColorOperator _ ImagerColorOperator.RGBLinearColorModel[255]; DrawColorImageAux: SAFE PROC = TRUSTED { Imager.SetSampledColor[dc, image, ImagerTransformation.Scale[scale], colors]; Imager.MaskBox[dc, [minX, minY, maxX, maxY]]; }; [image, success] _ NewColorImage[imageName]; IF NOT success THEN RETURN; scale _ 72.0/resolution; minX _ 0.0; minY _ 0.0; maxX _ screenExtent[1]; maxY _ screenExtent[2]; Imager.DoSaveAll[dc, DrawColorImageAux]; }; END. !ΔFile: SVImageImpl.mesa Last edited by Bier on August 17, 1985 10:10:54 pm PDT Copyright c 1984 by Xerox Corporation. All rights reserved. Contents: Routines for manipulating 24 bit per pixel color images find the largest integer less than r (or equal to if r is positive). find the smallest integer greater than r (or equal to if r is negative). We are given a minimum bounding box to be filled. Calculate the number of samples in the x direction as follows: Find the number of samples which will just fit in the alloted x extent. Now add one (Since + 1 = number of samples, we actually add two). If the resulting number is odd, add 1 again. Do the same for the y direction. (Because of unimplemented features in some of the printing software, it is useful to round all ais file sizes to even numbers of pixels.) xExtent/72 = x extent in inches. (xExtent/72)*resolution = samples which will fit. Round this down to the nearest integer. Bound box is in camera coordinates Truncate the REAL value to 0-255 i is row. j is column. i = maxY maps to 0. i = minY maps to maxY-minY. j = maxX maps to maxX-minX. j = minX maps to 0. i is row. j is column. i = ySamples maps to 0. i = 1 maps to ySamples-1. j = xSamples-1 maps to xSamples-1. j = 0 maps to 0. xExtent, yExtent are now in units of samples. Resolution is in samples per inch. There are 72 screen dots per inch. We wish to normalize as if xmin = ymin = 0; Count how many samples there are in the x and y directions of the image. Look at the resolution (samples per inch. default is 72.0). This gives the actual size of the image, in inches. Frame it evenly around the clipBox. The clipBox is in Camera coordinates. Strategy: Find the center of the clipBox in camera coordinates. Convert to screen coordinates. Find the width of the ais image (in screen coordinates -- just use 72.0 as a magic number). Find the origin (xStart, yStart) in screen coordinates. resolution _ ReadAIS.ResolutionFromInfo[info]; -- for now, receive as argument Compute xStart and yStart. xStart _ xStart - stepSize/2.0; yStart _ yStart - stepSize/2.0; Count how many samples there are in the x and y directions of the image. Look at the resolution (default is 72.0). This gives the actual size of the image. Frame it evenly around the clipBox. resolution _ ReadAIS.ResolutionFromInfo[info]; Compute xStart and yStart. DrawAndScaleBlackAndWhiteImage: PUBLIC PROC [dc: Imager.Context, imageName: Rope.ROPE, screenWRTCamera: Point2d, realMinX, realMinY, realMaxX, realMaxY: REAL] = { minX, maxX, minY, maxY: INTEGER; clipPath: ImagerPath.Trajectory; lowerLeft, upperRight: Point2d; Take file in AIS coordinates (right and down) and display in SCREEN coords. AIS origin is displaced from CAMERA origin by minX, minY. The clipping region has its origin at the ais origin and proceeds scanwidth and scanheight. screenOrigin: Point2d; success: BOOL _ TRUE; image: ImageRef; imageXmin, imageYmin, imageXmax, imageYmax, xScale, yScale: REAL; DrawAndScaleBlackAndWhiteImageAux: PROC = { [image, success] _ NewBlackAndWhiteImage[imageName]; IF NOT success THEN RETURN; Substitute for NIL parameters lowerLeft _ SVVector2d.Sub[[realMinX, realMinY], screenWRTCamera]; upperRight _ SVVector2d.Sub[[realMaxX, realMaxY], screenWRTCamera]; Box bounds in screen coordinates minX _ RoundDown[lowerLeft[1]]; maxX _ RoundUp[upperRight[1]]; minY _ RoundDown[lowerLeft[2]]; maxY _ RoundUp[upperRight[2]]; IF NOT IsEven[maxX - minX + 1] THEN maxX _ maxX + 1; IF NOT IsEven[maxY - minY + 1] THEN maxY _ maxY + 1; screenOrigin _ [minX, minY];-- ais file origin with respect to screen origin Now find the bounding box of the ais file and scale the ais file to fit in the viewport. [imageXmin, imageYmin, imageXmax, imageYmax] _ GraphicsOps.ImageBox[image]; xScale _ (maxX-minX)/(imageXmax-imageXmin); yScale _ (maxY-minY)/(imageYmax-imageYmin); clipPath _ ImagerPath.MoveTo[[screenOrigin[1], screenOrigin[2]]]; clipPath _ ImagerPath.LineTo[clipPath, [screenOrigin[1], screenOrigin[2]+maxY-minY]]; clipPath _ ImagerPath.LineTo[clipPath, [screenOrigin[1] + maxX-minX, screenOrigin[2]+maxY-minY]]; clipPath _ ImagerPath.LineTo[clipPath, [screenOrigin[1] + maxX-minX, screenOrigin[2]]]; Imager.ClipArea[dc, clipPath]; Imager.Translate[dc, screenOrigin[1], screenOrigin[2]]; Imager.SetCP[dc, 0, 0]; Imager.Scale[dc, xScale, yScale]; Imager.SetColor[dc, ImagerColor.white]; Imager.DrawImage[dc, image, TRUE]; }; Imager.DoSaveAll[dc, DrawAndScaleBlackAndWhiteImageAux]; }; DrawAndScaleColorImage: PUBLIC PROC [dc: Imager.Context, imageName: Rope.ROPE, screenWRTCamera: Point2d, realMinX, realMinY, realMaxX, realMaxY: REAL] = { minX, maxX, minY, maxY: INTEGER; lowerLeft, upperRight: Point2d; Take file in ais coordinates (right and down) and display in SCREEN coords. AIS origin is displaced from CAMERA origin by minX, minY. The clipping region has its origin at the ais origin and proceeds scanwidth and scanheight. screenOrigin: Point2d; redimage, greenimage, blueimage: ImageRef; success: BOOL; imageXmin, imageYmin, imageXmax, imageYmax, xScale, yScale: REAL; clipPath: ImagerPath.Trajectory; DrawAndScaleColorImageAux: PROC = { [redimage, greenimage, blueimage, success] _ NewColorImage[imageName]; IF NOT success THEN RETURN; lowerLeft _ SVVector2d.Sub[[realMinX, realMinY], screenWRTCamera]; upperRight _ SVVector2d.Sub[[realMaxX, realMaxY], screenWRTCamera]; Box bounds in screen coordinates minX _ RoundDown[lowerLeft[1]]; maxX _ RoundUp[upperRight[1]]; minY _ RoundDown[lowerLeft[2]]; maxY _ RoundUp[upperRight[2]]; IF NOT IsEven[maxX - minX + 1] THEN maxX _ maxX + 1; IF NOT IsEven[maxY - minY + 1] THEN maxY _ maxY + 1; screenOrigin _ [minX, minY];-- ais file lower left with respect to screen origin Now find the bounding box of the ais file and scale the ais file to fit in the viewport [imageXmin, imageYmin, imageXmax, imageYmax] _ GraphicsOps.ImageBox[redimage]; xScale _ (maxX-minX)/(imageXmax-imageXmin); yScale _ (maxY-minY)/(imageYmax-imageYmin); clipPath _ ImagerPath.MoveTo[[screenOrigin[1], screenOrigin[2]]]; clipPath _ ImagerPath.LineTo[clipPath, [screenOrigin[1], screenOrigin[2]+maxY-minY]]; clipPath _ ImagerPath.LineTo[clipPath, [screenOrigin[1] + maxX-minX, screenOrigin[2]+maxY-minY]]; clipPath _ ImagerPath.LineTo[clipPath, [screenOrigin[1] + maxX-minX, screenOrigin[2]]]; Imager.ClipArea[dc, clipPath]; Imager.Translate[dc, screenOrigin[1], screenOrigin[2]]; Imager.SetCP[dc, 0, 0]; Imager.Scale[dc, xScale, yScale]; [] _ Imager.SetPaintMode[dc, opaque]; Imager.SetColor[dc, ImagerColor.ColorFromAtom[$Red]]; Imager.DrawImage[dc, redimage]; [] _ Imager.SetPaintMode[dc, transparent]; Imager.SetColor[dc, ImagerColor.ColorFromAtom[$Green]]; Imager.DrawImage[dc, greenimage]; Imager.SetColor[dc, ImagerColor.ColorFromAtom[$Blue]]; Imager.DrawImage[dc, blueimage]; }; Imager.DoSaveAll[dc, DrawAndScaleColorImageAux]; }; -- end of DrawAndScaleColorImage clipBox in units of screen dots, in coordinates whose origin is the lower left hand corner of the ais image. resolution is in dots per inch (72 is screen resolution). Draws the ais file of given resolution such that its lower left hand corner is at the current origin of dc. This involves several steps. 1) Find the total size of the clipBox. If no clipBox is given, use the whole image size. 2) Find the scaling factors needed to interpret the image as having the stated resolution 3) Translate appropriately 4) Draw. Create the bounding box we have just calculated If lowerLeft were not [0,0], we would perform this translate OPEN THE IMAGE Substitute for NIL parameters. BoundBoxOfImage in screen dots relative to lower left corner of image. Find clipBox in screen coordinates (ie its lowerLeft and upperRight points) Now find the scaling factors for the given resolution. box bounds in screen coordinates clipBox in units of screen dots, in coordinates whose origin is the lower left hand corner of the ais image. resolution is in dots per inch (72 is screen resolution). Draws the ais file of given resolution such that its lower left hand corner is at the current origin of dc. This involves several steps. 1) Find the total size of the clipBox. If no clipBox is given, use the whole image size. 2) Find the scaling factors needed to interpret the image as having the stated resolution 3) Translate appropriately 4) Draw. OPEN THE IMAGE Now find the scaling factors for the given resolution. box bounds in screen coordinates See comment for DrawBlackAndWhiteImage OPEN THE IMAGE Now find the scaling factors for the given resolution. box bounds in screen coordinates Κ^– "cedar" style˜Iheadšœ™Iprocšœ6™6Jšœ Οmœ1™šœD™DLšžœžœžœ˜šžœžœ˜Lšœ˜Lšžœ˜—šžœ˜Lšœ˜Lšœ˜Lšœ˜Lšœ˜Lšœ˜—Lšœ˜—L˜Lš Ÿœžœžœžœžœžœ˜:šœH™HLšžœžœžœ˜šžœžœ˜Lšœ˜Lšœ˜Lšžœ˜—šžœ˜Lšœ˜Lšœ˜Lšœ ˜ Lšœ˜—Lšœ˜—L˜š œŸ œžœžœ6žœžœ&žŸ˜ŒLšŸœϋ™όLšœ.žœ˜4Lšœ9˜9Lšœ9˜9Lšœ)˜)Lšœ)˜)Lšœ/˜/Lšœ/˜/Lšžœžœžœ)˜MLšžœžœžœ)˜MLšœ˜—L˜Lšœ˜šŸ œžœžœžœ žœ6žœžœžœžœ-žœ˜ΠLšœ#™#L™Lšœžœ˜ Lšœžœ˜L˜Lšžœžœ ˜L˜Lšœh˜hL˜Lšœ žœžœF˜VL˜šžœ žœ˜Lšžœ žœ˜Lšœ7žœ˜LLšžœ žœ˜Lšœ˜Lšœ˜Lšœžœžœ˜)Lšœ˜—šžœ˜LšœžœD˜VLšœžœD˜XLšœžœD˜WLšœ žœ ˜L˜Lšžœ žœ˜Lšœ˜Lšœ7žœ˜LLšžœ žœ˜ Lšœ9žœ˜NLšžœžœ˜"Lšœ8žœ˜MLšžœžœ˜!Lšœ6žœ˜KLšžœ žœ˜Lšœ˜Lšœ˜Lšœžœžœ˜+Lšœ˜—LšœΟc˜L˜—šŸ œžœžœ žœ˜.Lšžœ˜Lšœ˜Lšœ˜Lšœ˜—L˜š Ÿœžœ žœžœžœ˜6Lšœ ™ šžœž˜Lšœžœ˜ Lšœ˜Lšžœ˜ —Lšœ˜—L˜šŸ œžœžœ(žœ˜\LšœH™HLšœ0™0Lšœ)žœ˜2Lšœžœ˜"Lšœ,žœ˜ALšœ.žœ˜ELšœ-žœ˜CLšœ2žœ˜MLšœ˜Lšœ!˜!Lšœ˜Lšœ)˜)Lšžœ6˜9Lšžœ:˜=Lšžœ8˜;Lšžœ;˜>Lšœ˜—L˜š Ÿœžœžœžœžœ$žœ˜ZLšœJ™JLšœ4™4šžœ žœ˜Lšœžœ˜Lšœ žœ˜Lšœ2žœ˜MLšœ)˜)Lšžœ žœ(˜9L˜—šžœ˜Lšœ)žœ˜2Lšœžœ˜"Lšœ,žœ˜ALšœ.žœ˜ELšœ-žœ˜CLšœ2žœ˜MLšœ˜Lšœ!˜!Lšœ˜Lšœ)˜)Lšžœ žœ#˜4Lšžœ žœ'˜8Lšžœ žœ%˜6Lšžœ žœ(˜9L˜—Lšœ˜—L˜š Ÿ œžœžœžœžœ˜:Lšœžœ˜ šžœ žœ˜Lšœžœ˜Lšžœ žœ ˜Lšžœ˜Lšœ˜Lšœ+˜+Lšœ˜L˜—šžœ˜Lšœžœ˜Lšžœ žœ ˜Lšžœ˜Lšœžœ˜Lšžœ žœ ˜Lšžœ˜Lšœžœ˜Lšžœ žœ ˜Lšžœ˜Lšœžœ˜Lšžœ žœ˜Lšžœ˜Lšœ(˜(Lšœ˜Lšœ+˜+Lšœ˜L˜—Lšœ ˜—L˜š Ÿœžœžœ2žœ žœ˜|Lšœžœ˜LšœQ™QLšœO™OLšœ(˜(Lšœ(˜(Lšœ žœ˜Lšœ˜Lšœ(˜(Lšœ˜—L˜š Ÿœžœžœžœžœ/žœ˜yLšœ žœA˜RLšœ žœ˜šœ*˜*Lšœžœžœžœ˜*—šžœžœ žœ˜Lšœ'žœžœ˜3Lšœ˜Lšžœ˜—Lšœ˜—L˜š Ÿ œžœžœžœžœ/žœ˜qLšœžœE˜WLšœžœE˜YLšœžœE˜XLšœ žœ˜šœ>˜>Lšœžœžœžœ˜*—šžœžœ žœ˜Lšœ'žœžœ˜3Lšœ˜Lšžœ˜—Lšœ˜—L˜L™š Ÿœžœžœ&žœžœ3˜™šœΪΟbœ‘œ™€Lšœžœ˜Lšœžœ˜Lšœ žœ˜Lšœžœ˜Lšœ$˜$Lšœžœ˜#šŸ œžœžœžœ˜7Lšœ‘œ‘œ˜(Lšœ@˜@L˜—Lšœ žœžœ˜)Lšœ žœ˜!Lšžœ˜LšœN™N˜Lšœ‘œ‘œ™—Lšœ˜Lšœ˜Lšœ ˜8šœ˜Lšœ˜Lšœ˜L˜—˜Lšœ@˜@Lšœ@˜@L˜—LšœO˜OLšœ4 ˜BLšœ4 ˜BLšœ0˜0Lšœ/˜/Lš‘œ™Lš‘œ™Lšœ7˜7Lšœ˜——L˜š Ÿœžœžœ&žœžœ3˜‘LšœΓ™ΓLšœžœ˜Lšœžœ˜Lšœ žœ˜Lšœžœ˜Lšœ$˜$Lšœžœ˜#LšœžœE˜WšŸœžœžœžœ˜/Lšœ‘œ‘œ˜(Lšœ8˜8L˜—Lšœ žœžœ˜'Lšœ žœ˜!Lšžœ˜Lšœ.™.™Lšœ‘œ‘œ™—Lšœ˜Lšœ˜Lšœ ˜8šžœ žœžœ˜Lšœ˜Lšœ˜L˜—šžœ˜Lšœ@˜@Lšœ@˜@L˜—LšœO˜OLšœ4 ˜BLšœ4 ˜BLšœ0˜0Lšœ/˜/Lšœ/˜/Lšœ˜—L™L™š Ÿœžœžœ&žœDžœ™’Lšœžœ™ Lšœ ™ Lšœ™LšœK™KLšœ9™9Lšœ[™[Lšœ™Lšœ žœžœ™Lšœ™Lšœ<žœ™AšŸ!œžœ™+Lšœ4™4Lšžœžœ žœžœ™Lšœ™LšœB™BLšœC™CLšœ ™ Lšœ™Lšœ™Lšœ™Lšœ™Lšžœžœžœ™4Lšžœžœžœ™4Lšœ 0™LLšœX™XLšœK™KLšœ,™,Lšœ+™+LšœA™ALšœU™ULšœa™aLšœW™WLšœ™Lšœ7™7Lšœ™Lšœ!™!Lšœ'™'Lšœžœ™"L™—Lšœ8™8Lšœ™—L˜š Ÿœžœžœ&žœDžœ™šLšœžœ™ Lšœ™Lšœα™αLšœ™Lšœ*™*Lšœ žœ™Lšœ<žœ™ALšœ ™ šŸœžœ™#LšœF™FLšžœžœ žœžœ™LšœB™BLšœC™CLšœ ™ Lšœ™Lšœ™Lšœ™Lšœ™Lšžœžœžœ™4Lšžœžœžœ™4Lšœ 4™PLšœW™WLšœN™NLšœ,™,Lšœ+™+LšœA™ALšœU™ULšœa™aLšœW™WLšœ™Lšœ7™7Lšœ™Lšœ!™!Lšœ%™%Lšœ5™5Lšœ™Lšœ*™*Lšœ7™7Lšœ!™!Lšœ6™6Lšœ ™ L™—Lšœ0™0Lšœ  ™#L™—L˜L˜šŸœžœžœ&žœžœžœžœ˜’Lšœl™lLšœ9™9Lšœk™kLšœυ™υLšœžœ˜Lšœ˜Lšœ#˜#Lšœ žœ˜Lšœžœ˜ LšœU˜UšŸœž œ ˜0Lšœ/™/Lšœ<™