any_one
2010-12-11 21:50:13
If the r, g, or b value for a colour is below 11, if you convert to xyz and then back it is ignored - ie. becomes 0.
Gives:
Note that if you make either r, g, or b 11 or higher its value is preserved properly.
Edit: OK, the problem is not with [x]ToXYZ it is with XYZ back to x, I'm guessing some kind of rounding error?
program new;
var x,y,z : Extended;
r,g,b,i : Integer;
begin
for i := 1 to 11 do
begin
RGBToXYZ(i,i,i,x,y,z);
XYZToRGB(x,y,z,r,g,b);
Writeln('r: ' + ToStr(r) + ' g: ' + ToStr(g) + ' b: ' + ToStr(b) );
end;
end.Gives:
r: 0 g: 0 b: 0
r: 0 g: 0 b: 0
r: 0 g: 0 b: 0
r: 0 g: 0 b: 0
r: 0 g: 0 b: 0
r: 0 g: 0 b: 0
r: 0 g: 0 b: 0
r: 0 g: 0 b: 0
r: 0 g: 0 b: 0
r: 0 g: 0 b: 0
r: 11 g: 11 b: 11Note that if you make either r, g, or b 11 or higher its value is preserved properly.
Edit: OK, the problem is not with [x]ToXYZ it is with XYZ back to x, I'm guessing some kind of rounding error?