home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sys / mac / programm / 15333 < prev    next >
Encoding:
Internet Message Format  |  1992-09-10  |  3.6 KB

  1. Path: sparky!uunet!decwrl!waikato.ac.nz!ldo
  2. From: ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Re: The Pallette manager
  5. Message-ID: <1992Sep11.181806.10762@waikato.ac.nz>
  6. Date: 11 Sep 92 18:18:06 +1200
  7. References: <MHALL.92Sep8155808@occs.cs.oberlin.edu>
  8. Distribution: comp.sys.mac.programmer
  9. Organization: University of Waikato, Hamilton, New Zealand
  10. Lines: 66
  11.  
  12. In article <MHALL.92Sep8155808@occs.cs.oberlin.edu>, mhall@occs.cs.oberlin.edu (Matthew Hall) writes:
  13. >
  14. > I am drawing a 256 color plot in an offscreen pixmap.  I set the
  15. > offscreen pmtable to whatever clut I wish to choose.  Then, from that
  16. > I creat a palette optimized for the current color level (or none for
  17. > direct devices).  So, if I'm in 16 colors, I would take one of every
  18. > 16 colors in the 256 color clut that I loaded in (with black and white
  19. > appropriately placed) and place them in the palette. Then I set the
  20. > app's default palette to this new palette.
  21.  
  22. An easier way might be to use the pmInhibit flags. That way you can specify
  23. for each palette entry which screen depths to use it at, and you don't have
  24. to check the screen depth before setting up your palette.
  25.  
  26. >  This way, I can
  27. > draw directly into the offscreen map since the positions of the colors
  28. > in the clut don't change, and I don't have to use
  29. > pmtolerant+pmexplicit, or setentries, and I can draw in an ideal color
  30. > environment and let PM take care of tolerance and updates.
  31.  
  32. Hang on--you don't need a palette for an offscreen port. The main point of
  33. palettes is for use with on-screen windows. The only point with attaching
  34. a palette to an offscreen port would be so you can use PmForeColor and
  35. PmBackColor to quickly specify colours from the palette. Tolerant and
  36. animated entries don't mean anything in an offscreen palette.
  37.  
  38. [problems with on-screen display omitted]
  39.  
  40. >  Now when I draw direct (plug index values in the data) into the
  41. > pixmap, and copybits to the screen
  42. > everything is fine. $FF turns to black, etc.  So the problem seems to
  43. > be that fillrect is placing the (teh) wrong index into the pixmap.  Is
  44. > this because my offscreen port is using the current gdevice, and
  45. > thinks black is somewhere else in my clut than it actually is? If so,
  46. > do I have to create a new gdevice for the pixmap?
  47. > Actually, is my method compatible? Is it stupid?  and why the strange
  48. > problems.
  49.  
  50. What exactly *is* your method? If you're directly poking colour table
  51. entries, are you remembering to call CTabChanged so QuickDraw knows what
  52. you've been up to? If you want a custom colour table for your pixmap, then
  53. *YES*, you *DO* have to create a custom GDevice. This is because the mapping
  54. from the colours you ask for to actual pixel values is done using an inverse
  55. colour table, and you find those in the GDevice structure, not in the PixMap.
  56.  
  57. Are you using the GWorld routines? If not, I highly recommend them. Here's how
  58. you create a GWorld:
  59.  
  60.     Err := NewGWorld
  61.       (
  62.         MyGWorld, (* ptr to returned GWorld *)
  63.         PixelDepth, (* number of bits per pixel *)
  64.         BoundsRect, (* bounds of GWorld's PortRect *)
  65.         CTable, (* custom colour table or NIL for default *)
  66.         NIL, (* don't want to use an existing GDevice *)
  67.         Flags (* specifying useTempMem puts pixmap into temporary memory *)
  68.       )
  69.  
  70. You can read the rest in IM6. The GWorld routines really are easy to use.
  71. Compatible, too.
  72.  
  73. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  74. Computer Services Dept                     fax: +64-7-838-4066
  75. University of Waikato            electric mail: ldo@waikato.ac.nz
  76. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+12:00
  77.                        Signature tow-away zone. You have been wa
  78.