Autor Beitrag
Daniel_100
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 63

Win XP
D3 Prof, D6 Enterprise
BeitragVerfasst: So 15.06.03 09:27 
Hallo!

Mit welchem Code vergleicht man zwei Images?

Also:
Wenn Image1 = Image2 dann
(Aktion)
GSE
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 740

Win 2k, Win XP Pro
D5 Prof, D6 Ent, D2k5 PE
BeitragVerfasst: So 15.06.03 10:05 
Hi,
SwissDelphiCenter hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
...zwei Bilder Pixel um Pixel vergleichen?  

procedure TForm1.Button1Click(Sender: TObject); 
var 
  b1, b2: TBitmap; 
  c1, c2: PByte; 
  x, y, i, 
  different: Integer; // Counter for different pixels 
begin 
  b1 := Image1.Picture.Bitmap; 
  b2 := Image2.Picture.Bitmap; 
  Assert(b1.PixelFormat = b2.PixelFormat); // they have to be equal 
  different := 0; 
  for y := 0 to b1.Height - 1 do 
  begin 
    c1 := b1.Scanline[y]; 
    c2 := b2.Scanline[y]; 
    for x := 0 to b1.Width - 1 do 
      for i := 0 to BytesPerPixel - 1 do // 1, to 4, dep. on pixelformat 
      begin 
        Inc(different, Integer(c1^ <> c2^)); 
        Inc(c1); 
        Inc(c2); 
      end; 
  end; 
end;


Musst da halt nur ein bisschen veränder, sprich: ´ne Funktion draußmachen und sofort wenn different > 0, abbrechen und false zurückgeben.

mfg
GSE

_________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs
and the universe trying to produce bigger and better idiots. So far, the universe is winning. (Richard Cook)


Zuletzt bearbeitet von GSE am So 15.06.03 16:26, insgesamt 1-mal bearbeitet
Daniel_100 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 63

Win XP
D3 Prof, D6 Enterprise
BeitragVerfasst: So 15.06.03 12:17 
Geht das auch so, dass z.B. nur die Dateinamen verglichen werden?
GSE
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 740

Win 2k, Win XP Pro
D5 Prof, D6 Ent, D2k5 PE
BeitragVerfasst: So 15.06.03 14:09 
Dann ist es aber doch kein richtiger Vergleich.
Wann und Wo vergleichst du überhaupt, wenn man was aus der Zwischenablage einfügen kann, wie willst du das dann über Dateinamen machen?

mfg
GSE

_________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs
and the universe trying to produce bigger and better idiots. So far, the universe is winning. (Richard Cook)
Daniel_100 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 63

Win XP
D3 Prof, D6 Enterprise
BeitragVerfasst: So 15.06.03 14:20 
Es soll so sein:
In einer Form sind zwei Bilder: Image1 und Image2. Im Image1 ist ein Bild, im 2. keins. Wenn man nun auf das Image2 klickt, wird ein Bild dort "hineingeladen" und es wird sofort verglichen, ob es mit dem 1. übereinstimmt. Wenn ja, dann soll der PC ne Meldung ausspucken, wenn nein, dann passiert nichts!

Aber wenn's halt anders nicht geht, dann probier ich es erstmal so.

Daniel
Terra23
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 872

Win 8
Delphi 7
BeitragVerfasst: So 15.06.03 16:19 
@Daniel: Ja, aber wie vergleichen? Pixel für Pixel, wie GSE dir geschrieben hat?

Wenn du nur den Pfad willst, kannst du ja

ausblenden Delphi-Quelltext
1:
2:
3:
If Image1.FileName=Image2.FileName
Then Tue dies und das
Else Tue jenes und welches


nehmen. Das ist aber ungeschickt, möchte man meinen. Denn:

Wenn ich z.B. ein Bild von einem Model hast ;-), dann kannst du das doch überall speichern.

Ich sichere es z.B. dann so:

C:\Windows\Model.jpg
C:\Eigene Daeien\Model.jpg
C:\Model.jpg

Das ist doch das, was GSE dir sagen wollte. Der Pfad ist dann unterschiedlich, aber das Bild ist im Grunde das gleiche..

_________________
Hasta La Victoria Siempre
GSE
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 740

Win 2k, Win XP Pro
D5 Prof, D6 Ent, D2k5 PE
BeitragVerfasst: So 15.06.03 16:28 
Terra23 hat folgendes geschrieben:
Das ist doch das, was GSE dir sagen wollte. Der Pfad ist dann unterschiedlich, aber das Bild ist im Grunde das gleiche..
Yepp.

@Daniel_100
Was gefällt dir an der Funktion eigentlich nicht, da sie Scanline verwendet ist sie doch eigntlich recht fix, oder?

_________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs
and the universe trying to produce bigger and better idiots. So far, the universe is winning. (Richard Cook)
Daniel_100 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 63

Win XP
D3 Prof, D6 Enterprise
BeitragVerfasst: Mo 16.06.03 17:06 
Ich kenn mich halt nicht so aus (scanline?) :oops: ; und wenn ich dann so ein für mich unbekannten Code sehe, ist das dann schon kompliziert. :?

Trotzdem, danke,

Daniel


Zuletzt bearbeitet von Daniel_100 am Mo 16.06.03 17:19, insgesamt 1-mal bearbeitet
Daniel_100 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 63

Win XP
D3 Prof, D6 Enterprise
BeitragVerfasst: Mo 16.06.03 17:17 
Zitat:
ausblenden Delphi-Quelltext
1:
2:
3:
If Image1.FileName=Image2.FileName 
Then Tue dies und das 
Else Tue jenes und welches


Der Code funktioniert nicht (Undeclared identifier: 'filename') :o !

Geht das nicht noch in einer ähnlichen Form?

Daniel
GSE
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 740

Win 2k, Win XP Pro
D5 Prof, D6 Ent, D2k5 PE
BeitragVerfasst: Mo 16.06.03 17:37 
Wenn du es so machst, dann musst du die Pfade der Bilder in Strings speichern und vergleichen, da ja in der ImageKompo nur die Bildinformation (sprich: welches Pixel hat welche Farbe) gespeichert wird.

mfg
GSE

_________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs
and the universe trying to produce bigger and better idiots. So far, the universe is winning. (Richard Cook)
Terra23
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 872

Win 8
Delphi 7
BeitragVerfasst: Mo 16.06.03 18:49 
@Daniel:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
Z1:=Image1.FileName;
Z2:=Image2.FileName;

If Z1=Z2 Then Tue dies Else Tue das;


Wie gesagt, es geht aber so nicht gescheit, weil ich den Dateinamen doch selber bestimmen kann, verstehst du? Nehmen wir wieder das Bikini-Model als Beispiel:

Ich kann doch das gleiche Bild als "Model.jpg" speichern und auch als "Stranschönheit.jpg". Es ist das gleiche Bild, nur der Name ist anders. Was spricht denn gegen die Prozedur von GSE?

Sein Code wird ja schon auf ButtonClick aufgerufen; sollte sogar selbst bei jemandem funktionieren, der nur kopieren will. :-) Nichts für Ungut..

_________________
Hasta La Victoria Siempre
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Di 17.06.03 21:07 
willst du die bilder vergelichen oder nur die dateinamen ?

_________________
MFG
Michael Springwald, "kann kein englisch...."
isocam
Hält's aus hier
Beiträge: 4



BeitragVerfasst: Mo 03.05.04 16:14 
Titel: -
Ich habe ein ähnliches Problem.
Pixel für Pixel zu vergleichen ist doch viel zu kompliziert gedacht.
Nehmen wir ein Memory-Spiel.
Dort muss doch verglichen werden, ob zwei Bilder (sind gleich groß und haben gleiches Pixelformat) identisch sind oder nicht. Ich habe probiert:
var bild:array[0..1] of TBitmap;
Bild1: bild[0]:=bildchen.picture.bitmap; (erster Durchlauf)
Bild2: bild[1]:= bildchen.picture.bitmap; (zweiter Durchlauf, jetzt ein anderes Bildchen)
(Bildchen ist ne dynamische Komponente (also die Memorykarten)

beim Vergleich bild[0] <> bild[1] kommt IMMER false raus.

Wäre nett, wenn jemand helfen könnte.
Ich glaube das Problem entspricht prinzipiell dem des Threaderöffners.