I had written a bit ago about bleeding the colors from an image, leaving
it greyscape (got no response… taking that as meaning no one on this
list has really tried ;). I think I’ve figured out a way to do it using
a variation to the palette fade to black example in the docs.
Essentially, we have two SDL_Color arrays, say color[] which
has the color palette from the image, and new_color[]. Then, we run
through it, checking each r,g,b value, and setting the lower two to the
higher one (i.e., if r is 200, g is 50 and b is 30, then setting g=200 and
b=200). Small portion of the routine would be:
for(i=0; i<ncolors; i++){
if(color[i].r > color[i].g && color[i].r > color[i].b) {
new_color[i].g = color[i].r;
new_color[i].b = color[i].r;
} else
…etc., checking for each color as above…
}
in theory, this ought to work (correct me if I’m wrong).
However, the problems I’m having now is that my surfaces aren’t
palettized! I’m using GIFs (which I thought were automatically palettized,
but I guess not). I’m also using the SDL_HWPALETTE flag (which I guess I
don’t understand as well as I thought I did).
How do I force a palette on a surface? (I’ve thought SDL_ConverSurface or
some such thing ought to do it… but couldn’t get it to work). Is
this even possible? Is there a better image format I should use?
Ultimately, I’m moving on in my project… but would like to impliment
this in the future.–
Sam Hart http://www.physics.arizona.edu/~hart/
Web Page Highlights: Video Game History, Black Hole Simulation, & more.
OTHER WEB SITES MAINTAINED BY SAM HART
http://www.geekcomix.com/ - Geekcomix, the Daily Geek Comic Strip Site
http://www.physics.arizona.edu/~hart/gw/ - Ghostworks (Alt./Linux Computing)