home *** CD-ROM | disk | FTP | other *** search
/ Carousel Volume 2 #1 / carousel.iso / mactosh / da / clipmagi.sit / iconpict.p < prev    next >
Text File  |  1989-06-01  |  2KB  |  64 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 xMain (myInfoPtr: routineInfoPtr; parmPtr: parmInfoPtr): OSErr;
  29.         var
  30.             r: rect;
  31.             aBitMap: BitMap;
  32.             orgPort: GrafPtr;
  33.             tempPort: GrafPort;
  34.             err: OSErr;
  35.     begin
  36.         parmPtr^.dstHandle := NewHandle(128);
  37.         if parmPtr^.dstHandle <> nil then
  38.             begin
  39.                 HLock(parmPtr^.dstHandle);
  40.                 HLock(parmPtr^.srcHandle);
  41.                 SetRect(r, 0, 0, 32, 32);
  42.                 with aBitMap do
  43.                     begin
  44.                         baseAddr := parmPtr^.dstHandle^;
  45.                         rowBytes := 4;
  46.                         bounds := r;
  47.                     end;
  48.                 GetPort(orgPort);
  49.                 OpenPort(@tempPort);
  50.                 SetPortBits(aBitMap);
  51.                 ClipRect(r);
  52.                 EraseRect(r);
  53.                 DrawPicture(PicHandle(parmPtr^.srcHandle), r);
  54.                 HUnLock(parmPtr^.srcHandle);
  55.                 HUnLock(parmPtr^.dstHandle);
  56.                 SetPort(orgPort);
  57.                 parmPtr^.dstType := 'ICON';
  58.                 xMain := NoErr;
  59.             end
  60.         else
  61.             xMain := MemError;
  62.     end;
  63.  
  64. end.