Delphi-PRAXiS
Seite 3 von 3     123   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   Delphi Negativ bei TImage (https://www.delphipraxis.net/67595-negativ-bei-timage.html)

Martin K 17. Apr 2006 14:48

Re: Negativ bei TImage
 
Zitat:

Zitat von xaromz
Hallo,

das ist üblicher:
Delphi-Quellcode:
function Umkehrfarbe(const Color: TColor): TColor;
begin
  Result := not ColorToRGB(Color);
end;
Gruß
xaromz

Ne, das funzt irgendwie nicht.
Da bekomme ich ja negative Zahlen raus...

xaromz 17. Apr 2006 14:50

Re: Negativ bei TImage
 
Hallo,
Zitat:

Zitat von Martin K
Ne, das funzt irgendwie nicht.
Da bekomme ich ja negative Zahlen raus...

Ja, und?

Gruß
xaromz

Hawkeye219 17. Apr 2006 14:53

Re: Negativ bei TImage
 
Hier noch mal ein dezenter Hinweis auf CopyMode:

Delphi-Quellcode:
BMP.Canvas.CopyMode := cmDstInvert;
BMP.Canvas.Draw (0, 0, BMP);
Der Code invertiert das komplette Bild ohne Berücksichtigung einer Farbe.

Zitat:

Zitat von xaromz
Delphi-Quellcode:
B := P[x * 3]; // Die einzelnen Farbwerte holen
G := P[x * 3 + 1];
R := P[x * 3 + 2];

if R = 255 then // wenn Rotanteil voll

Auch bei weiß ist der Rotanteil "voll" :wink:

Gruß Hawkeye

Martin K 17. Apr 2006 14:55

Re: Negativ bei TImage
 
Zitat:

Zitat von xaromz
Hallo,
Zitat:

Zitat von Martin K
Ne, das funzt irgendwie nicht.
Da bekomme ich ja negative Zahlen raus...

Ja, und?

Gruß
xaromz

Hab mir sowas gebastelt:
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
begin
  If ColorDialog1.Execute then
    Form1.Color := not ColorToRGB(ColorDialog1.Color);
end;
Entweder bleibt dann die Farbe meiner Form (clBtnFace) oder sie wird schwarz.

Das hier dagegen funzt:
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
begin
  If ColorDialog1.Execute then
    Form1.Color := $FFFFFF-ColorDialog1.Color;
end;
Meine Form hat dann immer die Komplimentärfarbe von der im Colordialog.

turboPASCAL 17. Apr 2006 14:56

Re: Negativ bei TImage
 
Zitat:

Zitat von xaromz
Hallo,
Zitat:

Zitat von turboPASCAL
Und was ? :gruebel:

Delphi-Quellcode:
 p[x] := rgb(255 - p[x], 255 - p[x], 255 - p[x]);
Du weist einem Byte einen RGB-Farbwert (Integer) zu, den Du auch noch mit dreimal dem gleichen Wert erstellst.

Gruß
xaromz

Stimmt, ausgebessert.

Hawkeye219 17. Apr 2006 15:01

Re: Negativ bei TImage
 
Zitat:

Zitat von turboPASCAL
Stimmt, ausgebessert.

Nöö, verschlimmbessert! :wink:

Schaue Dir die x-Schleife noch mal genau an...

Gruß Hawkeye

xaromz 17. Apr 2006 15:07

Re: Negativ bei TImage
 
Hallo,

da hatte ich wohl auch einen kleinen Fehler drin. So ist's richtig:
Delphi-Quellcode:
function Umkehrfarbe(const Color: TColor): TColor;
begin
  Result := not ColorToRGB(Color) and $FFFFFF; // Erstes Byte muss null sein
end;
@Hawkeye: Das mit dem Rotanteil war ja nur ein Beispiel...

Gruß
xaromz


Alle Zeitangaben in WEZ +1. Es ist jetzt 01:35 Uhr.
Seite 3 von 3     123   

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz