Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!ncar!noao!arizona!gerhard From: gerhard@cs.arizona.edu (Gerhard Mehldau) Newsgroups: comp.sys.mac.programmer Subject: Re: Query: question about color on the mac... Message-ID: <23451@megaron.cs.arizona.edu> Date: 24 Jul 90 17:23:32 GMT References: <10754@odin.corp.sgi.com> <23410@megaron.cs.arizona.edu> <139442@sun.Eng.Sun.COM> Organization: U of Arizona CS Dept, Tucson Lines: 47 In article <139442@sun.Eng.Sun.COM>, johnston@adhawk.Eng.Sun.COM (Scott Johnston) writes: > >The code for the color table/palette stuff should > >look like this (note that this code requires 32-Bit > >QuickDraw to be installed): > >CTabHandle gTable; > >PaletteHandle gPalette; > >gTable = GetCTable(kColorTable); /* read in from resource file */ > >gPalette = NewPalette((*gTable)->ctSize+1,gTable,pmTolerant+pmExplicit,0); > >SetPalette((WindowPtr)(-1),gPalette,TRUE); /* make default palette */ > I have been flailing miserably with this, too, so correct me if > I am wrong. Isn't the color table created with the above set of > commands still dependent upon the underlying device CLUT? And > this device CLUT has not changed? So, the way I understand it, > the Color Manager will attempt to find the closest RGB matches > between this newly created CLUT and the device CLUT. No, it doesn't. If you set the tolerance to 'pmTolerant+pmExplicit', the palette manager will do all the ugly work of modifying the CLUT for you - and, even better, will switch back to the old CLUT when your application quits. And you do get the exact colors you want in exactly the locations you requested them. > What if you wanted to do 256-tone Gray Scale? Wouldn't you need > to go in and modify the device's CLUT directly in order to get > this wide range of grays? Again, no. I've been using the above code to create a palette with a 128-level grayscale, and 128 colors (for an image processing application), and it works just fine... > Just worth mentioning: modifying the device CLUT gets ugly. It certainly does. I should know - this was also one of my earlier attempts at solving the problem (before 32-Bit QuickDraw was released). > sj - Gerhard -- -> Gerhard Mehldau Dept. of Computer Science internet: gerhard@cs.arizona.edu University of Arizona uucp: {cmcl2,noao,uunet}!arizona!gerhard Tucson, AZ 85721, U.S.A. at&t: +1 (602) 621-4632