Thema: Delphi Vignette effect

Einzelnen Beitrag anzeigen

Benutzerbild von sx2008
sx2008

Registriert seit: 16. Feb 2008
Ort: Baden-Württemberg
2.332 Beiträge
 
Delphi 2007 Professional
 
#6

AW: Vignette effect

  Alt 18. Sep 2010, 00:19
I think the following function is faster and easier to understand
than the gaussian function:

Delphi-Quellcode:
function CalcVignetteBrightness(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;

Geändert von sx2008 (18. Sep 2010 um 00:30 Uhr) Grund: Double -> Single
  Mit Zitat antworten Zitat