Results 1 to 3 of 3

Thread: Probleem met verschillende typen in RGB2HSVRange procedure

  1. #1

    Probleem met verschillende typen in RGB2HSVRange procedure

    Ik probeer een procedure te maken voor de RGBHSVUtils-bibliotheek, volgens RGBHSLUtils, om een ​​TColor type als invoerparameter te nemen. Ik liep echter tegen een probleem aan

    Procedure afgeleid van 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;
    fout:
    [Error] RGBHSVUtils.pas(232): Incompatible types: 'Byte' and 'Extended'

    Hoe kan ik die formule correct uitvoeren of moet ik deze veranderen in real type? Maar daar is het vergelijkbaar.
    Last edited by chlopik; 04-Jul-22 at 17:37.

  2. #2
    Je doet nu

    Delphi Code:
    1. R := GetRValue (RGB) / 255;
    2. G := GetGValue (RGB) / 255;
    3. B := GetBValue (RGB) / 255;

    Als je die als byte wilt kan je dit doen:
    Delphi Code:
    1. R := GetRValue (RGB) div 255;
    2. G := GetGValue (RGB) div 255;
    3. B := GetBValue (RGB) div 255;

    of je doet

    Delphi Code:
    1. R := Round(GetRValue (RGB) / 255);
    2. G := Round(GetGValue (RGB) / 255);
    3. B := Round(GetBValue (RGB) / 255);

  3. #3
    Heel erg bedankt.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •