-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathefekty.pas
executable file
·77 lines (58 loc) · 1.89 KB
/
efekty.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
unit efekty;
interface
uses Types, Graphics, Math;
procedure Blur(const bitmap: TPicture; const amount: Real);
procedure Glow(const bitmap: TPicture; const amount, radius: Real);
implementation
procedure Blur(const bitmap: TPicture; const amount: Real);
const
SCALE = 2;
var
sw, sh, scw, sch, steps, i: Integer;
copy: TBitmap;
begin
sw:= round(bitmap.Width / SCALE);
sh:= round(bitmap.Height / SCALE);
copy:= TBitmap.Create;
copy.PixelFormat:= pf24bit;
copy.Width:= sw;
copy.Height:= sh;
steps:= round(amount * 20);
for i:= 0 to steps-1 do
begin
scw:= max(1, round(sw - i));
sch:= max(1, round(sw - i));
copy.Canvas.FillRect(Bounds(0,0,sw,sh));
copy.Canvas.CopyRect(Bounds(0,0,scw,sch), bitmap.Bitmap.Canvas, Bounds(0,0,bitmap.Width,bitmap.Height));
bitmap.Bitmap.Canvas.CopyRect(Bounds(0,0,bitmap.Width,bitmap.Height), copy.Canvas, Bounds(0,0,scw,sch));
end;
copy.Free;
end;
procedure Glow(const bitmap: TPicture; const amount, radius: Real);
const
SCALE = 2;
var
sw, sh, scw, sch, steps, i: Integer;
copy, blur: TBitmap;
begin
{blur:= TBitmap.Create;
blur.PixelFormat:= pf24bit;
blur.Width:= bitmap.Width;
blur.Height:= bitmap.Height;
blur.Canvas.CopyRect(Bounds(0,0,bitmap.Width,bitmap.Height), bitmap.Canvas, Bounds(0,0,bitmap.Width,bitmap.Height));
sw:= round(bitmap.Width / SCALE);
sh:= round(bitmap.Height / SCALE);
copy:= TBitmap.Create;
copy.PixelFormat:= pf24bit;
copy.Width:= sw;
copy.Height:= sh;
steps:= round(radius * 20);
for i:= 0 to steps-1 do
begin
scw:= max(1, round(sw - i));
sch:= max(1, round(sw - i));
copy.Canvas.CopyRect(Bounds(0,0,scw,sch), bitmap.Canvas, Bounds(0,0,bitmap.Width,bitmap.Height));
blur.Canvas.CopyRect(Bounds(0,0,bitmap.Width,bitmap.Height), copy.Canvas, Bounds(0,0,scw,sch));
end; }
end;
end.