-
Notifications
You must be signed in to change notification settings - Fork 19
/
cGraphBkgColorParams.pas
121 lines (100 loc) · 4.39 KB
/
cGraphBkgColorParams.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
UNIT cGraphBkgColorParams;
{=============================================================================================================
Gabriel Moraru
2023.08.05
See Copyright.txt
--------------------------------------------------------------------------------------------------------------
Used by cGraphBkgColor.pas
The DFM editor for these parameters is in: cGraphBkgColorEditor.pas
Tester:
c:\MyProjects\Project Testers\gr cGraphBorder.pas tester\TesterFadeBrd.dpr
--------------------------------------------------------------------------------------------------}
INTERFACE
USES
System.SysUtils, Vcl.Graphics, ccStreamBuff;
TYPE
TBorderType = (btTop, btBottom, btLeft, btRight);
TBorderSet = set of TBorderType;
TFillType = (ftSolid, { Don't fade. Use color }
ftFade); { Fade borders to color. Super slow }
TEffectShape= (esRectangles, esTriangles, esOneColor);
TEffectColor= (ecAutoDetBorder, { Detect border color }
ecImageAverage, { Use average image color }
ecUserColor); { Use user-provided color }
PBkgColorParams= ^RBkgColorParams;
RBkgColorParams= record
FillType : TFillType;
EffectShape : TEffectShape;
EffectColor : TEffectColor;
FadeSpeed : Integer; { How fast the margins of the image will fade to background color. This is multiplied with 100 so I don't have to show to the user or store to disk decimal values}
EdgeSmear : Byte; { Makes the edge of the image to smear towards the borders of the screen. Default: 0 }
NeighborWeight : Integer; { Factor applied to neighbour pixels when computing the 3-pixel average. Give more intens colors and longer trails (fade) for higher values. This is multiplied with 100 so I don't have to show to the user or store to disk decimal values}
NeighborDist : Integer; { Fuzzyness}
Tolerance : Integer; { Border detection/tolerance }
Color : TColor;
procedure Reset;
private
CONST CurrentVersion: Integer= 1;
public
procedure ReadFromStream(IOStream: TCubicBuffStream);
procedure WriteToStream (IOStream: TCubicBuffStream);
end;
IMPLEMENTATION
procedure RBkgColorParams.Reset;
begin
FillType := ftSolid;
EffectShape := esOneColor;
EffectColor := ecImageAverage;
FadeSpeed := 200;
EdgeSmear := 0;
NeighborWeight := 100;
NeighborDist := 2;
Tolerance := 8; { Border detection }
Color := TColor($218F42); { Albastru+gri+negru }
end;
procedure RBkgColorParams.ReadFromStream(IOStream: TCubicBuffStream);
begin
VAR Version:= IOStream.ReadInteger;
if Version = CurrentVersion then
begin
{ Current }
Color := IOStream.ReadInteger;
FillType := TFillType (IOStream.ReadByte);
EffectShape := TEffectShape(IOStream.ReadByte);
EffectColor := TEffectColor(IOStream.ReadByte);
EdgeSmear := IOStream.ReadByte;
NeighborDist := IOStream.ReadInteger;
Tolerance := IOStream.ReadInteger;
FadeSpeed := IOStream.ReadInteger;
NeighborWeight:= IOStream.ReadInteger;
IOStream.ReadPadding(64);
end
else
begin
{ Up to BioniX v13 inclusive }
Color := IOStream.ReadInteger;
FillType := TFillType (IOStream.ReadByte);
EffectShape := TEffectShape(IOStream.ReadByte);
EffectColor := TEffectColor(IOStream.ReadByte);
EdgeSmear := IOStream.ReadByte;
NeighborDist := Round(IOStream.ReadSingle * 100);
Tolerance := IOStream.ReadInteger;
FadeSpeed := Round(IOStream.ReadSingle * 100);
NeighborWeight:= IOStream.ReadInteger;
end
end;
procedure RBkgColorParams.WriteToStream(IOStream: TCubicBuffStream);
begin
IOStream.WriteInteger (CurrentVersion);
IOStream.WriteInteger (Color);
IOStream.WriteByte (Ord(FillType));
IOStream.WriteByte (Ord(EffectShape));
IOStream.WriteByte (Ord(EffectColor));
IOStream.WriteByte (EdgeSmear);
IOStream.WriteInteger (NeighborDist);
IOStream.WriteInteger (Tolerance);
IOStream.WriteInteger (FadeSpeed);
IOStream.WriteInteger (NeighborWeight);
IOStream.WritePadding(64);
end;
end.