Einzelnen Beitrag anzeigen

Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.184 Beiträge
 
Delphi 12 Athens
 
#2

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

  Alt 4. Jul 2022, 23:29
Code:
 R := GetRValue (RGB) / 255;
 G := GetGValue (RGB) / 255;
 B := GetBValue (RGB) / 255;

^^^ Byte  :=         ^^^ Float
Doesn't the compiler tell you exactly what's wrong?

On the right you have a float (Extended) and you want to assign that to an integer (byte) on the left, which of course cannot work.
Why are you dividing there at all?



Also, the compiler should tell you that these lines are wrong (useless).
Delphi-Quellcode:
 h1 := h;
 s1 := s;
If you change a little thing, you will quickly realize that the value is only output, but not input (InOut).
Delphi-Quellcode:
//procedure RGB2HSVRange(RGB: TColor; var H: Word; var S, V: Byte);
  procedure RGB2HSVRange(RGB: TColor; out H: Word; out S, V: Byte);
$2B or not $2B

Geändert von himitsu ( 5. Jul 2022 um 00:21 Uhr)
  Mit Zitat antworten Zitat