Autor Beitrag
StefanH
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1144

Win XP
D5 Standard, D7 Pers, D2005 Pers
BeitragVerfasst: So 18.01.04 15:33 
Hallo!

wie kann ich eine Farbe umkehren, sprich aus schwarz wird weiß oda so?
mir fällt irgendwie niks dazu ein... :?
:roll:

Stefan

_________________
"Als es noch keine Computer gab, war das Programmieren noch relativ einfach."(Edsger W. Dijkstra)
"Ich bin nicht von Sinnen, sondern ich rede wahre und vernünftige Worte." (Paulus)
Andreas Pfau
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 997



BeitragVerfasst: So 18.01.04 15:42 
Hallo,

erstmal die Farbkomponenten ruassuchen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var
  R, G, B: Byte;
begin
  R := MyColor and $FF;
  G := MyColor shr 8 and $FF;
  B := MyColor shr 16 and $FF;

Dann umkehren:
ausblenden Delphi-Quelltext
1:
2:
3:
R := 255 - R;
G := 255 - G;
B := 255 - B;

Und wieder eine TColor draus machen:
ausblenden Delphi-Quelltext
1:
MyColor := R or (G shl 8) or (B shl 16);					

Fertig.

_________________
Life is a bad adventure, but the graphic is really good!
StefanH Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1144

Win XP
D5 Standard, D7 Pers, D2005 Pers
BeitragVerfasst: So 18.01.04 16:04 
danke :D

_________________
"Als es noch keine Computer gab, war das Programmieren noch relativ einfach."(Edsger W. Dijkstra)
"Ich bin nicht von Sinnen, sondern ich rede wahre und vernünftige Worte." (Paulus)
Andreas Pfau
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 997



BeitragVerfasst: So 18.01.04 16:12 
Hallo,

:oops: aähem... sorry dass mir das jetzt erst einfällt, aber... Ich hatte mal das Problem, dass ich ein Panel hatte, dessen Farbe man ändern konnte. Darauf war ein Text - in Komplenetärfarbe. Da Problem: Bei mittlerem Grau ist die Komplenetärfarbe fast die selbe - Kontrast annähernd null.

Also habe ich damals noch nen 2. Algo entwickelt:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
function Contrast(Color: TColor): TColor;
var
  R, G, B: Integer;
begin
  Color := ColorToRgb(Color);
  R := Color and $FF;
  G := (Color and $FF00) shr 8;
  B := (Color and $FF0000) shr 16;
  if ((R * 0.239) + (G * 0.686) + (B * 0.075) >= 127.5) then
    Result := clBlack
  else
    Result := clWhite;
end;

Der Rückgabewert ist entweder schwarz oder weiß - je nach dem, was grade den besseren Kontrast liefert.

_________________
Life is a bad adventure, but the graphic is really good!
StefanH Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1144

Win XP
D5 Standard, D7 Pers, D2005 Pers
BeitragVerfasst: So 18.01.04 17:43 
ok -- dann nehm ich des. ich hab auch ein Panel :-)

_________________
"Als es noch keine Computer gab, war das Programmieren noch relativ einfach."(Edsger W. Dijkstra)
"Ich bin nicht von Sinnen, sondern ich rede wahre und vernünftige Worte." (Paulus)