Autor Beitrag
MaximusMR
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27



BeitragVerfasst: Fr 06.09.02 11:40 
Wenn ich auf ein Bild klicke möchte ich das Delphi die Farbe erkennt.
Mein Problem ist einfach das eine Variable hochgezählt werden soll, wenn man auf einen Kreis klickt. Allerdings kann man in meinem derzeitigen Programm auch in die ecken klicken wo der Kreis schon ende ist. das soll abgefangen werden.

Mit der Farberkennung wäre das einfach. Da der Kreis Rot und der hintergrund weiß ist.

Also wie geht das???
Visum
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 106



BeitragVerfasst: Fr 06.09.02 14:18 
Hi,
wie malst du den Kreis?

Wenn du ein TImage benutzt und eine BMP darin hast, müsste es so gehen:
Im OnMousedown-Ereignis:
ausblenden Quelltext
1:
2:
if Deinbild.Canvas.Pixels[x,y]<>clwhite then 
variable:=variable+1;


Bei einem TImage mit JPG geht es so:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
var bmp:tbitmap;
...
bmp:=tbitmap.Create;
bmp.Width:=image1.Width;
bmp.Height:=image1.Height;
bmp.Assign(image1.Picture.Graphic);
if bmp.Canvas.Pixels[x,y]<>clwhite then
variable:=variable+1;


mfG,
visum
MaximusMR Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27



BeitragVerfasst: Fr 06.09.02 15:05 
Hast du das da mt BMP und jpg verwechselt. Naja mit dem kurzen gehts nich ganz. ich teste mal das andere.

Also bei mir ist ein BMP-Bild.
MaximusMR Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27



BeitragVerfasst: Fr 06.09.02 15:11 
Das Bild selber heißt "Kreis"

Im moment pasiert nichts wenn ich auf das Bild klicke. hier is der QT:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
procedure TForm1.KreisClick(Sender: TObject);
var 
  bmp:tbitmap;
  x,y:integer; 
begin
  bmp:=tbitmap.Create; 
  bmp.Width:=image1.Width; 
  bmp.Height:=image1.Height; 
  bmp.Assign(image1.Picture.Graphic); 
  if bmp.Canvas.Pixels[x,y]<>clwhite then
    begin
      exit;
    end
  else
    x:=x+1;

  label1.caption:=inttostr(x);
end;


Code-Tags hinzugefügt. TINO
Visum
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 106



BeitragVerfasst: Fr 06.09.02 22:49 
Bei OnClick geht das nicht, das muss im OnMouseDown Ereignis behandelt werden. Da werden die Koordinaten der Maus als x und y direkt mitgegeben.
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.SGEinkaufslisteMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Kreis.Canvas.Pixels[x,y]<>clwhite then x:=x+1; 
label1.caption:=inttostr(x); 
end;

OnMouseDown findest du im Objectinspector unter Ereignisse.
MaximusMR Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27



BeitragVerfasst: Sa 07.09.02 09:49 
Wo ich das finde weiß ich ja. Aber ich wusste nicht das da x und y immer ermittelt werden.
Werde ich direkt mal testen.
MaximusMR Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27



BeitragVerfasst: Sa 07.09.02 10:11 
Klappt wunderbar!!!! danke