[futurebasic] Re: [FB] Gworld CLUT's (somewhat lengthy)

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : October 1999 : Group Archive : Group : All Groups

From: Russ Pagel <russp@...>
Date: Sat, 23 Oct 1999 15:33:57 -0500
> >Has anyone done anything with CLUT (Color Lookup Table) manipulation on
> >8 bit offscreen Gworlds?
> >
> >I'm working on an image editing project and I'd like to implement a
> >feature where the user can select a specific color (CLUT index) or
> >colors and mask out all other colors before doing my copy-bits to the screen.

 
> The way I do that may not be optimal, but it works.
> 
> I cannot build a CLUT from scratch. I only know how to build a palette and
> then to derive a CLUT from a palette.
> 
> get the present palette so that you can restore it at the end:
> colorWndPtr& = WINDOW(_wndPointer)
> gPalette& = FN GETPALETTE(colorWndPtr&)
> build a new palette. Set parameters : entries%,
> srcColor&,srcUsage%,srcTolerance%.
> 
> customPalette& = FN NEWPALETTE()
> FOR I = 0 TO (number of colors)
> set the RGB record from an array with red,green,blue values
> dstEntry% = 1
> CALL SETENTRYCOLOR()
> NEXT
> 
> CALL SETPALETTE()
> CTH& = FN NEWHANDLE(CTabsize&)
> CALL PALETTE2CTAB(customPalette&,CTH&)
> CALL DISPOSEPALETTE(customPalette&)
> 
> store the CLUT in a resource :
> 
> FN pGreplaceRes(CTH&,_"CLUT",ID%,"")
> CTH& = FN GETCTABLE(ID%)
> 
> use the CLUT in your GWorld :
> 
> QDErr% = FN NEWGWORLD(offPort&,8,rect,CTH&,0,0)
> 
> or in an update :
> 
> QDErr% = FN UPDATEGWORLD()
> 
> At the end you will have to restore the system CLUT/Palette (there was a
> post about this some time ago).
> 
> You will find what should be in parenthesis by looking in the Help files
> (toolbox).
> 
> Cheers.
> 
> Patrick
> 


Thanks Patrick,  I think you're right.

As an update:  I fiddled with this some more and found that I can POKE
into the Gworld CLUT to remove unwanted colors (actually re-write them
to white) and it does work.  Inside Macintosh seems to indicate that
this is legal or at least doesn't say its not as it does with other
parts of the window record.

Since I already have my starting CLUT resource I can probably just
re-write it back to my Gworld with UPDATEGWORLD when I'm done to restore
the original colors.  I won't have to worry about the system CLUT since
I'm not affecting the screen, only my offscreen Gworld.

I've tried using UPDATEGWORLD a few times and run into a problem though.
 Inside Macintosh says that its looking for a Bounding Rect as the third
argument but FBII seems to want me to use a Long here.  I don't know if
the problem is a typo in IM or a problem in FB.  My next step is to try
using a Long pointer to my Rect and see if that will go through.

I appreciate the response a lot.

rp