home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!wupost!waikato.ac.nz!ldo
- From: ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
- Newsgroups: comp.sys.mac.programmer
- Subject: Re: What am I doin wrong?
- Message-ID: <1992Dec28.131842.12990@waikato.ac.nz>
- Date: 28 Dec 92 13:18:42 +1300
- References: <1992Dec27.133008.1@vax1.mankato.msus.edu>
- Organization: University of Waikato, Hamilton, New Zealand
- Lines: 79
-
- In article <1992Dec27.133008.1@vax1.mankato.msus.edu>, t303grey@vax1.mankato.msus.edu writes:
- >
- > *** problem 1: (Error checking code are deleted, assume best case)
- >
- > GetGWorld( &oldPort, &oldDevice );
- > Err = NewGWorld( &offWorld, 8, &theScreen, NULL, NULL, 0 );
- > SetGWorld( offWorld, NULL );
- >
- > pixBase = GetGWorldPixMap( offWorld );
- > LockPixels( pixBase );
- >
- > EraseRect( &theScreen );
- >
- > SetGWorld( oldPort, oldDevice );
- >
- > CopyBits( &pixBase,
- > &(*(GrafPtr) pCWindow).portBits,
- > &theScreen, &theScreen, srcCopy, NULL );
- >
- > UnlockPixels( pixBase );
- >
- > Strange thing about this code is if I substitute the 1st argument of CopyBits
- > call to &(*(GrafPtr) offWorld).portBits it works fine.
-
- That's right. The Color QuickDraw version of CopyBits can take three different
- forms for the srcBits and dstBits arguments: either a pointer to the actual
- BitMap field of a B&W GrafPort, a pointer to a PixMap record (I assume you
- have to lock down the PixMapHandle first), or a pointer to the pseudo-BitMap
- field of a CGrafPort. It can distinguish these three cases simply by
- checking the top two bits of the rowBytes field. For colour work, I find the
- third form the easiest to use.
-
- To save typecasting, I modified the definition of the CGrafPort structure as
- follows:
-
- TYPE
- CGrafPort =
- RECORD
- device : ShortInt;
- CASE : BOOLEAN OF
- | FALSE:
- portPixMap : PixMapHandle;
- portVersion : ShortInt;
- grafVars : GVarHandle;
- chExtra : ShortInt;
- pnLocHFrac : ShortInt;
- | TRUE:
- portBits : BitMap; (* used only for CopyBits/CopyMask/CopyDeepMask *)
- END (*CASE*);
- portRect : Rect;
-
- ...
-
- grafProcs : CQDProcsPtr;
- END (*RECORD*);
-
- But of course this only works with Modula-2...
-
- > But according to IM7 we
- > should never dereference GWorld (p21-5 paragraph 3) to get to pixMap. Right?
-
- This has to do with creating offscreen GWorlds on machines without Color
- QuickDraw. Since all the ports are B&W GrafPorts in this case, the direct
- reference to the BitMap field should still work.
-
- By the way, I assume you already know that GetGWorldPixMap doesn't work
- properly in system versions prior to 7.0. Can somebody clarify whether the
- bug was introduced in version 1.2 of 32-Bit QuickDraw, or whether it was
- present in version 1.0 as well?
-
- Lawrence D'Oliveiro fone: +64-7-856-2889
- Computer Services Dept fax: +64-7-838-4066
- University of Waikato electric mail: ldo@waikato.ac.nz
- Hamilton, New Zealand 37^ 47' 26" S, 175^ 19' 7" E, GMT+13:00
- The landscape was snow and green ice on broken mountains. These weren't old
- mountains, worn down by time and weather and full of gentle ski slopes, but
- young, sulky, adolescent mountains. One yodel out of place would attract, not
- the jolly echo of a lonely goatherd, but fifty tons of express-delivery snow.
- -- Terry Pratchett, "Reaper Man"
-