Article View: comp.sys.mac
Article #23327Mac II clut question
From: Eric K. Olson
Date: Wed, 06 Jan 1988 00:04
Date: Wed, 06 Jan 1988 00:04
83 lines
3274 bytes
3274 bytes
I need a way to set the GDevice color lookup table (clut) with a specific
clut. I would like a friendly way. Here's what I do now:
setclut(object)
objectptr object;
{
GDHandle gdev;
if (object->window==FrontWindow()) {
gdev=GetGDevice();
HLock(object->clut);
SetEntries(0,(*(object->clut))->ctSize,&((*(object->clut))->ctTable));
(*(*(*gdev)->gdPMap)->pmTable)->ctSeed=(*(object->clut))->ctSeed;
HUnlock(object->clut);
}
}
object is just a data structure containing, among other things, a WindowPtr
(object->window) and a Detached clut resource (object->clut). Note that,
in the above, I also set the Gdevice's ctSeed to match the clut, so that
it won't try to remap all the pixels.
Note also that I am working with Color PixMaps: RGBForeColor and RGBBackColor
have no meaning here, and I must have the GDevice clut match the PixMap
clut exactly, in order.
The problem with this technique is that it:
1. Isn't very friendly (according to IM-V)
2. Doesn't set any GDevice clut beyond this MainDevice's.
I can traverse the GDevice list myself, and check for intersections of
GDRects with the content region of the window:
setclut(object)
objectptr object;
{
GDHandle gdev;
GDHandle save;
if (object->window==FrontWindow()) {
save=GetGDevice();
gdev=GetMainDevice();
while (gdev) {
HLock(gdev);
if (RectInRgn(&((*gdev)->gdRect),
((WindowPeek) object->window)->contRgn)) {
HUnlock(gdev);
SetGDevice(gdev);
HLock(object->clut);
SetEntries(0,(*(object->clut))->ctSize,
&((*(object->clut))->ctTable));
(*(*(*gdev)->gdPMap)->pmTable)->ctSeed=
(*(object->clut))->ctSeed;
HUnlock(object->clut);
}
HUnlock(gdev);
gdev=GetNextDevice(gdev);
}
SetGDevice(save);
}
}
For some reason this only finds one GDevice (the main one). A SysBeep
placed after the while rings once. Can anyone give me a hint as to why?
I thought the Palette Manager pmExplicit mode would do what I want (and it
would do this traversal for me): it did not. It didn't seem to do anything.
What is pmExplicit for?
Setting an exact color map is a common need: ImageStudio and PixelPaint
both have to do this, and both only work on the MainDevice. I would like
to work on all attached screens, setting cluts as needed by window positions.
It's not uncommon for me to need to have an 8-bit all grey clut on one
screen and a 4-bit all grey clut on another, and I'd like them all to update
the GDevice cluts so I get perfect colors (grays). The code above would
do that if it worked (I suppose one could say that about any code...)
Thanks in Advance.
-Eric
(defun maybe (x) (maybe (not x)))
Eric K. Olson olson@endor.harvard.edu harvard!endor!olson D0760
(Name) (ArpaNet) (UseNet) (AppleLink)
Technical Details
Message-ID:
<3715@husc6.harvard.edu>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!endor!olsonShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!endor!olson From: olson@endor.harvard.edu (Eric K. Olson) Newsgroups: comp.sys.mac Subject: Mac II clut question Message-ID: <3715@husc6.harvard.edu> Date: 6 Jan 88 00:04:23 GMT Sender: news@husc6.harvard.edu Reply-To: olson@endor.UUCP (Eric K. Olson) Distribution: na Organization: Lexington Software Design Lines: 83