Thema: Delphi Negativ bei TImage

Einzelnen Beitrag anzeigen

xaromz

Registriert seit: 18. Mär 2005
1.682 Beiträge
 
Delphi 2006 Enterprise
 
#13

Re: Negativ bei TImage

  Alt 17. Apr 2006, 14:33
Hallo,
Zitat von Martin K:
Also den Code von turboPASCAL verstehe ich nicht.
Da ist auch was falsch.

Versuch's mal hiermit:
Delphi-Quellcode:
procedure NegativeBitmapFX(aBitmap: TBitmap);
var
  x, y: integer; // Koordinaten
  p: pbytearray; // Pixel
begin
  aBitmap.PixelFormat := pf24Bit; // Damit wir 3 Byte pro Pixel haben

  for y := 0 to aBitmap.Height - 1 do // Bildzeilen durchgehen
  begin
    p := aBitmap.scanline[y]; // Pointer auf aktuelle Zeile
    for x := 0 to (aBitmap.Width * 3) - 1 do // Jedes Pixel duchgehen (1 Pixel -> 3 Byte)
      p[x] := not p[x]; // Invertieren
  end;
end;
Wenn Du einzelne Farben prüfen willst, dann versuch Folgendes:
Delphi-Quellcode:
procedure NegativeBitmapFX(aBitmap: TBitmap);
var
  x, y: integer; // Koordinaten
  p: pbytearray; // Pixel
  R, G, B: Byte;
begin
  aBitmap.PixelFormat := pf24Bit; // Damit wir 3 Byte pro Pixel haben

  for y := 0 to aBitmap.Height - 1 do // Bildzeilen durchgehen
  begin
    p := aBitmap.scanline[y]; // Pointer auf aktuelle Zeile
    for x := 0 to aBitmap.Width - 1 do // Jedes Pixel duchgehen
    begin
      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
      begin
        P[x * 3] := not P[x * 3]; // Farbwerte invertieren
        P[x * 3 + 1] := not P[x * 3 + 1];
        P[x * 3 + 2] := not P[x * 3 + 2];
      end;
    end;
  end;
end;
Gruß
xaromz
  Mit Zitat antworten Zitat