-
Notifications
You must be signed in to change notification settings - Fork 24
/
lut.pas
executable file
·118 lines (109 loc) · 3.1 KB
/
lut.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
unit lut;
interface
uses define_types, sysutils, dialogs, clut;
{$D-,L-,O+,Q-,R-,Y-,S-}
const
knAutoLUT = 7;
procedure LUTdropLoad( lLUTindex: integer; var lLUT: TLUT; lLUTname: string; var lCLUTrec: TCLUTrec);
//procedure LoadColorScheme(lStr: string; var lLUT: TLUT);
implementation
function SetAlpha(lIndex: byte): byte;
begin
result := lindex shr 4;
end;
procedure LinearMinMaxCLUTrec(lMin,lMax: TGLRGBQuad; var lNodeRA: TCLUTrec);
//creates linear RGBA values from minimum to maximum
begin
lNodeRA.nodes[0].intensity := 0;
lNodeRA.nodes[0].rgba := lMin;
lNodeRA.nodes[1].intensity := 255;
lNodeRA.nodes[1].rgba := lMax;
lNodeRA.numnodes := 2;
end;
procedure LoadMonochromeLUT (var lLUTindex: integer; var lLUT: TLUT; var lCLUTrec: TCLUTrec); //lLUT: 0=gray,1=red,2=green,3=blue
var
//lR,lG,lB,
lInc: integer;
begin
case lLUTindex of
1:
for lInc := 0 to 255 do begin
lLUT[lInc].rgbRed := lInc;
lLUT[lInc].rgbGreen := 0;
lLUT[lInc].rgbBlue := 0;
lLUT[lInc].rgbReserved := SetAlpha(lInc);
end;//red
2:
for lInc := 0 to 255 do begin
lLUT[lInc].rgbRed := 0;
lLUT[lInc].rgbGreen := lInc;
lLUT[lInc].rgbBlue := 0;
lLUT[lInc].rgbReserved := SetAlpha(lInc);
end;//green
3:
for lInc := 0 to 255 do begin
lLUT[lInc].rgbRed := 0;
lLUT[lInc].rgbGreen := 0;
lLUT[lInc].rgbBlue := lInc;
lLUT[lInc].rgbReserved := SetAlpha(lInc);
end;//blue
4:
for lInc := 0 to 255 do begin
lLUT[lInc].rgbRed := lInc;
lLUT[lInc].rgbGreen := 0;
lLUT[lInc].rgbBlue := lInc;
lLUT[lInc].rgbReserved := SetAlpha(lInc);
end;//r+b=violet
5:
for lInc := 0 to 255 do begin
lLUT[lInc].rgbRed := lInc;
lLUT[lInc].rgbGreen := lInc;
lLUT[lInc].rgbBlue := 0;
lLUT[lInc].rgbReserved := SetAlpha(lInc);
end;//red + green = yellow
6:
for lInc := 0 to 255 do begin
lLUT[lInc].rgbRed := 0;
lLUT[lInc].rgbGreen := lInc;
lLUT[lInc].rgbBlue := lINc;
lLUT[lInc].rgbReserved := SetAlpha(lInc);
end;//green+blue = cyan
else begin
for lInc := 0 to 255 do begin
lLUT[lInc].rgbRed := lInc;
lLUT[lInc].rgbGreen := lInc;
lLUT[lInc].rgbBlue := lInc;
lLUT[lInc].rgbReserved := SetAlpha(lInc);
end;//for gray
end//else... gray
end;
LinearMinMaxCLUTrec(lLUT[0],lLUT[255],lCLUTrec);
end;
procedure LUTdropLoad(lLUTindex: integer; var lLUT: TLUT; lLUTname: string; var lCLUTrec: TCLUTrec);
var
lStr: string;
begin
if lLUTindex < knAutoLUT then begin
LoadMonochromeLUT(lLUTindex,lLUT,lCLUTrec);
exit;
end;
lStr := ClutDir+pathdelim+lLUTname+'.clut';
if not FileExistsEX(lStr) then begin
showmessage('Can not find '+lStr);
exit;
end;
CLUT2TLUT(lStr,lLUT,lCLUTrec);
(*lStr := ClutDir+pathdelim+lLUTname+'.lut';
if not FileExistsEX(lStr) then begin
showmessage('Can not find '+lStr);
exit;
end;
LoadColorScheme(lStr, lLUT); *)
end;
(*begin
if lLUTindex < knAutoLUT then begin
LoadMonochromeLUT(lLUTindex,lLUT,lCLUTrec);
exit;
end; //if B&W lut
end; *)
end.