TatukGIS

过程名称  ColorToHSL

所在单元  GisDefs 

过程原型  

          procedure ColorToHSL(const _color: TColor; var _h: Real; var _s: Real; var _l: Real);         

过程说明 

   根据TColor 转换至 HSL颜色.   

         HSL即色相饱和度亮度英语Hue, Saturation, Lightness),又称HLS          

举例说明    


 1 var
 2   h, s, l: Real;
 3   c: TColor;
 4 begin
 5   c := RGBToColor(127,255,127);
 6   ColorToHSL(c, h, s, l);
 7   ShowMessage(Format('H = %f , S = %f , L = %f', [h*360, s, l]));
 8   c := HSLToColor(h, s, l);
 9   ShowMessage(IntToStr(c));
10   if c = RGBToColor(127,255,127) then ShowMessage('OK');
11 end;

 

RGBHSLHSV结果
(1, 0, 0) (0°, 1, 0.5) (0°, 1, 1)  
(0.5, 1, 0.5) (120°, 1, 0.75) (120°, 0.5, 1)  
(0, 0, 0.5) (240°, 1, 0.25) (240°, 1, 0.5)  

 
原文地址:https://www.cnblogs.com/chinacodegear/p/3624409.html