Mail Archives: djgpp/1997/01/07/20:56:50
Matt J Reiferson writes:
>still not final, so I set out to write a function that would take the current
>main pallete and "remap" it to all the tiles. This way I would not
>have to keep each individual picture updated (the program would do it for
>me). The problem is it doesn't work right, the tiles still don't display
>correctly, could anyone tell me what's wrong with the following function:
>
> cerror += abs(desired[cur_data].r-actual[index].r);
I suspect this line is the problem. The color fields in a pallete are
unsigned chars. Subtract one from another, and if the actual value is
greater than the desired one (ie. approx 50% of the time), it will wrap
around and give the wrong result. Try casting the values first, eg:
cerror += abs((int)desired[cur_data].r-(int)actual[index].r);
/*
* Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
* Ghoti: 'gh' as in 'enough', 'o' as in 'women', and 'ti' as in 'nation'.
*/
- Raw text -