home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / mac / programm / 13922 < prev    next >
Encoding:
Text File  |  1992-08-12  |  3.2 KB  |  104 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!munnari.oz.au!manuel!merlin!ralph
  3. From: ralph@merlin.anu.edu.au (Ralph Sutherland)
  4. Subject: Re: DESPERATE: switching pixmaps w/ SetPortPix
  5. Message-ID: <1992Aug13.070030.24697@newshost.anu.edu.au>
  6. Sender: news@newshost.anu.edu.au
  7. Organization: Mt. Stromlo and Siding Spring Observatories
  8. References: <m0mGARZ-0003hxC@envy.reed.edu>
  9. Date: Thu, 13 Aug 92 07:00:30 GMT
  10. Lines: 92
  11.  
  12. Newsgroups: comp.sys.mac.programmer
  13. Subject: Re: DESPERATE: switching pixmaps w/ SetPortPix
  14. Summary: 
  15. Expires: 
  16. References: <m0mGARZ-0003hxC@envy.reed.edu>
  17. Sender: 
  18. Followup-To: 
  19. Distribution: 
  20. Organization: Mt. Stromlo and Siding Spring Observatories
  21. Keywords: 
  22.  
  23.  In Article 21019 in comp.sys.mac.programmer:
  24.  envy@reed.edu!envy.Reed.Edu!pcalahan (Patrick John Calahan) Wrote:
  25.  
  26. >I still need a few lines of code which will do the following.
  27. >
  28. >SetPortPix(myOffscreenPixMap);
  29. >
  30.  
  31. I tried email but it bounced and there didn't ssem to be any further posts
  32. So...
  33.  
  34.  
  35. Is this pseudocode more useful? (excuse the tabs, and as always no guarantees):
  36.  
  37. variables:
  38.  
  39.     aPort:Grafptr;              {general purpose port vriable}
  40.     Coffport:CGrafPtr;          {temp colour port}
  41.     oldpix:PixMapHandle;        {save the old pixmap}
  42.     offpix:PixMapHandle;        {offscreen pixmap, initialised elsewhere}
  43.     pwidth,pheight:integer;     {offscreen size}
  44.     r:rect;                     {offscreen size}
  45.     anRGB:RGBColor;             {anRGB color!}
  46.  
  47. .
  48. .
  49. .
  50.  
  51.       GetPort(aPort);
  52.  
  53.       Coffport := nil; {paranoia}
  54.  
  55.       Coffport := cGrafPtr(NewPtr(sizeof(cGrafport)));
  56.                                       {allocate temp port to hold pixmap}
  57.  
  58.       if (Coffport <> nil)) and (Memerror = Noerr) then {Always check....}
  59.        begin
  60.  
  61.            OpenCPort(Coffport);             {init port}
  62.            oldpix := Coffport^.portPixMap;  {save pixmap}
  63.  
  64.            setport(Grafptr(CoffPort));     {set port is a good idea}
  65.            SetPortpix(offpix);             {use the offpix}
  66.            portsize(pwidth, pheight);      {Size IS important}
  67.            rectrgn(CoffPort^.VisRgn, r);   {needed if the pixmap is
  68.                                             larger than the screen}
  69.            cliprect(r);                    { just so we have a clip}
  70.            with anRGB do
  71.              begin
  72.                   red := $C000;
  73.                   green := $C000;
  74.                   blue := $4000;
  75.              end;
  76.            RGBForeColor(anRGB);           {sort of yellow...}
  77.            Fillrect(brect, black);        {solid colour}
  78.  
  79.            SetPortpix(oldpix);            {put back the pix,
  80.                                           I don't know if you really
  81.                                           have to restore the visrgn}
  82.  
  83.            setPort(aPort);                { move to another port
  84.                                             *before* you dispose!}
  85.  
  86.            CloseCPort(CoffPort);          {dispose}
  87.            disposPtr(Pointer(CoffPort));  {clean Up}
  88.  
  89.          end;
  90. .
  91. .
  92. .
  93.  
  94. Hope this helps
  95.  
  96. cheers
  97. Ralph Sutherland
  98.  
  99.  
  100. -- 
  101. ---- Ralph S. Sutherland      Mount Stromlo & Siding Spring Observatories.
  102. ---- ralph@madras.anu.edu.au  The Australian National University.
  103. ---- rss100@cscgpo.anu.edu.au --------------------------------------------
  104.