DIRECTORY InterpressToTape, AIS, Imager, Rope, PrintColor, ImagerInterpress, ImagerPixelArray, ImagerColor, ImagerBox, ImagerFont, Real, FS, OptronicsTape; ProduceTapesImpl: CEDAR PROGRAM IMPORTS AIS, Imager, ImagerInterpress, Rope, ImagerPixelArray, ImagerColor, ImagerFont, Real, FS, InterpressToTape EXPORTS ~ BEGIN ROPE: TYPE ~ Rope.ROPE; ColorCorrection: TYPE ~ PrintColor.ColorCorrection; IPSpec: TYPE ~ InterpressToTape.IPSpec; IPSpecRep: TYPE ~ InterpressToTape.IPSpecRep; RGB: TYPE ~ ImagerColor.RGB; AISEndings: TYPE = ARRAY [0..2] OF ROPE; redGreenBlue: AISEndings _ ["-red", "-green", "-blue"]; redGrnBlu: AISEndings _ ["-red", "-grn", "-blu"]; ImageAndLabel: PROC [context: Imager.Context, pa: ImagerPixelArray.PixelArray, note: ROPE, fontSize: REAL, onSide: BOOLEAN _ FALSE] RETURNS[widthInPixels, heightInPixels: NAT] ~ { nLines: NAT _ pa.sSize; nPixels: NAT _ pa.fSize; widthInPixels _ nPixels; heightInPixels _ nLines; IF note#NIL THEN { width: PROC[extent: ImagerFont.Extents] RETURNS[REAL] = { RETURN[extent.leftExtent+extent.rightExtent]}; height: PROC[extent: ImagerFont.Extents] RETURNS[REAL] = { RETURN[extent.ascent+extent.descent]}; font: ImagerFont.Font _ ImagerFont.Scale[ImagerFont.Find["Xerox/PressFonts/Helvetica-mrr"],fontSize]; noteBox: ImagerFont.Extents _ ImagerFont.RopeBoundingBox[font, note]; gap: REAL _ 2.0; --standard small space noteSize: REAL _ 2*gap+height[noteBox]; writeNote: PROC = { Imager.SetColor[context, Imager.white]; IF onSide THEN { Imager.TranslateT[context, [nPixels+gap, nLines-(nLines-width[noteBox])/2.0]]; Imager.RotateT[context, -90]; Imager.SetXY[context,[0,0]]; widthInPixels _ Real.Round[nPixels+noteSize]; heightInPixels _ nLines; } ELSE { Imager.SetXY[context, [x: (nPixels-width[noteBox])/2.0, y: nLines+gap]]; widthInPixels _ nPixels; heightInPixels _ Real.Round[nLines+noteSize]; }; Imager.SetFont[context, font]; Imager.ShowRope[context, note]; }; Imager.DoSave[context, writeNote]; }; Imager.SetSampledColor[context, pa, NIL, ImagerColor.NewColorOperatorRGB[255]]; Imager.MaskRectangle[context, [0,0, nPixels, nLines]]; }; AISSpec: TYPE = RECORD[aisRoot, note: ROPE]; IPFromFourAIS: PUBLIC PROC [ipName: ROPE, aisSpecs: ARRAY[0..3] OF AISSpec, xPitch,yPitch, aisWidth: REAL, aisEndings: AISEndings _ redGrnBlu, onSide: BOOLEAN _ FALSE] ~ { ip: ImagerInterpress.Ref _ ImagerInterpress.Create[ipName]; xPitchInMeters: REAL _ xPitch*Imager.metersPerInch; yPitchInMeters: REAL _ yPitch*Imager.metersPerInch; current: NAT _ 0; action: PROC[context: Imager.Context] = { writeAIS: PROC = { aisRoot: ROPE _ aisSpecs[current].aisRoot; note: ROPE _ aisSpecs[current].note; pa: ImagerPixelArray.PixelArray _ ImagerPixelArray.Join3AIS[Rope.Cat[aisRoot, aisEndings[0], ".ais"], Rope.Cat[aisRoot, aisEndings[1], ".ais"], Rope.Cat[aisRoot, aisEndings[2], ".ais"] ]; nLines: NAT _ pa.sSize; nPixels: NAT _ pa.fSize; ppi: REAL _ nPixels/aisWidth; fontSize: REAL _ 8*ppi/Imager.pointsPerInch; Imager.ScaleT[context,Imager.metersPerPoint*Imager.pointsPerInch/ppi]; [,] _ ImageAndLabel[context, pa, note, fontSize, onSide]; }; Imager.SetColor[context, Imager.black]; Imager.MaskRectangle[context,[0,0,2*xPitchInMeters,2*yPitchInMeters]]; current _ 0; Imager.DoSave[context, writeAIS]; Imager.TranslateT[context,[xPitchInMeters, 0]]; current _ 1; Imager.DoSave[context, writeAIS]; Imager.TranslateT[context,[-xPitchInMeters, yPitchInMeters]]; current _ 2; Imager.DoSave[context, writeAIS]; Imager.TranslateT[context,[xPitchInMeters, 0]]; current _ 3; Imager.DoSave[context, writeAIS]; }; ImagerInterpress.DoPage[ip, action, 1]; ImagerInterpress.Close[ip]; }; IPFromColorAIS: PUBLIC PROC [aisRoot, ipName, note: ROPE, ppi: REAL _ 0, width: REAL _ 0, aisEndings: AISEndings _ redGrnBlu, onSide: BOOLEAN _ FALSE] RETURNS[fDim, sDim: REAL] ~ { ip: ImagerInterpress.Ref _ ImagerInterpress.Create[ipName]; action: PROC[context: Imager.Context] = { pa: ImagerPixelArray.PixelArray _ ImagerPixelArray.Join3AIS[Rope.Cat[aisRoot, aisEndings[0], ".ais"], Rope.Cat[aisRoot, aisEndings[1], ".ais"], Rope.Cat[aisRoot, aisEndings[2], ".ais"] ]; fontSize: REAL _ 8*ppi/Imager.pointsPerInch; Imager.SetColor[context, Imager.black]; Imager.MaskRectangle[context,[0,0,nPixels+2*fontSize,nLines+2*fontSize]]; [widthInPixels, heightInPixels] _ ImageAndLabel[context, pa, note, fontSize, onSide]; }; scale: REAL _ 1; nLines,nPixels, widthInPixels, heightInPixels: NAT; [nLines,nPixels] _ SizeFromAISFile[Rope.Cat[aisRoot, aisEndings[0], ".ais"]]; IF ppi <= 0 AND width <= 0 THEN ERROR; IF ppi=0 THEN ppi _ nPixels/width; scale _ Imager.metersPerPoint*Imager.pointsPerInch/ppi; ImagerInterpress.DoPage[ip, action, scale]; ImagerInterpress.Close[ip]; RETURN[fDim: widthInPixels/ppi, sDim: heightInPixels/ppi]; }; IPFromAISSquared: PUBLIC PROC [aisRoot, ipName: ROPE, ppi: REAL _ 0, width: REAL _ 0, aisEndings: AISEndings _ redGrnBlu, background: RGB ] RETURNS[fDim, sDim: REAL] ~ { ip: ImagerInterpress.Ref _ ImagerInterpress.Create[ipName]; action: PROC[context: Imager.Context] = { pa: ImagerPixelArray.PixelArray _ ImagerPixelArray.Join3AIS[Rope.Cat[aisRoot, aisEndings[0], ".ais"], Rope.Cat[aisRoot, aisEndings[1], ".ais"], Rope.Cat[aisRoot, aisEndings[2], ".ais"] ]; Imager.SetColor[context, ImagerColor.ColorFromRGB[background]]; Imager.MaskRectangle[context,[0,0,nPixels, nPixels]]; Imager.TranslateT[context, [0,(nPixels-nLines)/2]]; [widthInPixels, heightInPixels] _ ImageAndLabel[context, pa, NIL, 1, FALSE]; }; scale: REAL _ 1; nLines,nPixels, widthInPixels, heightInPixels: NAT; [nLines,nPixels] _ SizeFromAISFile[Rope.Cat[aisRoot, aisEndings[0], ".ais"]]; IF ppi <= 0 AND width <= 0 THEN ERROR; IF ppi=0 THEN ppi _ nPixels/width; scale _ Imager.metersPerPoint*Imager.pointsPerInch/ppi; ImagerInterpress.DoPage[ip, action, scale]; ImagerInterpress.Close[ip]; RETURN[fDim: widthInPixels/ppi, sDim: heightInPixels/ppi]; }; SizeFromAISFile: PROC[name: ROPE] RETURNS[nLines, nPixels: NAT] = { fRef: AIS.FRef _ AIS.OpenFile[name]; raster: AIS.Raster _ AIS.ReadRaster[fRef]; nLines _ raster.scanCount; nPixels _ raster.scanLength; }; MakeIPList: PROC [ip0,ip1,ip2,ip3,ip4,ip5: IPSpec _ NIL] RETURNS [list: LIST OF IPSpec] ~ { RETURN[LIST[ip0,ip1,ip2,ip3,ip4,ip5]]; }; IPFromRoot: PROC[aisRoot, ipDir: ROPE] RETURNS[ipName: ROPE] = { cp: FS.ComponentPositions; full: ROPE; [full, cp] _ FS.ExpandName[aisRoot]; ipName _ Rope.Cat[ipDir, Rope.Substr[base: full, start: cp.base.start, len: cp.base.length], ".ip"]; }; MakeIPSpecFromAIS: PROC [aisRoot, ipDir, note: ROPE, aisPPI, outPPI: NAT, width: REAL, colorCorrection: ColorCorrection _ NIL] RETURNS [IPSpec] ~ { fDim,sDim: REAL; ipName: ROPE _ IPFromRoot[ipDir, aisRoot]; [fDim, sDim] _ IPFromColorAIS[aisRoot: aisRoot, ipName: ipName, note: note, ppi: aisPPI, width: width]; RETURN[NEW[InterpressToTape.IPSpecRep _ [name: ipName, page: 1, pixelsPerInch: outPPI, fOrg: 0, sOrg: 0, fDim: fDim, sDim: sDim, surfaceUnitsPerPixel: 1, colorCorrection: colorCorrection, achromatic: FALSE]]]; }; MakeIPSpec: PROC [name: ROPE, fOrg, sOrg: REAL, fDim, sDim: REAL, surfaceUnitsPerPixel: NAT _ 5, colorCorrection: ColorCorrection _ NIL, ppi: NAT, achromatic: BOOLEAN] RETURNS [IPSpec] ~ { IF fDim = 0 OR sDim = 0 THEN [fOrg, sOrg, fDim, sDim] _ InterpressToTape.DefaultIPSize[name, 1]; RETURN[NEW[InterpressToTape.IPSpecRep _ [name: name, page: 1, pixelsPerInch: ppi, fDim: fDim, sDim: sDim, fOrg: fOrg, sOrg: sOrg, surfaceUnitsPerPixel: surfaceUnitsPerPixel, colorCorrection: colorCorrection, achromatic: achromatic]]]; }; END. าProduceTapesImpl.mesa Copyright ำ 1987 by Xerox Corporation. All rights reserved. Maureen Stone, July 24, 1989 12:43:16 pm PDT Production code around calls to InterpressToTape Sizes, converts to Interpress and writes tapes for images Makes sized Interpress masters from AIS Assume the context background is black, so label in white We're in meters use either ppi or longestSize, whichever is not 0 use either ppi or width, whichever is not 0 Making IPSpecs ส]˜code•Mark outsideHeaderšœ™Kšœ<™