Thema: Delphi Vignette effect

Einzelnen Beitrag anzeigen

WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#7

Re: Vignette effect

  Alt 18. Sep 2010, 13:09
This is what I have:

Delphi-Quellcode:
function VignetteBrightness(X, Y: Single): Single;
var
  distance: Single;
  inner_radius, outer_radius: Single;
begin
  inner_radius := 50;
  outer_radius := 150;

  // calculate the distance from the origin (center of the image)
  distance := SQRT(SQR(x) + SQR(Y));

  if distance <= inner_radius then
    result := 1.0 // Brightness 100%
  else if distance <= outer_radius then
    // decreasing Brightness from 100% downto 0%
    result := (distance - inner_radius) / (outer_radius - inner_radius)
  else
    result := 0.0; // it's dark outside the outer_radius
end;

procedure Vignette(ASource: TBitmap32);
var
  Bits: PColor32Entry;
  I, J, XCenter, YCenter: Integer;
  Brightness: Single;
begin
  XCenter := ASource.Width div 2;
  YCenter := ASource.Height div 2;

  Bits := @ASource.Bits[0];

  for J := 0 to ASource.Height - 1 do
  begin
    for I := 0 to ASource.Width - 1 do
    begin
      Brightness := VignetteBrightness(I - XCenter, J - YCenter) * 0.5{=effect depth} + 0.3{basic brightness};

      Bits.R := IntToByte(Round(Bits.R + Brightness));
      Bits.G := IntToByte(Round(Bits.G + Brightness));
      Bits.B := IntToByte(Round(Bits.B + Brightness));

      Inc(Bits);
    end;
  end;

  ASource.Changed;
end;
And no effect - image not changed. Why?
I tried change inner_radius, outer_radius, effect depth and basic brightness, bot no effect too
  Mit Zitat antworten Zitat