Mail Archives: djgpp/1998/04/02/09:16:41
Ishpeck wrote:
>
> Oh, alright... I give up... I'll do it
> the sensible way! SHEESH!
>
> :)
You cut too deep insinuating advocating sensibility.
The following code is guaranteed NOT to work- I
didn't have the allegro reference in front of me
when I wrote it, and I didn't even try to compile it.
But if I were trying to accomplish this conversion
its where I'd start.
Charles Terry
Char colortable[255]
pallete_convert(pal screenpal,pal flickpal)
{
RGB* SC[255];
RGB* PC[255];
int place,place2;
int bestvalue=0xffff;
setpallete(flickpal);
for (place=0;place<=255;place ++)getcolor(place,&PC[place]);
setpallete(screenpal);
for (place=0;place<=255;place ++)getcolor(place,&SC[place]);
// you probably would have to tweek the color value test below
for(place=0;place<=255;place++){
for(place2=0;place2<=255;place2++){
if( abs(SC.R-PC.R)+abs(SC.G-PC.G)+abs(SC.B-PC.B)<
bestvalue){
bestvalue=place2;
if (0==bestvalue)break;
}}
colortable[place]=bestvalue;
bestvalue=0xffff;
}
}
color_flick(char* bmp,int size)
{
for(int place=0;place<size;place++)
{
bmp[place]=colortable[bmp[place]];
}}
>
- Raw text -