forked from amix/photoshop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tables.p
231 lines (168 loc) · 4.36 KB
/
Tables.p
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
{Photoshop version 1.0.1, file: Tables.p
Computer History Museum, www.computerhistory.org
This material is (C)Copyright 1990 Adobe Systems Inc.
It may not be distributed to third parties.
It is licensed for non-commercial use according to
www.computerhistory.org/softwarelicense/photoshop/ }
PROGRAM Tables;
USES
MemTypes, QuickDraw, PickerIntf;
TYPE
TLookUpTable = PACKED ARRAY [0..255] OF CHAR;
TRGBLookUpTable = RECORD R, G, B: TLookUpTable END;
{*****************************************************************************}
PROCEDURE WritePLUT (table: TRGBLookUpTable; id: INTEGER; name: Str255);
VAR
row: INTEGER;
col: INTEGER;
gray: INTEGER;
color: INTEGER;
BEGIN
WRITELN;
WRITELN ('resource ''PLUT'' (', id:1, ', "', name, '", purgeable)');
WRITELN (' {');
WRITELN (' {');
FOR color := 0 TO 2 DO
FOR row := 0 TO 15 DO
BEGIN
WRITE (' ');
FOR col := 0 TO 15 DO
BEGIN
CASE color OF
0: gray := ORD (table.R [row * 16 + col]);
1: gray := ORD (table.G [row * 16 + col]);
2: gray := ORD (table.B [row * 16 + col])
END;
WRITE (gray:3);
IF (row <> 15) OR (col <> 15) OR (color <> 2) THEN
WRITE (';')
END;
WRITELN
END;
WRITELN (' }');
WRITELN (' };')
END;
{*****************************************************************************}
PROCEDURE MakeBlackBody (VAR table: TRGBLookUpTable);
VAR
gray: INTEGER;
BEGIN
FOR gray := 0 TO 255 DO
CASE gray OF
0..85:
BEGIN
table.R [gray] := CHR (3 * gray);
table.G [gray] := CHR (0);
table.B [gray] := CHR (0)
END;
86..170:
BEGIN
table.R [gray] := CHR (255);
table.G [gray] := CHR (3 * (gray - 85));
table.B [gray] := CHR (0)
END;
171..255:
BEGIN
table.R [gray] := CHR (255);
table.G [gray] := CHR (255);
table.B [gray] := CHR (3 * (gray - 170))
END
END
END;
{*****************************************************************************}
PROCEDURE MakeMonochrome (VAR table: TRGBLookUpTable);
VAR
gray: INTEGER;
BEGIN
FOR gray := 0 TO 255 DO
BEGIN
table.R [gray] := CHR (gray);
table.G [gray] := CHR (gray);
table.B [gray] := CHR (gray)
END
END;
{*****************************************************************************}
PROCEDURE MakeSpectrum (VAR table: TRGBLookUpTable);
VAR
gray: INTEGER;
rColor: RGBColor;
hColor: HSVColor;
BEGIN
FOR gray := 0 TO 255 DO
BEGIN
hColor.hue := ORD4 (255 - gray) * 54613 DIV 255;
hColor.saturation := $FFFF;
hColor.value := $FFFF;
HSV2RGB (hColor, rColor);
table.R [gray] := CHR (BAND (BSR (rColor.red , 8), $FF));
table.G [gray] := CHR (BAND (BSR (rColor.green, 8), $FF));
table.B [gray] := CHR (BAND (BSR (rColor.blue , 8), $FF))
END
END;
{*****************************************************************************}
PROCEDURE MakeSystem (VAR table: TRGBLookUpTable);
VAR
x: INTEGER;
gray: INTEGER;
band: INTEGER;
slot: INTEGER;
r, g, b: INTEGER;
BEGIN
gray := 0;
FOR r := 5 DOWNTO 0 DO
FOR g := 5 DOWNTO 0 DO
FOR b := 5 DOWNTO 0 DO
IF gray <> 215 THEN
BEGIN
table.R [gray] := CHR (r * $33);
table.G [gray] := CHR (g * $33);
table.B [gray] := CHR (b * $33);
gray := gray + 1
END;
FOR band := 1 TO 4 DO
FOR slot := 1 TO 10 DO
BEGIN
r := ORD ((band = 1) OR (band = 4));
g := ORD ((band = 2) OR (band = 4));
b := ORD ((band = 3) OR (band = 4));
CASE slot OF
1: x := $EE;
2: x := $DD;
3: x := $BB;
4: x := $AA;
5: x := $88;
6: x := $77;
7: x := $55;
8: x := $44;
9: x := $22;
10: x := $11
END;
table.R [gray] := CHR (r * x);
table.G [gray] := CHR (g * x);
table.B [gray] := CHR (b * x);
gray := gray + 1
END;
table.R [255] := CHR (0);
table.G [255] := CHR (0);
table.B [255] := CHR (0)
END;
{*****************************************************************************}
VAR
table: TRGBLookUpTable;
BEGIN
WRITELN ('type ''PLUT''' );
WRITELN (' {' );
WRITELN (' wide array [768]' );
WRITELN (' {' );
WRITELN (' unsigned byte;' );
WRITELN (' };' );
WRITELN (' };' );
MakeSystem (table);
WritePLUT (table, 1000, '.System');
MakeBlackBody (table);
WritePLUT (table, 1001, 'Blackbody');
MakeMonochrome (table);
WritePLUT (table, 1002, 'Gray Scale');
MakeSpectrum (table);
WritePLUT (table, 1003, 'Spectrum')
END.