[comp.sys.mac.programmer] Palette question

t-stephp@microsoft.UUCP (Stephen Poole) (01/31/89)

Hello, folks.  I've been playing around with LSC 3.01 (and enjoying it
greatly) and recently started messing with pixel patterns.  I haven't been
able to produce a pixel pattern that actually uses RGB colors.  What I've
done is createD a color window with NewCWindow, which works fine as far as
I can tell, and then attempt to fill a rect with my pixpat.  The pixpat
is created with MakeRGBPat; I've tried a variety of RGB colors as the
pattern specifier.  FillCRect, when given this pattern, fills my rect with
a pattern using only QuickDraw colors.  I've also tried using PmForeColor
with an index from 0 to 255 and painting an oval; this invariably gives
me black.

Soooo, do I somehow need to attach or specify a palette for use by my
CWindow?  Is there a good source for example Color QuickDraw code?  A 
fragment of my program:

    void doabout()
        {
        PixPatHandle  niftypattern;
        RGBColor      niftycolor;
        CWindowPtr    niftywindow;
        Rect          niftywinrect;

        /* set up rect "niftywinrect" here */
        /* build a sample RGB color in "niftycolor" here */
        
        niftypattern = NewPixPat();
        MakeRGBPat(niftypattern, &niftycolor);

        niftywindow = (CWindowPtr) NewCWindow(NULL, &niftywinrect, 
                      "\pNifty Window", TRUE, 4, (int *) -1, FALSE, 0);
        FillCRect(&niftywinrect, niftypattern);
        }

And another question... LSC didn't know about the CWindowPtr type, even
though I was including both Color.h and ColorToolbox.h.  I typedef'ed
CWindowPtr to be CGrafPtr.  Is this a problem?  Should I be including
something else (MacHeaders are enabled)?

Thanks for any help you can provide.
-- 
-- Stephen D. Poole -- t-stephp@microsoft.UUCP -- Mac II Fanatic --
--                                                               --
-- I'm just an Oregon Tech Software Engineering co-op at  Micro- --
-- soft.  Believe me, nobody here pays attention to my opinions! --

t-stephp@microsoft.UUCP (Stephen Poole) (05/06/89)

I have put together my first custom clut and am having a bit of trouble
getting my program to use it.  I'm reading a GIF file (got tired of Giffer
and Vision Lab crashing on me all the time) and have created a palette of
256 colors.  The pmInfo array of ColorInfo records does appear to contain 
the values I have stored in it.  I call SetPalette and assign the
palette to my window.  I then call ActivatePalette, thinking that this
will make calls to PmForeColor use this palette.  It doesn't seem to.
My colors appear to be coming from the system palette.  By calling 
GetPalette I can see that my window does have my palette associated with
it, so I'm a bit confused as to what more I need to do.  Any help or
sample code would be appreciated.
.
-- 
-- Stephen D. Poole -- t-stephp@microsoft.UUCP -- Mac II Fanatic --
--                                                               --
-- I'm just an Oregon Tech Software Engineering co-op at  Micro- --
-- soft.  Believe me, nobody here pays attention to my opinions! --