Path: utzoo!utgpu!water!watmath!clyde!bellcore!decvax!decwrl!labrea!agate!violet.berkeley.edu!edmoy
From: edmoy@violet.berkeley.edu
Newsgroups: comp.sys.mac.programmer
Subject: Re: How do you use the Palette Manager?
Message-ID: <9899@agate.BERKELEY.EDU>
Date: 12 May 88 18:26:18 GMT
References: <793@trwcsed.trwrb.UUCP>
Sender: usenet@agate.BERKELEY.EDU
Reply-To: edmoy@violet.berkeley.edu.UUCP ()
Distribution: na
Organization: University of California, Berkeley
Lines: 41

In article <793@trwcsed.trwrb.UUCP> arenberg@trwcsed.UUCP (Jeff Arenberg) writes:
>
>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 :
> . . .
>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 been trying to get the Palette manager to work myself.  The problem
seem to be that CopyBits() does not cause the window's palatte to change,
at least not entirely.

In my test program, I try to draw the color spectrum (from violet to red)
using the Color manager and it works fine.  Converting to the Palette
manager, I usually get random patterns of black and white stripes.  If
I make the CLUT of the pixmap point to the device's CLUT, I get the
spectrum with several black stripes running through it at various places.

I finally used FillRect to draw all the colors to the window, then do the
CopyBits().  It looked like the FillRect() caused the palette to change
correctly.  I got a clean spectrum.

The problem that remains is that apparently, even if the pixmap and palette
use the same colors, CopyBits() does an inverse mapping and then a forward
mapping.  Probably due to the limitations in the standard inverse mapping
algorithm, truncation occurs and I don't get all the colors I should.  This
occurs because in a spectrum, each color is close to its two neighboring
colors, and so it selects the wrong one too often.  For more random colors,
you may not notice this problem.

Edward Moy
Workstation Software Support Group
University of California
Berkeley, CA  94720

edmoy@violet.Berkeley.EDU
ucbvax!violet!edmoy