-- AIS.mesa
-- Last changed by Maureen Stone, 17-Nov-81 14:11:11
-- Last changed by Doug Wyatt, 18-Aug-81 17:46:12
DIRECTORY
File,
Space,
AISFormat;
AIS: DEFINITIONS = {
-- Types --
FRef: TYPE = LONG POINTER TO FRep; -- AIS File
FRep: TYPE = RECORD [
file: File.Capability, -- the AIS file
write: BOOLEAN ← FALSE,
abase: File.PageNumber ← 0, -- first page of attribute part
rbase: File.PageNumber ← 0, -- first page of raster part
raster: Raster, -- the raster information
wordsPerLine: CARDINAL ← 0, -- words per scan line
buffersize: Space.PageCount ← 0 --raster buffer size
];
WRef: TYPE = LONG POINTER TO WRep; -- AIS Window
WRep: TYPE = RECORD [
fref: FRef ← NIL, --file descriptor
bref: BRef ← NIL, --file buffer descriptor (mess with this at your own risk!)
firstScan: CARDINAL ← 0,
lastScan: CARDINAL ← 0,
firstPixel: CARDINAL ← 0,
lastPixel: CARDINAL ← 0,
wordsPerLine: CARDINAL ← 0, --the number of words for one windowed scan line
pixelsPerWord: CARDINAL ← 0,
nextScanLine: CARDINAL ← 0,
currline:CARDINAL←177777B,
clineaddr:LONG POINTER←NIL];
BRef: TYPE = LONG POINTER TO BRep; --AIS file buffer
BRep: TYPE = RECORD [
space: Space.Handle,
addr: LONG POINTER ← NIL, -- points to first scan line
first,last: CARDINAL ← 0 -- first and last scan line numbers
];
ScanMode: TYPE = {ru, ul, ld, dr, rd, ur, lu, dl};
-- Scan direction for pixels and lines; for example, "rd" means:
-- successive pixels move rightward in the image
-- successive scanlines move downward in the image
--attribute definitions
Raster: TYPE = LONG POINTER TO RasterPart;
RasterPart: TYPE = RECORD [
scanCount: CARDINAL, -- number of scan lines
scanLength: CARDINAL, -- number of pixels per scan line
scanMode: ScanMode, -- scanning directions
bitsPerPixel: [0..16], -- number of bits per pixel
linesPerBlock: INTEGER, -- for blocked AIS files. -1=no blocks
paddingPerBlock: CARDINAL --in words
];
Placement: TYPE = LONG POINTER TO PlacementPart;
PlacementPart: TYPE = RECORD [
xLeft: INTEGER,
yBottom: INTEGER,
xWidth: INTEGER,
yHeight: INTEGER
];
Photometry: TYPE = LONG POINTER TO PhotometryPart;
PhotometryPart: TYPE = RECORD [
signal: AISFormat.SignalType,
sense: AISFormat.Sense,
scaleType: AISFormat.ScaleType,
pointA: AISFormat.Point,
pointB: AISFormat.Point,
pointC: AISFormat.Point,
spotType: AISFormat.SpotType,
spotWidth: INTEGER, -- in units of 100*(width in pixels)
spotLength: INTEGER, -- in units of 100*(length in scanlines)
sampleMin: INTEGER,
sampleMax: INTEGER,
histogramLength: INTEGER --0 or -1 means no histogram
];
Histogram: TYPE = LONG POINTER TO RECORD[SEQUENCE len: CARDINAL OF INTEGER];
-- Errors --
Error: SIGNAL[type: ErrorType];
ErrorType: TYPE = {invalidFileName, fileAlreadyExists, fileNotFound,
invalidFile, readOnlyFile, bufferTooSmall, outOfRange,
invalidParameter, notImplemented,badWindow, volumeFull};
-- File operations --
CreateFile: PROC[name: LONG STRING, raster: Raster,
overwrite: BOOLEAN ← FALSE, attributeLength: CARDINAL ← 0] RETURNS[f: FRef];
DeleteFile: PROC[name: LONG STRING] RETURNS[success: BOOLEAN];
OpenFile: PROC[name: LONG STRING, write: BOOLEAN ← FALSE] RETURNS[f: FRef];
--DON'T reuse this FRef
CloseFile: PROC[f: FRef];
--read and write attribute information
--For everthing but raster, client passes pointers to records of the correct type.
--A RETURN of FALSE from a Read indicates that the attribute was not present
maxComment: CARDINAL = 256;
--If string buffer is too short, will truncate
ReadComment: PROC[f: FRef, s: LONG STRING] RETURNS[BOOLEAN];
WriteComment: PROC[f: FRef, s: LONG STRING];
ReadPlacement: PROC[f: FRef, placement: Placement] RETURNS[BOOLEAN];
WritePlacement: PROC[f: FRef, placement: Placement];
--histogram is separate from the rest of the photometry info because it is variable length
--Histogram Length is in Photometry. (0 or -1 means no histogram)
ReadPhotometry: PROC[f: FRef, photometry: Photometry] RETURNS[BOOLEAN];
--if histogram buffer is too short, will truncate
ReadHistogram: PROC[f: FRef, histogram: Histogram] RETURNS[BOOLEAN];
--Error is histogram length # photometry.histogramLength
WritePhotometry: PROC[f: FRef, photometry: Photometry, histogram: Histogram ← NIL];
--raster info always present
--raster info can only be written when doing a CreateFile;
ReadRaster: PROC[f: FRef, raster: Raster];
-- Window operations --
--values will default to file values
OpenWindow: PROC[f: FRef, firstScan: CARDINAL ← 0, lastScan: CARDINAL ← LAST[CARDINAL],
firstPixel: CARDINAL ← 0, lastPixel: CARDINAL ← LAST[CARDINAL]]
RETURNS[w: WRef];
--do NOT reuse this WRef
CloseWindow: PROC[w: WRef];
GetWindowParams: PROC[w: WRef] RETURNS[firstScan: CARDINAL, lastScan: CARDINAL,
firstPixel: CARDINAL, lastPixel: CARDINAL];
--the minimum number of words in a scan line buffer for a given window
MinBufferSize: PROC[w: WRef] RETURNS[length: CARDINAL];
--returns TRUE if the current scan line is the last scan line in the window
EndOfWindow: PROC[w: WRef] RETURNS[BOOLEAN];
Buffer: TYPE = RECORD [length: LONG CARDINAL, addr: LONG POINTER];
ReadLine: PROC[w: WRef, buffer: Buffer, line: INTEGER ← -1];
WriteLine: PROC[w: WRef, buffer: Buffer, line: INTEGER ← -1];
ReadLines: PROC[w: WRef, buffer: Buffer,
line: INTEGER ← -1, count: CARDINAL ← 1]
RETURNS[numberRead: CARDINAL];
WriteLines: PROC[w: WRef, buffer: Buffer,
line: INTEGER ← -1, count: CARDINAL ← 1]
RETURNS[numberWritten: CARDINAL];
ReadSample: PROC[w: WRef, line,pixel: CARDINAL] RETURNS[value: CARDINAL];
WriteSample: PROC[w: WRef, value: CARDINAL, line,pixel: CARDINAL];
-- CreatePattern might be handy, but isn't implemented yet.
AISImpl: PROGRAM;
}.