home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sys / mac / programm / 20342 < prev    next >
Encoding:
Internet Message Format  |  1992-12-27  |  3.3 KB

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