home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / da / clpbrdmg.sit / iconpict.p < prev    next >
Text File  |  1990-05-24  |  2KB  |  68 lines

  1. unit UConvertor;
  2.     const
  3. {the constants are for use of the simulator only }
  4.         testID = 128; { change to reflect code resource ID }
  5.         testType = 'ICON'; { change to reflect the data type you are testing }
  6. interface
  7.     type
  8.         routineInfo = record
  9.                 entryPoint: ProcPtr;
  10.                 resID: Integer;
  11.                 parmCount: Integer;
  12.                 useDefault: boolean;
  13.             end;
  14.         routineInfoPtr = ^routineInfo;
  15.         parmInfo = record
  16.                 srcType: ResType;
  17.                 srcHandle: Handle;
  18.                 dstType: ResType;
  19.                 dstHandle: Handle;
  20.             end;
  21.         parmInfoPtr = ^parmInfo;
  22.  
  23. { the name xMain is for debugging use only, change to Main before making the code resource }
  24.  
  25.     function xMain (myInfoPtr: routineInfoPtr; parmPtr: parmInfoPtr): OSErr;
  26. implementation
  27.  
  28.     function CallExt (rtnRsrc: ResType; NamePtr: Str255; parmCount: integer; useDefault: Boolean; parmPtr: Ptr; theAddr: Ptr): OSErr;
  29.     inline
  30.         $205F, $4e90; { move.l (A7)+, A0;  jsr (A0)}
  31.  
  32.     function xMain (myInfoPtr: routineInfoPtr; parmPtr: parmInfoPtr): OSErr;
  33.         var
  34.             r: rect;
  35.             aBitMap: BitMap;
  36.             orgPort: GrafPtr;
  37.             tempPort: GrafPort;
  38.             err: OSErr;
  39.     begin
  40.         parmPtr^.dstHandle := NewHandle(128);
  41.         if parmPtr^.dstHandle <> nil then
  42.             begin
  43.                 HLock(parmPtr^.dstHandle);
  44.                 HLock(parmPtr^.srcHandle);
  45.                 SetRect(r, 0, 0, 32, 32);
  46.                 with aBitMap do
  47.                     begin
  48.                         baseAddr := parmPtr^.dstHandle^;
  49.                         rowBytes := 4;
  50.                         bounds := r;
  51.                     end;
  52.                 GetPort(orgPort);
  53.                 OpenPort(@tempPort);
  54.                 SetPortBits(aBitMap);
  55.                 ClipRect(r);
  56.                 EraseRect(r);
  57.                 DrawPicture(PicHandle(parmPtr^.srcHandle), r);
  58.                 HUnLock(parmPtr^.srcHandle);
  59.                 HUnLock(parmPtr^.dstHandle);
  60.                 SetPort(orgPort);
  61.                 parmPtr^.dstType := 'ICON';
  62.                 xMain := NoErr;
  63.             end
  64.         else
  65.             xMain := MemError;
  66.     end;
  67.  
  68. end.