![]() |
if routine für getpixel (brett vorm kopf)
hallöchen community
die panels haben von anfang an ne weisse farbe. mal angenommen das foto was ich auf farbanteile durchsuche hat an der vorgegebenen Pixelposition keinen blau oder grünanteil, und somit ändert sich die panelfarbe auch nicht. wie schreibe ich nun ne IF routine das wenn die panelfarbe nach dem prüfen immernoch weiss ist, an pixelposition X+1,Y+1 gesucht wird, bzw anstatt der 506 meinetwegen ne 508?
Code:
begin
DWord(AColor) := GetPixel(dc,506,554); //Blauanteil eines Fotos if (AColor[1] > 220) and (AColor[2] > 95) and (AColor[3] > 190) then panel1.color :=clBLUE; //Grünanteil eines fotos if (AColor[1] > 190) and (AColor[2] < 50) and (AColor[3] < 50) then panel2.color :=clGREEN; if panel1.color := clwhite then... ??! danke. |
AW: if routine für getpixel (brett vorm kopf)
Suchst evtl. eine Schleife?
Delphi-Quellcode:
var
x, y : integer; x := 1; y:= 1; while panel1.Color = clWhite do begin ... Inc( x ); Inc( y ); // im 45 Grad Winkel durch das Bild end; |
AW: if routine für getpixel (brett vorm kopf)
im prinzip schon...allerdings wollte ich nicht die ganzen farbsuchroutinen wieder runterschreiben sondern dachte ich könnte einfach die koordinaten oberhalb der suchroutinen ändern, so das automatisch nach den farben in der neuen koordinate gesucht wird....denn sonst wird der code ingesamt 10 mal so groß, wenn ich für jede koordinate noch 2 alternative angebe samt farbschemata :S
|
AW: if routine für getpixel (brett vorm kopf)
:wiejetzt:
Eine Schleife ist dafür da einen Codeteil mehrmals zu durchlaufen, damit man den eben NICHT x-mal tippen muss. |
AW: if routine für getpixel (brett vorm kopf)
i see :-)
hab das hier jetzt ausprobiert, allerdings hängt er sich mehr oder weniger auf, ziel war eigentlich das er nach jedem durchlauf X um 1 erhöht wenn die farbe nicht gefunden wurde.
Code:
ne idee?
var
x:integer; ... x:=0; while panel1.Color = clwhite do begin DWord(AColor) := GetPixel(dc,506+x,554); //Blauanteil eines Fotos if (AColor[1] > 220) and (AColor[2] > 95) and (AColor[3] > 190) then panel1.color :=clBLUE; //Grünanteil eines fotos if (AColor[1] > 190) and (AColor[2] < 50) and (AColor[3] < 50) then panel2.color :=clGREEN; x:= +1; end; |
AW: if routine für getpixel (brett vorm kopf)
Delphi-Quellcode:
Aber dann sollte es eine zusätzliche Abbruchbedingung geben.
x := x + 1;
Vieleicht besser so:
Delphi-Quellcode:
for x := {xMin} to {xMax} do
begin if {TestFarbe1} then begin panel1.color := clBLUE; Break; end; if {TestFarbe2} then begin panel1.color := clGREEN; Break; end; end; |
AW: if routine für getpixel (brett vorm kopf)
Zitat:
kaum macht man es richtig, schon funktionierts ;-) |
Alle Zeitangaben in WEZ +1. Es ist jetzt 07:10 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