Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!nrl-cmf!ames!pasteur!ucbvax!hplabs!sdcrdcf!trwrb!arenberg
From: arenberg@trwrb.UUCP (Jeff Arenberg)
Newsgroups: comp.sys.mac.programmer
Subject: How do you use the Palette Manager?
Message-ID: <793@trwcsed.trwrb.UUCP>
Date: 9 May 88 22:08:42 GMT
Reply-To: arenberg@trwcsed.UUCP (Jeff Arenberg)
Distribution: na
Organization: TRW EDS, Redondo Beach, CA
Lines: 34


I am getting extremely frustrated trying to figure out how the properly
use the Palette Manager.  I have an image that I want to display with
specific colors.  Here is the approach I've been trying :

1.  Init my own cGrafPort and allocate a color table for 256 entries.
2.  Set the first entry to white, the second to black, and the remaining
    to the colors I want.
3.  Read my temp file which has 12 bits of RGB data per pixel and set the
    pixels in my cGrafPort using SetCPixel.
4.  Open a cWindow.  Create a PaletteHandle for 256 colors.
5.  Copy my color table to the palette using CTab2Palette and attach the
    palette to the window.
6.  Use CopyBits to copy from the cGrafPort to the cWindow the first time
    and to update the window.

When I do this, the colors come out all wrong.  It looks like index values
in the window are pointing to the wrong values in the screen color table.
I've looked at the screen CLUT using the Klutz DA and most of the correct
colors seem to be present.  

I don't understand why this approach fails.  Does anyone have any working
code that uses the Palette Manager and offscreen pixmaps?  I know Giffer
1.0 handles palettes correctly, so it's not a hardware problem.

I've running on a Mac II, 5 Meg, System 4.2, Finder 6.0, code is written
in LSC.  Any help is really appreciated.

Jeff Arenberg
------------------------------------------------------------
UUCP : ( ucbvax, ihnp4, uscvax ) !trwrb!trwcsed!arenberg
ARPA : jarenberg@ecla.usc.edu
GEnie: shifty
------------------------------------------------------------