Xref: utzoo comp.sys.mac.programmer:5630 comp.sys.mac:30102 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!gatech!prism!loligo!pepke From: pepke@loligo.cc.fsu.edu (Eric Pepke) Newsgroups: comp.sys.mac.programmer,comp.sys.mac Subject: Re: CopyBits in MPW C 3.0 Keywords: CopyBits , MPW C Message-ID: <580@loligo.cc.fsu.edu> Date: 13 Apr 89 14:30:44 GMT References: <225@uw-apl.UUCP> <98709@sun.Eng.Sun.COM> Reply-To: pepke@loligo.UUCP (Eric Pepke) Distribution: na Organization: Supercomputer Computations Research Institute Lines: 42 In article <98709@sun.Eng.Sun.COM> wert@sun.UUCP (Robert Scott Comer) writes: >Here is how you fix that: Look for the definition of CopyBits. See that first >parameter? See its type? Determine what that type is, exactly, then make sure >you pass that type in to CopyBits. > >For example, if CopyBits wants a pointer to a BitMap or PixMap, then what you >have looks like it might work, if it wants a handle to one of those you will >have to remove the * from your first argument. If you are going to condescend, at least make sure you know what you're talking about. OF COURSE CopyBits wants a pointer. The problem is that the C prototype wants a pointer to a BitMap, not to a PixMap. There are a number of ways of constructing the type cast which can seem to a novice as if they should work, but not all of them do. This code fragment compiles fine under my MPW 3.0 C: WindowPtr wind; PixMapHandle mypixhandle; HLock((Handle) mypixhandle); CopyBits(*(BitMap **) mypixhandle, &(wind->portBits), &((*mypixhandle)->bounds),&((*mypixhandle)->bounds), srcCopy, 0L); HUnlock((Handle) mypixhandle); Notice that the casting of the window to type GrafPtr is not needed. As explained in IM, a WindowPtr is the same as a GrafPtr, and to look in the extra fields in a window record, use a WindowPeek type cast. This is not the case for BitMaps and PixMaps, so the cast to BitMap ** is needed. C and Pascal are becoming more and more alike as time goes on. :-( Eric Pepke ARPA: pepke@gw.scri.fsu.edu Supercomputer Computations Research Institute MFENET: pepke@fsu Florida State University SPAN: pepke@scri Tallahassee, FL 32306-4052 BITNET: pepke@fsu Disclaimer: My employers seldom even LISTEN to my opinions. Meta-disclaimer: Any society that needs disclaimers has too many lawyers.