Logo Search packages:      
Sourcecode: race version File versions

void CAImageManipulation::hsvToRgb ( int  h,
int  s,
int  v,
int *  r,
int *  g,
int *  b 
) [static]

Converts an HSV color to a RGB color.

Definition at line 337 of file caimagemanipulation.cpp.

Referenced by changeHSV().

{
  *r=*g=*b = v;

  if( s == 0 || h == -1 ) {
    ;
  }
  else {
    if( (unsigned int)h >= 360 ) {
      h %= 360;
    }
    int f = h%60;
    h /= 60;
    int p = (2*v*(255-s)+255)/510;
    int q, t;
    if( h&1 ) {
      q = (unsigned int)(2*v*(15300-s*f)+15300)/30600;
      switch( h ) {
        case 1: *r=(int)q; *g=(int)v, *b=(int)p; break;
        case 3: *r=(int)p; *g=(int)q, *b=(int)v; break;
        case 5: *r=(int)v; *g=(int)p, *b=(int)q; break;
      }
    }
    else {
      t = (unsigned int)(2*v*(15300-(s*(60-f)))+15300)/30600;
      switch( h ) {
        case 0: *r=(int)v; *g=(int)t, *b=(int)p; break;
        case 2: *r=(int)p; *g=(int)v, *b=(int)t; break;
        case 4: *r=(int)t; *g=(int)p, *b=(int)v; break;
      }
    }
  }
}


Generated by  Doxygen 1.6.0   Back to index