Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

void RGBtoHLS ( const COLORREF  rgb,
double *  H,
double *  L,
double *  S 
)

Definition at line 28 of file cardcolor.cpp.

Referenced by ColorScaleHSL().

00029 {
00030     double delta;
00031     double r = (double)((rgb    )&0xFF)/255;
00032     double g = (double)((rgb>> 8)&0xFF)/255;
00033     double b = (double)((rgb>>16)&0xFF)/255;
00034     double cmax = MAX3(r,g,b);
00035     double cmin = MIN3(r,g,b);
00036     *L=(cmax+cmin)/2.0;
00037 
00038     if(cmax == cmin)
00039     {
00040         *S = *H = 0; // it's really undefined
00041     }
00042     else
00043     {
00044         if(*L < 0.5)    *S = (cmax-cmin)/(cmax+cmin);
00045         else            *S = (cmax-cmin)/(2.0-cmax-cmin);
00046 
00047         delta = cmax - cmin;
00048 
00049         if(r == cmax)
00050         {
00051             *H = (g - b) / delta;
00052         }
00053         else
00054         {
00055             if(g == cmax) *H = 2.0 + (b-r) / delta;
00056               else          *H = 4.0 + (r-g) / delta;
00057         }
00058           *H /= 6.0;
00059           if (*H < 0.0) *H += 1;
00060     }
00061 }


Generated on Thu Feb 9 06:09:19 2012 for ReactOS by doxygen 1.6.3

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.