-- JaMAISimpl.mesa
-- Mesa 6 version
-- Last changed by John Warnock September 17, 1980 2:33 PM

DIRECTORY
ImageObj,
AISObj,
Real,
Vector,
JaMGraphicsDefs,
Graphics,
JaMFnsDefs USING [ PushInteger, PopInteger, PopString, GetReal, Register];

JaMAISimpl: PROGRAM
IMPORTS JaMFnsDefs,ImageObj,AISObj,JaMGraphicsDefs, Graphics =
{OPEN JaMFnsDefs,ImageObj,AISObj;
ais:Handle;

JOpenAIS: PROCEDURE =
{s:STRING←[64];
PopString[s];
ais←NewAISObj[s];
};

JScanCount: PROCEDURE = {
c:CARDINAL;
c←GetScanCount[ais];
PushInteger[c];
};


JScanLength: PROCEDURE = {
c:CARDINAL;
c←GetScanLength[ais];
PushInteger[c];
};

JSamplesPerPixel: PROCEDURE = {
c:CARDINAL;
c←GetSamplesPerPixel[ais];
PushInteger[c];
};

JBitsPerSample: PROCEDURE = {
c:CARDINAL;
c←GetBitsPerSample[ais];
PushInteger[c];
};

JReadSample: PROCEDURE = {
i,j:REAL;
c:CARDINAL;
j←ABS[GetReal[]];
i←ABS[GetReal[]];
c←ReadSample[ais,i,j];
PushInteger[c];
};

JDrawAIS:PROCEDURE=
{
dc:Graphics.DisplayContext;
dc←JaMGraphicsDefs.GetDC[];
Graphics.DrawImage[dc,ais]};
JFree: PROCEDURE = {
Free[@ais];
};


Register[".openais"L,JOpenAIS];
Register[".getscancount"L,JScanCount];
Register[".getscanlength"L,JScanLength];
Register[".getsamplesperpixel"L,JSamplesPerPixel];
Register[".getbitspersample"L,JBitsPerSample];
Register[".readsample"L,JReadSample];
Register[".drawais"L,JDrawAIS];
Register[".closeais"L,JFree];
}.