[comp.sys.mac.programmer] displaying colored picts with correct colors?

neves@cubbie.ils.nwu.edu (David Neves) (09/26/90)

When I display a PICT resource using draw-picture the colors don't
seem to be quite right.  I know that the picture was created with its
own colors (own color palette?).  Does this has something to do with
it?  If so, how can I get the picture displayed correctly?
Do I have to change the window's CLUT?  How do I get this information
from the PICT?

-Thanks for any help, David
--
The Institute for The Learning Sciences
1890 Maple St., Evanston, Il.  60201
neves@ils.nwu.edu (312) 491-7178

cory@howtek.UUCP (Cory Kempf) (10/03/90)

In article <1918@anaxagoras.ils.nwu.edu> neves@ils.nwu.edu (David Neves) writes:
>When I display a PICT resource using draw-picture the colors don't
>seem to be quite right.  I know that the picture was created with its
>own colors (own color palette?).  Does this has something to do with
>it?	

Sounds like a palette problem.  You need to set the colours that
you will be using.  With many pictures (especially bitmap PICTS),
it is easier to set up the whole palette at once.  Often the palette
is saved as a resource along with the PICT.  If not, game over.
(unless you are using a 32 bit pict, then you can regen. the CLUT
from the pict)

+C

acc@psuecl.bitnet (10/05/90)

In article <1533@howtek.UUCP>, cory@howtek.UUCP (Cory Kempf) writes:
> In article <1918@anaxagoras.ils.nwu.edu> neves@ils.nwu.edu (David Neves) writes:
>>When I display a PICT resource using draw-picture the colors don't
>>seem to be quite right.  I know that the picture was created with its
>>own colors (own color palette?).  Does this has something to do with
>>it?
>
> Sounds like a palette problem.  You need to set the colours that
> you will be using.  With many pictures (especially bitmap PICTS),
> it is easier to set up the whole palette at once.  Often the palette
> is saved as a resource along with the PICT.  If not, game over.
> (unless you are using a 32 bit pict, then you can regen. the CLUT
> from the pict)
>
> +C


I missed the original post, but I ran into a similar problem myself and
was able to solve it, with the help of MacDTS.

When you playback a PICT handle with DrawPicture, you will not automatically
have the image displayed in the original color palette.  What you need to do is
to determine the palette first, set the palette of the device (SetPalette with
a very low or zero tolerance perhaps) and then call DrawPicture.

The trick is to determine the color table.  You can do this (thanks MacDTS) by
replacing the QuickDraw bottleneck (thePort^.grafProcs) procedures with a set
of routines that do no actual drawing, but simply keep track of all of the
colors used in the PICT file.  Call DrawPictures to draw with your color
collecting bottlenecks, then replace the bottleneck procedures with the
standard set.

Now you know the colors used in the PICT file.  If you are lucky, your device
can display enough colors to accomodate the number of used colors.  Build a
palette with these colors, and call SetPalette (for a window... or be real cool
and call UpdateGWorld on your offscreen GWorld.)

Now you are ready to call (yes again) DrawPicture to actually draw the PICT
file.

Apple is kind enough to provide sample code to this effect on the Developer CD
Series.  I (a year after I needed it, but hey, you need it now) found sample
code on Volume IV, in
        Programming and Utilities
         MOOF
          KnowsPICT
           KnowsPICT Source
             CLUTBuilder.c

Good Luck!

Tony Canike.