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

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