Imagem - transformar em negativo

Top  Previous  Next

Transforma a imagem em negativo de fotografia

procedure ColorToNegative(ABmp: TBitmap);

//

// Transforma a imagem em negativo de fotografia

//

// Use-o assim:

//

// var x: TBitmap;

// begin

//

// x := TBitmap.create;

// x.LoadFromFile('c:\MVC-267S.bmp');

// ColorToNegative(x);

// image1.Picture.Assign(x);

// end;

//

//

const

  _high = 255;

var

  c: TCursor;

  x, y: Integer;

  ColorRGB: LongInt;

begin

  c := Screen.Cursor;

  Screen.Cursor := crHourGlass;

  for y := 0 to (ABmp.Height - 1) do

    for x := 0 to (ABmp.Width - 1) do

    begin

     ColorRGB := ColorToRGB(ABmp.Canvas.Pixels[x, y]);

     ABmp.Canvas.Pixels[x, y] := PaletteRGB(_high - GetRValue(ColorRGB),_high - GetGValue(ColorRGB), _high - GetBValue(ColorRGB));

    end;

    Screen.Cursor := c;

end;