26 #ifndef __SYNFIG_COLOR_CAIROCOLOR_H
27 #define __SYNFIG_COLOR_CAIROCOLOR_H
33 class CairoColorAccumulator;
61 static const unsigned char ceil=255;
62 static const unsigned char floor=0;
74 else return (
unsigned char)(x);
79 else return (
unsigned char)(x);
81 inline unsigned char clamp(
int x)
85 else return (
unsigned char)(x);
87 inline unsigned char clamp(
float x)
89 return clamp((
int) (x));
125 const float temp(1.0
f/rhs);
187 }
else return alpha();
193 CairoColor(
const unsigned char u): pixel((u<<24)|(u<<16)|(u<<8)|(u)) { }
195 CairoColor(
const unsigned char R,
const unsigned char G,
const unsigned char B,
const unsigned char A=
ceil):
196 pixel((A<<24)|(R<<16)|(G<<8)|(B)) { }
214 unsigned char get_a()
const {
return pixel>>24; }
215 unsigned char get_r()
const {
return pixel>>16; }
216 unsigned char get_g()
const {
return pixel>>8; }
217 unsigned char get_b()
const {
return pixel; }
268 return sqrt(u*u+v*v);
272 set_yuv(
const float &y,
const float &u,
const float &v)
276 c.
set_g(y*DecodeYUV[1][0]+u*DecodeYUV[1][1]+v*DecodeYUV[1][2]);
277 c.
set_b(y*DecodeYUV[2][0]+u*DecodeYUV[2][1]+v*DecodeYUV[2][2]);
293 const float s(sqrt(u*u+v*v));
303 static CairoColor YUV(
const float& y,
const float& u,
const float& v,
const unsigned char a=
ceil)
304 {
return CairoColor().set_yuv(y,u,v).set_a(a); }
312 const float s(
get_s());
314 u(s*(
float)Angle::sin(theta).
get()),
315 v(s*(
float)Angle::cos(theta).
get());
323 const float a(Angle::sin(theta).
get()), b(Angle::cos(theta).
get());
325 return set_uv(b*u-a*v,a*u+b*v);
333 s*(
float)Angle::sin(theta).
get(),
334 s*(
float)Angle::cos(theta).
get()
339 {
return CairoColor().set_yuv(y,s,theta).set_a(a); }
380 #endif // __SYNFIG_COLOR_CAIROCOLOR_H