-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathViewerALFs.pas
132 lines (98 loc) · 3.25 KB
/
ViewerALFs.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
122
123
124
125
126
127
128
129
130
131
132
unit ViewerALFs;
interface //#################################################################### ■
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
LUX,
LUX.NALFs;
type //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【 T Y P E 】
TViewerALFsFrame = class( TFrame )
private
protected
_BMP :TBitmap;
_NALFs :TNALFs; upNALFs:Boolean;
///// A C C E S S O R
procedure OnUpALFs( Sender:TObject );
function GetALFs :TNALFs;
procedure SetALFs( const ALFs_:TNALFs );
///// M E T H O D
procedure Paint; override;
procedure DrawNALFs;
public
constructor Create( Owner_:TComponent ); override;
destructor Destroy; override;
///// P R O P E R T Y
property NALFs :TNALFs read GetALFs write SetALFs;
end;
implementation //############################################################### ■
{$R *.fmx}
uses System.Math, System.Threading,
LUX.D2, LUX.Color;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TViewerALFsFrame
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& protected
//////////////////////////////////////////////////////////////// A C C E S S O R
procedure TViewerALFsFrame.OnUpALFs( Sender:TObject );
begin
upNALFs := True; Repaint;
end;
function TViewerALFsFrame.GetALFs :TNALFs;
begin
Result := _NALFs;
end;
procedure TViewerALFsFrame.SetALFs( const ALFs_:TNALFs );
begin
if Assigned( _NALFs ) then _NALFs.OnChange.Del( OnUpALFs );
_NALFs := ALFs_;
if Assigned( _NALFs ) then _NALFs.OnChange.Add( OnUpALFs );
OnUpALFs( Self );
end;
//////////////////////////////////////////////////////////////////// M E T H O D
procedure TViewerALFsFrame.Paint;
begin
inherited;
if not Assigned( _NALFs ) then Exit;
if upNALFs then
begin
upNALFs := False;
DrawNALFs;
end;
Canvas.DrawBitmap( _BMP, TRectF.Create( 0, 0, _BMP.Width, _BMP.Height ), LocalRect, 1, True );
end;
//------------------------------------------------------------------------------
procedure TViewerALFsFrame.DrawNALFs;
var
D :TBitmapData;
begin
_BMP.SetSize( NALFs.DegN+1, NALFs.DegN+1 );
_BMP.Map( TMapAccess.Write, D );
NALFs[ 0, 0 ]; // 遅延評価を実行
TParallel.For( 0, NALFs.DegN, procedure ( N:Integer )
var
P :PAlphaColor;
M :Integer;
C :TAlphaColorF;
begin
P := D.GetScanline( N );
for M := 0 to N do
begin
C.R := Clamp( 0.5 + NALFs[ N, M ] / 4, 0, 1 );
C.G := C.R;
C.B := C.R;
C.A := 1;
P^ := C.ToAlphaColor; Inc( P );
end;
end );
_BMP.Unmap( D );
end;
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& public
constructor TViewerALFsFrame.Create( Owner_:TComponent );
begin
inherited;
_BMP := TBitmap.Create;
end;
destructor TViewerALFsFrame.Destroy;
begin
_BMP.Free;
inherited;
end;
end. //######################################################################### ■