ColourTrans Conversions
Steve Fryatt (216) 2105 posts |
Can anyone shed any light on how ColourTrans_ConvertCIEToRGB is supposed to work? Reading the module’s source, it appears to be doing a simple matrix transformation; what isn’t clear to me is what it expects the input and output numbers to look like. The documentation states that the parameters are passed as fixed point numbers with 16 bits above and below the point, and then suggests that values are within the range 0 to 1 “for compatibility with other conversion SWIs”. The input values are X, Y and Z, which are described as “CIE tristimulus values” — however, while small, there seems to be no guarantee that in the real world they will always be in the range 0 to 1 that the PRM suggests. It’s also not clear what range the RGB output values are in: assuming the same 16/16 bit fixed point arrangement as the input, they seem to be in the range of 0 to 10 or so. My first attempt to convert CIE values into RGB suitable for use with GCOL or the like was this:
However, while it does sort-of work, scale% needs to be reduced well below 255 (to 60 or so) in order to give RGB values in the range 0 to 255. There’s clearly something blindingly obvious that I’m missing; can anyone point out my mistake(s)? ETA: Bounds checking on SWI output values, which I’d originally omitted from the example for clarity. |