delphi RGB 转 HSV

2021-04-26 12:26

阅读:353

标签:var   begin   single   roc   byte   ohs   procedure   phi   pre   

 1 procedure RgbToHsv(R, G, B: Byte; var H, S, V: Single);
 2 var
 3   mx, mn: Byte;
 4   tmp: Single;
 5 begin
 6   mx := R;
 7   mn := R;
 8   if mx then mx := G;
 9   if mx then mx := B;
10   if mn > G then mn := G;
11   if mn > B then mn := B;
12   if mx = 0 then
13   begin
14     H := -1;  S := 0;  V := 0;
15     Exit;
16   end;
17 
18   V := mx / 255;
19   S := (mx - mn) / mx ;
20   tmp := 60.0 / (mx - mn);
21   if mx = R then H := (G - B) * tmp
22   else if mx = G then H := 120 + (B - R) * tmp
23   else if mx = B then H := 240 + (R - G) * tmp;
24   if H 0 then H := H + 360;
25 end;

 

delphi RGB 转 HSV

标签:var   begin   single   roc   byte   ohs   procedure   phi   pre   

原文地址:http://www.cnblogs.com/btxz/p/7895419.html


评论


亲,登录后才可以留言!