-- AISFormat.mesa
-- Last changed by Maureen Stone, 8-Oct-81 11:31:05
-- Last changed by Doug Wyatt, 13-Aug-81 15:41:02

-- Definition of AIS (Array of Intensity Samples) file format

AISFormat: DEFINITIONS = {

aisPassword: INTEGER = -31574;

aisWordsPerPage: CARDINAL = 1024;

unused: INTEGER = -1; -- for unused values in Placement and Photometry parts

Header: TYPE = MACHINE DEPENDENT RECORD [
  password: INTEGER, attributeLength: CARDINAL];

PartType: TYPE = MACHINE DEPENDENT {nil(0),
  raster(1), placement(2), photometry(3), comment(4), (77B)};

PartHeader: TYPE = MACHINE DEPENDENT RECORD[type: PartType, length: [0..1777B]];

CodingType: TYPE = MACHINE DEPENDENT {uca(1)};

RasterPart: TYPE = MACHINE DEPENDENT RECORD [
  part(0): PartHeader,
  scanCount(1): CARDINAL,
  scanLength(2): CARDINAL,
  scanDir(3): CARDINAL,
  samplesPerPixel(4): CARDINAL,
  coding(5:0..79): SELECT codingType(5): CodingType FROM
    uca => [ -- Uncompressed array
      bitsPerSample(6): CARDINAL,
      wordsPerScanLine(7): CARDINAL,
      scanLinesPerBlock(8): INTEGER,	-- -1 means no blocking
      paddingPerBlock(9): CARDINAL -- in words
      ],
    ENDCASE
  ];

PlacementPart: TYPE = MACHINE DEPENDENT RECORD [
  part: PartHeader,
  xLeft: INTEGER,
  yBottom: INTEGER,
  xWidth: INTEGER,
  yHeight: INTEGER
  ];

PhotometryPart: TYPE = MACHINE DEPENDENT RECORD [
  part: PartHeader,
  signal: SignalType,  
  sense: Sense,  
  scaleType: ScaleType,
  pointA: Point,
  pointB: Point,
  pointC: Point,
  spotType: 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,
  -- followed by Histogram if histogramLength is not 0 or -1
  histogram: SEQUENCE COMPUTED CARDINAL OF INTEGER
  ];


SignalType: TYPE = MACHINE DEPENDENT {blackAndWhite(0),
  red(1), blue(2), green(3), cyan(4), magenta(5), yellow(6), x(7), y(8),
  RGB(100), CMY(101), CMYB(102), Yxy(103),
  comments(177776B), undefined(177777B)};

Sense: TYPE = MACHINE DEPENDENT {largerIsLighter(0), largerIsDarker(1),
  undefined(177777B)};

ScaleType: TYPE = MACHINE DEPENDENT {reflectance(1), density(2),
  comments(177776B), undefined(177777B)};

Point: TYPE = MACHINE DEPENDENT RECORD [sample: INTEGER, level: INTEGER];

SpotType: TYPE = MACHINE DEPENDENT {rectangular(1), circular(2),
  comments(177776B), undefined(177777B)};

CommentPart: TYPE = MACHINE DEPENDENT RECORD [
  part: PartHeader,
  chars: PACKED SEQUENCE COMPUTED CARDINAL OF CHARACTER
  ];
-- Comment string is chars[1..LOOPHOLE[chars[0],CARDINAL]]

}.