![]() |
Ähnliche Farben
Hi,
sorry für den Threadnamen, mir ist leider kein besserer eingefallen. Ich habe einen bestimmten Farbwert und möchte auch ähnliche Farbwerte bei einer Bedingung zulassen. Wie kann cih dies Bewerkstelligen ohne jede Farbe von Hand einzufügen ? :( Danke schonmal im Vorraus!! |
Re: Ähnliche Farben
Ich habe mal schnell eine Funktion geschrieben:
Delphi-Quellcode:
const
CF_RED = 1; CF_GREEN = 2; CF_BLUE = 4; CF_ALL = 8; type TColorBytes = record r, g, b, a: Byte; end; function IsColorSimilar(Color1, Color2: TColor; ColorFlags: DWORD; MaxDifference: Byte): BOOL; var ColorBytes1, ColorBytes2: TColorBytes; begin Result := FALSE; ColorBytes1 := TColorBytes(Color1); ColorBytes2 := TColorBytes(Color2); if (ColorFlags and CF_ALL) <> 0 then ColorFlags := CF_RED or CF_GREEN or CF_BLUE; if (ColorFlags and CF_RED) <> 0 then if abs(ColorBytes1.r - ColorBytes2.r) > MaxDifference then Exit; if (ColorFlags and CF_GREEN) <> 0 then if abs(ColorBytes1.g - ColorBytes2.g) > MaxDifference then Exit; if (ColorFlags and CF_BLUE) <> 0 then if abs(ColorBytes1.b - ColorBytes2.b) > MaxDifference then Exit; Result := TRUE; end; |
Re: Ähnliche Farben
danke!!!!
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:03 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz