Einzelnen Beitrag anzeigen

neumimnemecky

Registriert seit: 21. Dez 2018
45 Beiträge
 
#1

Problem mit verschiedenen Typen im RGB-to-HSL-Range Procedur

  Alt 4. Jul 2022, 16:25
Guten tag,
can you help with this procedure derived from Color Lib v2.0.2? In original code in module RGBHSLUtils, there is similar procedure RGBtoHSLRange(RGB: TColor; var H1, S1, L1 : integer); using TColor as input parameter. Hence I wanted to create modified function in RGBHSVUtils for convertion to HSV. The HSV original procedure is RGB2HSV(R, G, B: integer; var H: Word; var S, V: byte); // passing Integer inputs(!). So I decided to pass TColor, but here is the problem. How to make it working now? There is the error : RGBHSVUtils.pas(232*): Incompatible types: 'Byte' and 'Extended'; *note: modified version is on my PC.

Verfahren abgeleitet von Color Lib v2.0.2.

Code:
procedure RGB2HSVRange(RGB: TColor; var H: Word;var S,V: byte);
var
 Delta, Min, H1, S1: real;
 R, G, B: byte;
begin
 R := GetRValue (RGB) / 255;
 G := GetGValue (RGB) / 255;
 B := GetBValue (RGB) / 255;
 h1 := h;
 s1 := s;
 // Min := MinIntValue([R, G, B]);
 Min := R;
 if Min > G then
   Min := G;
 if Min > B then
   Min := B;
 // V := MaxIntValue([R, G, B]);
 V := R;
 if V < G then
   V := G;
 if V < B then
   V := B;
 Delta := V - Min;
 if V = 0.0 then S1 := 0 else S1 := Delta / V;
 if S1  = 0.0 then
  H1 := 0
 else
  begin
   if R = V then
    H1 := 60.0 * (G - B) / Delta
   else
    if G = V then
     H1 := 120.0 + 60.0 * (B - R) / Delta
    else
     if B = V then
      H1 := 240.0 + 60.0 * (R - G) / Delta;
   if H1 < 0.0 then H1 := H1 + 360.0;
  end;
 h := round(h1);
 s := round(s1*255);
end;

Geändert von neumimnemecky ( 4. Jul 2022 um 17:13 Uhr)
  Mit Zitat antworten Zitat