Thema: Delphi WebSafe Farben

Einzelnen Beitrag anzeigen

blackdrake

Registriert seit: 22. Aug 2003
Ort: Bammental
618 Beiträge
 
Delphi 10.3 Rio
 
#1

WebSafe Farben

  Alt 9. Aug 2006, 00:00
Diese Funktion sucht die näheste Websafe-Farbe:

Delphi-Quellcode:
function WebSafeColor(inp: TColor): TColor;

        function WebSafeVal(int: integer): integer;
        begin
          result := 0;
          case int of
            0, 51, 102, 153, 204, 255: result := int;
          else
            begin
              if (int <= 26) then
                result := 0
              else
                if (int > 26) and (int <= 76) then
                  result := 51
                else
                  if (int > 76) and (int <= 127) then
                    result := 102
                  else
                    if (int > 127) and (int <= 178) then
                      result := 153
                    else
                      if (int > 178) and (int <= 229) then
                        result := 204
                      else if (int > 229) then
                        result := 255;
            end;
          end;
        end;

begin
  result := rgb(WebSafeVal(GetRValue(inp)), WebSafeVal(GetGValue(inp)), WebSafeVal(GetBValue(inp)));
end;
Weitere Informationen: http://de.wikipedia.org/wiki/Farbtabellen_im_Internet
Daniel Marschall
  Mit Zitat antworten Zitat