OptronicsTape.mesa
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
Maureen Stone, July 24, 1989 12:31:16 pm PDT
Crow, March 30, 1989 12:50:26 pm PST
Format to read/write Optronics tape format.
RGB pixels, linear in density. One record per scanline.
Each color separation is a separate file.
DIRECTORY
Rope USING [ROPE],
ImagerPixel USING [PixelBuffer],
ImagerSample USING [Sample],
UnixTapeOps USING [TapeHandle, Density],
TapesCommon USING [FileHandleList];
OptronicsTape: CEDAR DEFINITIONS
~ BEGIN
ROPE: TYPE ~ Rope.ROPE;
TapeHandle: TYPE ~ UnixTapeOps.TapeHandle;
TapeError: SIGNAL [reason: ErrorDesc];
ErrorDesc: TYPE ~ RECORD [code: ATOM, explanation: Rope.ROPE];
Write Tape
FileSpec: TYPE = REF FileSpecRep;
FileSpecRep: TYPE = RECORD[
pixelsPerInch: PixelsPerInch,
nLines, nPixels: NAT,
rgbInterleaved: BOOLEAN ← FALSE,
maxD: REAL ← 2.0 --suggested values: 2.0 for gray, 1.5 for color
];
FileSpecList: TYPE = LIST OF FileSpec;
ColorType: TYPE = {rgb, gray, singleColor}; --linear in density
PixelsPerInch: TYPE = {ppi63, ppi127, ppi254, ppi508, ppi1015, ppi2030};
The maximum size on nPixels and nLines for each resolution is:
625, 1.25K, 2.5K, 5K, 10K, 20K
From TapesCommon
FileHandle: TYPE = REF FileHandleRep;
FileHandleRep: TYPE = RECORD[
newLine: PROC[self: FileHandle, line: PixelBuffer] RETURNS[eof: BOOLEAN],
data: REF
];
FileHandleList: TYPE = LIST OF FileHandle;
WriteTape: PROC [tapeHandle: TapeHandle, header: ROPE, files: FileSpecList] RETURNS [TapesCommon.FileHandleList];
Writes header and returns a list of FileHandle. Client rasterizes into each FileHandle in turn. newLine.eof is TRUE when tape has recorded nLines worth of rasters. Client can check newLine.eof to verify that the client and the tape are still in sync.
In interleaved format, generates a File handle that expects an 3 deep PixelBuffer (r,g,b) and writes an interleaved red, green, blue file.
Otherwise, expects only a 1 deep PixelBuffer
AISToTape: PROC [aisRootName: ROPE, color: BOOLEANTRUE, pixelsPerInch: NAT ← 254];
Writes single AIS file (3 for color) to tape. Errors:
 - can't reach tape (not mounted, etc.)
 - image at specified pixelsPerInch won't fit on Optronics
Read Tape
ReadHeader: PROC [tapeHandle: TapeHandle] RETURNS [ROPE];
Reads the header block
FileToAIS: PROC [tapeHandle: TapeHandle, fileNumber: NAT, colorType: ColorType, aisRootName: ROPE, reduce: NAT ← 4];
Converts a tape file to 1 or 3 AIS files.
If colorType=rgb the fileNumber should be the red file.
colorType=gray and colorType=singleColor are treated indentically.
Utilities
TRCTable: TYPE = REF TRCTableRec;
TRCTableRec: TYPE = RECORD[length: NAT, values: SEQUENCE maxLength: NAT OF ImagerSample.Sample];
MakeRGBToDensity: PUBLIC PROC[maxSampleOut, maxSampleIn: NAT ← 255, maxD: REAL ← 2.0] RETURNS[TRCTable];
MakeDensityToRGB: PUBLIC PROC[maxSampleOut, maxSampleIn: NAT ← 255, maxD: REAL ← 2.0] RETURNS[TRCTable];
Makes the tables that drive RGBToDensity and DensityToRGB
RGBToDensity: PROC [raster: ImagerPixel.PixelBuffer, rgbToDensity: TRCTable];
DensityToRGB: PROC[raster: ImagerPixel.PixelBuffer, densityToRGB: TRCTable];
Used internally, exported here for convenience of clients
The length of the TRCTable should be the same as the size of the pixels in the raster
Sizes
A big tape is 2400 feet, a small tape is 600 feet.
SizeOfFile: PROC [fileSpec: FileSpec, density: UnixTapeOps.Density ← GCR6250] RETURNS [sizeInFeet: REAL];
The file (three color files or one intensity file)
SizeOfHeader: PROC [density: UnixTapeOps.Density ← GCR6250] RETURNS [sizeInFeet: REAL];
The header block
SizeOfList: PROC [files: FileSpecList, density: UnixTapeOps.Density ← GCR6250] RETURNS [sizeInFeet: REAL];
Convenience proc. SizeOfFile for each file in list + SizeOfHeader
END.