Autor Beitrag
maxk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: So 19.01.03 17:44 
Ich habe ein Problem beim "erhellen" einer Farbe, die mir als RGB-Wert vorliegt. Wie im Farbfenster von Windows möglich möchte ich diese Farbe heller machen. Wie kann ich das machen? Ich muss hier gestehen, dass ich in Farbenlehre immer geschlafen habe. :lol:

Aus FF0000 (Rot, Helligkeit 120) wird z.B. FF0A0A (Helligkeit 125) - aber wie?

maxk


PS: Ich poste hier, da Farbe mit Grafik zutun hat.

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: So 19.01.03 19:33 
uiii.
Also bei reinfarben weiß ich's. Wenn du zum Beispiel Blau hast. Für Blau (ebenso wie rot und grün) gibt es einen reinfarbwert: 0,0,255 (RGB). Dunkler wird's nun, wenn du die 255 kleiner machst. Heller wird's, wenn du die beiden 0en gleichmäßig (!) erhöhst. Wie das Verhältnis dabei sit, weiß ich leider auch nicht. Für seeehr grobe Helligkeitsveränderungen geht's aber so. Wie es bei Mischwerten (Mittelblaugrüngelb oder sowas in der Richtung) aussieht, weiß ich's leider auch nicht genau.

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
torstenheinze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 461



BeitragVerfasst: So 19.01.03 19:49 
ich denke, dann mus man einfach einen wert so lassen (z-B. blau) und ändert grün und rot um den gleichen wert
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: So 19.01.03 20:33 
also wenn du ein reines blau hast, und dann rot und grün um die gleichen werte anhebst ändert sich das blau in richtuing weiß ab !

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Rool
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 211



BeitragVerfasst: So 19.01.03 21:16 
Titel: So gehts:
Hier der Code:

zuerst mal n paar deklarationen:

ausblenden Quelltext
1:
2:
3:
RGBColorType = record
     R,G,B: Longint
end;


dann ne nebenfunktion und die hauptfunktion:



ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
function RGBsplit(Col:TColor):RGBColorType;
var cRGB: RGBColorType;
begin
  cRGB.B := (Col And 16711680) div 65536;
  cRGB.G := (Col And 65280) div 256;
  cRGB.R := Col And 255;
  Result:=cRGB
end;


function IncColor(Col: TColor; Increments: Integer): TColor;
var cRGB: RGBColorType;
begin
     cRGB:=RGBSplit(ColorToRGB(Col));
     if not (cRGB.R + Increments>255) then
        Inc(cRGB.R,Increments)
     else
        cRGB.R:=255; 
     if not (cRGB.G + Increments>255) then
        Inc(cRGB.G,Increments)
     else
         cRGB.G:=255;
     if not (cRGB.B + Increments>255) then
        Inc(cRGB.B,Increments)
     else
         cRGB.B:=255;
     result:=RGB(cRGB.R,cRGB.G,cRGB.B);

end;


Mit IncColor erhöhst du die Farbe um Increments!!

Hoffe es hat dir geholfen!

_________________
MFG Rool
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: So 19.01.03 21:20 
Hi,

ich kann dir die Theorie mal erklären *g*

Also... du hast die Farbe in RGB, wandelst sie in HSL (Hue, Saturation, Light) um, erhöst den Hue wert und wandelst wieder in RGB um... :)

Units/Kompos für HSLtoRGB etc gibt's genügend, such einfach mal.

Au'revoir,
Aya~
maxk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Mo 20.01.03 11:39 
:P Danke, ich werd's mal ausprobieren!

maxk

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
Rool
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 211



BeitragVerfasst: Mo 20.01.03 13:34 
Titel: Verbesserung...
Was ich noch zu meinem Code oben sagen muss ist, dass wenn du ne Farbe nimmst wie zB. clBtnFace, musst du sie erst in RGB umwandeln. also zb. so:

ausblenden Quelltext
1:
 Self.Color:=IncColor(ColorToRGB(clBtnFace),10);					

_________________
MFG Rool
maxk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Di 21.01.03 16:56 
Es funzt! :beer:

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.