home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!munnari.oz.au!manuel!merlin!ralph
- From: ralph@merlin.anu.edu.au (Ralph Sutherland)
- Subject: Re: DESPERATE: switching pixmaps w/ SetPortPix
- Message-ID: <1992Aug13.070030.24697@newshost.anu.edu.au>
- Sender: news@newshost.anu.edu.au
- Organization: Mt. Stromlo and Siding Spring Observatories
- References: <m0mGARZ-0003hxC@envy.reed.edu>
- Date: Thu, 13 Aug 92 07:00:30 GMT
- Lines: 92
-
- Newsgroups: comp.sys.mac.programmer
- Subject: Re: DESPERATE: switching pixmaps w/ SetPortPix
- Summary:
- Expires:
- References: <m0mGARZ-0003hxC@envy.reed.edu>
- Sender:
- Followup-To:
- Distribution:
- Organization: Mt. Stromlo and Siding Spring Observatories
- Keywords:
-
- In Article 21019 in comp.sys.mac.programmer:
- envy@reed.edu!envy.Reed.Edu!pcalahan (Patrick John Calahan) Wrote:
-
- >I still need a few lines of code which will do the following.
- >
- >SetPortPix(myOffscreenPixMap);
- >
-
- I tried email but it bounced and there didn't ssem to be any further posts
- So...
-
-
- Is this pseudocode more useful? (excuse the tabs, and as always no guarantees):
-
- variables:
-
- aPort:Grafptr; {general purpose port vriable}
- Coffport:CGrafPtr; {temp colour port}
- oldpix:PixMapHandle; {save the old pixmap}
- offpix:PixMapHandle; {offscreen pixmap, initialised elsewhere}
- pwidth,pheight:integer; {offscreen size}
- r:rect; {offscreen size}
- anRGB:RGBColor; {anRGB color!}
-
- .
- .
- .
-
- GetPort(aPort);
-
- Coffport := nil; {paranoia}
-
- Coffport := cGrafPtr(NewPtr(sizeof(cGrafport)));
- {allocate temp port to hold pixmap}
-
- if (Coffport <> nil)) and (Memerror = Noerr) then {Always check....}
- begin
-
- OpenCPort(Coffport); {init port}
- oldpix := Coffport^.portPixMap; {save pixmap}
-
- setport(Grafptr(CoffPort)); {set port is a good idea}
- SetPortpix(offpix); {use the offpix}
- portsize(pwidth, pheight); {Size IS important}
- rectrgn(CoffPort^.VisRgn, r); {needed if the pixmap is
- larger than the screen}
- cliprect(r); { just so we have a clip}
- with anRGB do
- begin
- red := $C000;
- green := $C000;
- blue := $4000;
- end;
- RGBForeColor(anRGB); {sort of yellow...}
- Fillrect(brect, black); {solid colour}
-
- SetPortpix(oldpix); {put back the pix,
- I don't know if you really
- have to restore the visrgn}
-
- setPort(aPort); { move to another port
- *before* you dispose!}
-
- CloseCPort(CoffPort); {dispose}
- disposPtr(Pointer(CoffPort)); {clean Up}
-
- end;
- .
- .
- .
-
- Hope this helps
-
- cheers
- Ralph Sutherland
-
-
- --
- ---- Ralph S. Sutherland Mount Stromlo & Siding Spring Observatories.
- ---- ralph@madras.anu.edu.au The Australian National University.
- ---- rss100@cscgpo.anu.edu.au --------------------------------------------
-