Forum: Multimedia
Delphi
by sx2008,
18. Sep 2010
function CalcVignetteBrightness(X, Y: Single): Single;
var
distance : Single;
inner_radius, outer_radius, : Single;
begin
inner_radius := 50;
outer_radius := 150;
x := x * 0.75; // <= try this
// calculate the distance from the origin (center of the image)
Forum: Multimedia
Delphi
by sx2008,
18. Sep 2010
Hmm ,there is a little bug:
else if distance <= outer_radius then
// decreasing Brightness from 100% downto 0%
// result := (distance - inner_radius) / (outer_radius - inner_radius) // wrong
result := (outer_radius - distance) / (outer_radius - inner_radius)
Forum: Multimedia
Delphi
by sx2008,
18. Sep 2010
You must multiply with the brightness factor.
And you have to care about arithmetic overflow.
function ClampByte(value:Integer):Byte;
begin
if value > 255 then
result := 255
(* not neccesary when a pixel is multiplied with a positive value
else if value < 0
result := 0
Forum: Multimedia
Delphi
by sx2008,
17. Sep 2010
I think the following function is faster and easier to understand
than the gaussian function:
function CalcVignetteBrightness(X, Y: Single): Single;
var
distance : Single;
inner_radius, outer_radius : Single;
begin
inner_radius := 50;
outer_radius := 150;
Forum: Multimedia
Delphi
by sx2008,
16. Sep 2010
You could calculate the brightness of every Pixel with a 2-dimensional Gaussian function.
Here is some Pseudocode:
xcenter := Bitmap.Width div 2;
ycenter := Bitmap.Height div 2;
for each Pixel do
begin
brightness_factor := mygaussian(x - xcenter, y-ycenter)* 0.5{=effect depth} + 0.3{basic brightness};
Pixel.red := Pixel.red * brightness_factor;
Pixel.green := Pixel.green *...