![]() |
Image "Variable" erhöhen
Hallo,
vorweg: ich bin absoluter Delphi-Anfänger. Meine Frage ist wahrscheinlich ziemlich simpel für euch. Ich programmiere mit Delphi 7. Ich versuche mich an einer "Bild (klein) in Bild (groß) Abfrage". Diese funktioniert auch einwandfrei (habe ich via Suche in diesem Forum gefunden). Bild groß = Imggross Bild klein = Image1 Hier der Code ...
Delphi-Quellcode:
Was ich nun möchte ist ...dass wenn "Image1" (kleines Bild) in "Imggross" (großes Bild) nicht gefunden wurde, dass dann die "procedure TForm1.bild1"
procedure TForm1.bild1;
var x2, y, PosY, y1, Scanlength: integer; PosX: cardinal; FindScan: Pointer; Ok: boolean; begin Ok:= false; ImgGross.Picture.Bitmap.PixelFormat := pf24bit; image1.Picture.Bitmap.PixelFormat := pf24bit; FindScan:= image1.Picture.Bitmap.ScanLine[image1.Picture.Bitmap.Height div 2]; Scanlength:= image1.Picture.Bitmap.Width* 3; for y:= 0 to pred(ImgGross.Picture.Bitmap.Height) do for PosX:= 0 to Pred(ImgGross.Picture.Bitmap.Width- image1.Picture.Bitmap.Width) do //zuerst nur eine Zeile scannen if CompareMem(Pointer(Cardinal(ImgGross.Picture.Bitmap.ScanLine[y])+ PosX *3), FindScan, ScanLength) then begin//Zeile stimmt überein PosY:= y- image1.Picture.Bitmap.Height div 2; //jetzt noch den Rest des kleinen Bildes scannen if PosY>= 0 then begin x2:= 0; for y1:= PosY to PosY+ image1.Picture.Bitmap.Height- 1 do begin ok:= CompareMem(Pointer(Cardinal(ImgGross.Picture.Bitmap.ScanLine[y1])+ PosX *3), image1.Picture.Bitmap.ScanLine[x2], Scanlength); if not ok then break; inc(x2); end; end; if ok then begin ImgGross.Picture.Bitmap.Canvas.Brush.Style:= bsClear; ImgGross.Picture.Bitmap.Canvas.Pen.Color:= clRed; ImgGross.Picture.Bitmap.Canvas.Rectangle(PosX, PosY, PosX+ Cardinal(image1.Picture.Bitmap.Width), PosY+ image1.Picture.Bitmap.Height); exit; end; end; end; erneut durchläuft von vorne und zwar statt mit "Image1" mit "Image2" als kleinem Bild was in "Imggross" gesucht wird ... usw ...also wenn kleines Bild nicht gefunden wurde ..soll immer weiter gesucht werden ..mit Image2, Image3 , Image4 usw ... Meine kläglich gescheiterte idee war ...: statt: image1.Picture.Bitmap.PixelFormat := pf24bit; image[zz].Picture.Bitmap.PixelFormat := pf24bit; und variable ZZ (z.B. Integer) beim Programmstart auf 1 zu setzen und dann bei gescheitertem Suchdurchlauf um 1 zu erhöhen ... aber da kriege ich eine Fehlermeldung ..wie geht das? Ist bestimmt voll simpel oder? danke für eure hilfe und bitte um nachsicht ;-) frohes fest |
Re: Image "Variable" erhöhen
Delphi-Quellcode:
Das gibts nicht, wenn schon so:
mage[zz].Picture.Bitmap.PixelFormat := pf24bit;
Delphi-Quellcode:
(FindComponent('Image123') as TImage).Picture.Bitmap.PixelFormat := pf24bit;
|
Re: Image "Variable" erhöhen
Erstmal danke für die Antwort.
Und wie erhöhe ich jetzt damit? Sodass er beim ersten Durchlauf mit Image1 vergleicht .. wenn kein Treffer --> mit Image2 ... wenn kein Treffer --> mit Image 3 usw? Ist mir noch nicht ganz klar :( |
Re: Image "Variable" erhöhen
![]() Daher kannst du damit auch so etwas übergeben:
Delphi-Quellcode:
"i" ist dabei die Laufvariable für Image1, Image2, Image3, ...
// Schleife:
i := ...; (FindComponent('Image' + IntToStr(i))as TImage).Picture.Bitmap.PixelFormat := pf24bit; if ( { ... } ) then inc(i); |
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:40 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 by Thomas Breitkreuz