Path: utzoo!attcan!uunet!mailrus!cs.utexas.edu!usc!apple!stevec From: stevec@Apple.COM (Steve Christensen) Newsgroups: comp.sys.mac.programmer Subject: Re: Help with icl8's... Message-ID: <9433@goofy.Apple.COM> Date: 26 Jul 90 16:39:59 GMT References: <3681@crash.cts.com> Organization: Apple Computer Inc., Cupertino, CA Lines: 51 In article <3681@crash.cts.com> mdavis@pro-sol.cts.com (Morgan Davis) writes: >... >Here is a short routine that took me a while to figure out. If anyone >knows of a better way to do this, PLEASE let me know. > >/***************************************************************************** > ** > ** PlotIcl8 > ** > ** Like PlotIcon, this function uses the same arguments, only the the icon's > ** handle belongs to a 1K icl8 resource. > ** > **/ > >void >PlotIcl8 (register Rect *dest, register Handle theIcon) >{ > register PixMapHandle pm; > register byte hAttrs; > CGrafPtr gp; > > GetPort (&gp); > pm = NewPixMap(); > HLock (pm); > CopyPixMap (gp->portPixMap, pm); > hAttrs = HGetState (theIcon); > HLock (theIcon); > (**pm).baseAddr = *theIcon; > HSetState (theIcon, hAttrs); > (**pm).rowBytes = 32 | 0x8000; > SetRect(&(**pm).bounds, 0, 0, 32, 32); > CopyBits(*pm, &(*gp).portPixMap, &(**pm).bounds, dest, 0, NULL); > DisposPixMap (pm); >} Actually the "hSetState(theIcon, hAttrs)" should be moved below the CopyBits() call since CopyBits can move memory, and if the icon is unlocked, it could end up drawing garbage... steve -- ____________________________________________________________________ Steve Christensen Internet: stevec@goofy.apple.com Apple Computer, Inc. AppleLink: STEVEC 20525 Mariani Ave, MS 81-CS CompuServe: 76174,1712 Cupertino, CA 95014 "You just contradicted me." "No I didn't." ____________________________________________________________________