Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Color Table Question

0 views
Skip to first unread message

Steve

unread,
Dec 17, 1998, 3:00:00 AM12/17/98
to
I am trying to create a grayscale color table for a pixmap. I would
use the built in Mac grayscale table except I need to change a table
entry.
The following code snippet is what I have tried.

hGrayTable = (CTabHandle) NewHandle (sizeof (ColorTable) + (255 *
sizeof (ColorSpec)));
(**hGrayTable).ctSeed = GetCTSeed();
(**hGrayTable).ctFlags = 0x00;

(**hGrayTable).ctSize = 255;

for (x = 0; x < 256; x++)
{
(**hGrayTable).ctTable[x].value = x;
(**hGrayTable).ctTable[x].rgb.red = x * 256;
(**hGrayTable).ctTable[x].rgb.green = x * 256;
(**hGrayTable).ctTable[x].rgb.blue = x * 256;
} // end for

(**hGrayTable).ctTable[*pucGray].rgb.red = 0;
(**hGrayTable).ctTable[*pucGray].rgb.green = 0;
(**hGrayTable).ctTable[*pucGray].rgb.blue = 128 * 256;

This seems to work except that when I close my dialog box my system
locks up.
Can anyone see an error in my creation method? Thanks.

Steve

Replace "where-i-work" with s-vision to respond via e-mail.

Graham C

unread,
Dec 18, 1998, 3:00:00 AM12/18/98
to
Why not load the system greyscale table with GetCTable, then modify it? When
you load a table like this, you get a copy that is yours to do with as you
wish.

Also, you need to set the high bit of the flags field to let the value field
be ignored (index is value) and a colour component should be "smeared"
across 16 bits i.e. an 8-bit value 5F becomes 5F5F in an RGB record- i..e
(short) c << 16 | c, rather than c * 256.

If you are getting a crash, it is probably because you wrote beyond the end
of the handle and hit something in your heap.

GC.


Steve wrote in message <3679ABEB...@where-i-work.com>...

0 new messages