Autor Beitrag
GR-Thunderstorm
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 206



BeitragVerfasst: Sa 09.06.07 21:15 
Hi,
ich habe folgendes Problem: Ich will per Knopfdruck herausfinden, welche RGB Werte die Farbe eines bestimmten Pixels in meinem Bild hat.

Soweit habe bin ich mit der Forensuche soweit gekommen, dass ich die Farbe in ein Editfeld schreiben kann:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.Button3Click(Sender: TObject);
begin
edit1.Text:=inttostr(image1.Canvas.Pixels[100,100]);
end;


In meinem Editfeld erscheinen dann Zahlen wie "16119285", mit denen ich leider nichts anfangen kann. Gibt es also eine Möglichkeit, die Farben so auszugeben, dass dann der Hexcode (z.B. "$00FFA15D") in meinem Editfeld erscheint?


Zuletzt bearbeitet von GR-Thunderstorm am Sa 09.06.07 21:21, insgesamt 1-mal bearbeitet
_frank_
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 343
Erhaltene Danke: 1

Win XP
Delphi 3 Prof / Turbo Delphi Explorer
BeitragVerfasst: Sa 09.06.07 21:20 
so z.B.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.Button3Click(Sender: TObject);
var c:TColor;
    r,g,b:byte;
begin
  c:=image1.Canvas.Pixels[100,100];
  r:=GetRValue(c);
  g:=GetGValue(c);
  b:=GetBValue(c);
  edit1.Text:=format('%d,%d,%d',[r,g,b]);
end;


HTH Frank
GR-Thunderstorm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 206



BeitragVerfasst: Sa 09.06.07 21:42 
THX! :wink:
Genau was ich gesucht hab! :)
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Sa 09.06.07 21:43 
Ansonsten noch ColorToString aus der Unit Graphics. Gibt das ganze als Hexstring aus - oder, falls die Farbe bekannt ist, ihren Namen ('clWhite', etc.).

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Sa 09.06.07 23:33 
Oder einfach statt IntToStr IntToHex(xy, 6) benutzen ;)

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.