>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. > >I already have a fairly quick routine that I use to collect a histogram >of the gworld and I guess I could modify it to set any unwanted color >indexes in the gworld to white but I was hoping for something faster. > >The palette manager ignores animated color entries in Gworlds so I've >been try to fool the Gworld CLUT by reseting the color entries after I >load the image but I'm not having any luck. > >Here's what I've done so far > >Get an 8 bit Gworld with a custom CLUT resource. > >Set the port to the Gworld > >DRAWPICTURE a PICT file into it > >Use CALL SETENTRIES to change the color data at each point in Gworld CLUT >Have also tried cheating by simply POKEing them in. > >Set the port to the window > >Copybits the image out to the screen. > >NO change in the image at all! > >I would think the logic of this would be as follows: Quickdraw should >have assigned which colors (CLUT indexes) it thought were appropriate >for each pixel when the image was loaded. When I change the CLUT entry >RGB values then the actual image colors (RGB values) should change when >I copy them out with Copybits. > >I'm assuming that the Gworld only has one CLUT to work with so where is >it getting the old RGB values to work with during Copybits? > >I'd really appreciate any advice. Thanks In Advance > >rp 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