BMToAIS.Mesa
Last Edited by: Spreitzer, January 12, 1984 9:08 pm
DIRECTORY AIS, Graphics, GraphicsOps, IO, Rope;
BMToAIS: PROGRAM
IMPORTS AIS, Graphics, GraphicsOps, Rope =
BEGIN
ROPE: TYPE = Rope.ROPE;
Bitmap: TYPE = GraphicsOps.BitmapRef;
fRef: AIS.FRef;
w: AIS.WRef;
raster: AIS.Raster ← NEW [AIS.RasterPart];
Write: PROC [fileName: ROPE, bm: Bitmap, bitsPerPixel: CARDINAL] =
BEGIN
raster^ ← [
scanCount: bm.height,
scanLength: bm.width,
scanMode: rd,
bitsPerPixel: bitsPerPixel,
linesPerBlock: -1,
paddingPerBlock: 0];
fRef ← AIS.CreateFile[name: fileName, raster: raster];
w ← AIS.OpenWindow[f: fRef];
FOR line: INTEGER IN [0 .. INTEGER[bm.height]) DO
TRUSTED {
AIS.UnsafeWriteLine[
w: w,
buffer: [
length--in words, right?--: bm.raster,
addr: LOOPHOLE[bm.base, LONG POINTER] + LONG[bm.raster]*line],
line: line]};
ENDLOOP;
AIS.CloseWindow[w];
AIS.CloseFile[fRef];
END;
WriteEyes: PROC [prefix: ROPE, allEyes: Bitmap, size, upset: INTEGER] =
BEGIN
DoIt: PROC [view: ROPE, pos: INTEGER] =
BEGIN
GraphicsOps.DrawBitmap[self: context, bitmap: allEyes, w: 64, h: 64, x: pos*64, y: 0, xorigin: pos*64, yorigin: 64];
Write[prefix.Cat[view, ".AIS"], single, 0];
END;
single: Bitmap ← GraphicsOps.NewBitmap[size, size];
context: Graphics.Context ← GraphicsOps.NewContextFromBitmap[single];
Graphics.SetCP[context, (size-64)/2, upset];
DoIt["Left", 0];
DoIt["Right", 1];
DoIt["Back", 2];
DoIt["Front", 3];
END;
END.