-- TJaMImageImpl.mesa
-- Last changed by Bill Paxton, March 12, 1982 8:35 am
-- Last changed by Doug Wyatt, September 13, 1982 1:21 pm
-- Last Edited by: January 31, 1984 2:20:16 pm PST

DIRECTORY
Graphics,
GraphicsBasic,
GraphicsOps,
JaM,
Rope USING [ROPE],
Real,
TJaMGraphics,
TJaMGraphicsInfo;

TJaMImageImpl: CEDAR PROGRAM
IMPORTS Graphics,
GraphicsOps,
JaM,
Real,
TJaMGraphics
EXPORTS TJaMGraphicsInfo = {

JDrawImage: PROCEDURE [frame: JaM.State] = {
Draw: PROC [dc: Graphics.Context] = { Graphics.DrawImage[dc,image] };
name: Rope.ROPE;
image: GraphicsBasic.ImageRef;
name ← JaM.PopRope[frame];
image ← GraphicsOps.NewAisImage[name];
TJaMGraphics.Painter[Draw, frame];
};

JCopyScreen: PROCEDURE [frame: JaM.State] = {
Get: PROC RETURNS [CARDINAL] = {
  RETURN [Real.RoundC[MAX[JaM.PopReal[frame],0.0]]] };
 y2: CARDINAL ← Get[];
 x2: CARDINAL ← Get[];
 y1: CARDINAL ← Get[];
 x1: CARDINAL ← Get[];
Copy: PROC [dc: Graphics.Context] = {
  GraphicsOps.DrawBitmap[
   self: dc,
   bitmap: GraphicsOps.ScreenBitmap[],
   w: x2-x1,
   h: y2-y1,
   x: x1,
   y: y1,
   xorigin: (x1+x2)/2,
   yorigin: (y1+y2)/2
   ] };
IF x1 > x2 THEN { temp: CARDINAL ← x1; x1 ← x2; x2 ← temp };
IF y1 > y2 THEN { temp: CARDINAL ← y1; y1 ← y2; y2 ← temp };
 TJaMGraphics.Painter[Copy, frame];
 };

RegisterImage: PUBLIC PROC[frame: JaM.State] = {
 JaM.Register[frame,".drawimage",JDrawImage];
 JaM.Register[frame,".copyscreen",JCopyScreen];
 };

}...