## about the FractionColor class document.SUBSCRIPTION_OPTIONS = { "thing": "thread", "subscribed": false, "url": "subscribe", "icon": { "css": "fa fa-envelope-o" } };

xuguilin
2005-01-22
2013-04-17
• xuguilin - 2005-01-22

in the implement of the FractionalColor class,the FractionalColor was transformed to Color by the following methord.
EGL_IntFromFixed((0x1FF * EGL_CLAMP(r, 0, EGL_ONE)) >> 1),
but the transform from color to FractionalColor just as the following statement
r = color.R() << 8;
In this way when input 0xFF ,then transform to FractionalColor ,and then transform back,the result will be 0xFE
I think the transform from color to FractionalColor should be like the next expression:
r =  (color.R() << 8) + 0x80;

• Hans-Martin Will - 2005-01-22

I have:

FractionalColor(const Color & color) {
r = (color.R() << 8 | color.R()) + (color.R() >> 7);
g = (color.G() << 8 | color.G()) + (color.G() >> 7);
b = (color.B() << 8 | color.B()) + (color.B() >> 7);
a = (color.A() << 8 | color.A()) + (color.A() >> 7);
}

and

inline operator Color() const {
return Color(
EGL_IntFromFixed((0x1FF * EGL_CLAMP(r, 0, EGL_ONE)) >> 1),
EGL_IntFromFixed((0x1FF * EGL_CLAMP(g, 0, EGL_ONE)) >> 1),
EGL_IntFromFixed((0x1FF * EGL_CLAMP(b, 0, EGL_ONE)) >> 1),
EGL_IntFromFixed((0x1FF * EGL_CLAMP(a, 0, EGL_ONE)) >> 1));
}

What code are you referring to, and where is it used?

- HM