Path: utzoo!attcan!uunet!mailrus!ncar!asuvax!noao!arizona!gerhard From: gerhard@cs.arizona.edu (Gerhard Mehldau) Newsgroups: comp.sys.mac.programmer Subject: Re: Query: question about color on the mac... Summary: try this... Message-ID: <23410@megaron.cs.arizona.edu> Date: 23 Jul 90 20:24:51 GMT References: <10754@odin.corp.sgi.com> Organization: U of Arizona CS Dept, Tucson Lines: 50 In article <10754@odin.corp.sgi.com>, myoung@joker.sgi.com (Mark Young) writes: > > I'm working on a class project that does simple color halftoning, and I > want to be able to set up the color table and then write color index values > to the pixels on the screen. > > I looked over the color stuff in volume five and it wasn't obvious how > you would go about doing this...everything seemed to want RGB colors which > would then get mapped for you. > > is this easier than it looks? can someone give me an RTFM reference to > volume V that explains this... > > thanks. > > ...myoung I have struggled through this, too - IM V and the 32-Bit QuickDraw documentation really isn't very clear on this topic (Apple, are you listening?). First, you need to create a color table - either within your program, or as a resource which you can read in from your resource file. You then convert the color table to a palette (with all entries allocated as pmTolerant+pmExplicit), and associate the palette with the window(s) in question. You can then create an offscreen pixmap, set the individual pixels to whatever index you want, and do a CopyBits() to put them on-screen. 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 */ Good luck! - 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