Einzelnen Beitrag anzeigen

Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.153 Beiträge
 
Delphi 12 Athens
 
#10

Re: Vergleichen zweier BitMaps

  Alt 13. Nov 2003, 20:34
Stimmt, meinte natürlich ABS.
Das mit dem XOR, weis auch nicht was da in meinem Kopf fehlgeleitet wurde. (hatte mir auch ein paar Werte durchgerechnet, und da stimmte es fast)


Na dann optimieren wir mal in Richtung Graustufen.
Delphi-Quellcode:
Var R1, G1, B1, R2, G2, B2, Re, Ge, Be: Byte;

{je Pixel}
R1 := Bild1.Canvas.Pixels[X, Y] and $0000FF;
G1 := (Bild1.Canvas.Pixels[X, Y] and $00FF00) shr 8;
B1 := (Bild1.Canvas.Pixels[X, Y] and $FF0000) shr 16;

R2 := Bild2.Canvas.Pixels[X, Y] and $0000FF;
G2 := (Bild2.Canvas.Pixels[X, Y] and $00FF00) shr 8;
B2 := (Bild2.Canvas.Pixels[X, Y] and $FF0000) shr 16;

Re := ABS(R1 - R2);
Ge := ABS(G1 - G2);
Be := ABS(B1 - B2);

Bild3.Canvas.Pixels[X, Y] := RGB(Re, Ge, Be);
wird zu:
Delphi-Quellcode:
Var C: Byte;

{je Pixel}
C := ABS((Bild1.Canvas.Pixels[X, Y] and $0000FF) - (Bild2.Canvas.Pixels[X, Y] and $0000FF));
Bild3.Canvas.Pixels[X, Y] := RGB(C, C, C);
oder:
Delphi-Quellcode:
Var C: Byte;

{je Pixel}
C := ABS((Bild1.Canvas.Pixels[X, Y] and $0000FF) - (Bild2.Canvas.Pixels[X, Y] and $0000FF));
Bild3.Canvas.Pixels[X, Y] := (C shl 16) or (C shl 8) or C;
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests
  Mit Zitat antworten Zitat