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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
|
//
// Copyright 2002 Ximian, Inc. http://www.ximian.com
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//
// Authors:
// Jordi Mas i Hernandez (jordi@ximian.com)
//
// Partially based on work by:
//
// Everaldo Canuto (everaldo.canuto@bol.com.br)
// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
// Dennis Hayes (dennish@raytek.com)
//
using System;
using System.Runtime.InteropServices;
namespace System.Drawing.Imaging
{
#if TARGET_JVM
[MonoTODO]
#endif
[StructLayout (LayoutKind.Sequential)]
public sealed class ColorMatrix
{
private float color00;
private float color01;
private float color02;
private float color03;
private float color04;
private float color10;
private float color11;
private float color12;
private float color13;
private float color14;
private float color20;
private float color21;
private float color22;
private float color23;
private float color24;
private float color30;
private float color31;
private float color32;
private float color33;
private float color34;
private float color40;
private float color41;
private float color42;
private float color43;
private float color44;
// constructors
public ColorMatrix ()
{
color01 = color02 = color03 = color04 = 0;
color10 = color12 = color13 = color14 = 0;
color20 = color21 = color23 = color24 = 0;
color30 = color31 = color32 = color34 = 0;
color40 = color41 = color42 = color43 = 0;
color00 = color11 = color22 = color33 = color44 = 1;
}
[CLSCompliant(false)]
public ColorMatrix (float[][] matrix)
{
color00 = matrix [0][0];
color01 = matrix [0][1];
color02 = matrix [0][2];
color03 = matrix [0][3];
color04 = matrix [0][4];
color10 = matrix [1][0];
color11 = matrix [1][1];
color12 = matrix [1][2];
color13 = matrix [1][3];
color14 = matrix [1][4];
color20 = matrix [2][0];
color21 = matrix [2][1];
color22 = matrix [2][2];
color23 = matrix [2][3];
color24 = matrix [2][4];
color30 = matrix [3][0];
color31 = matrix [3][1];
color32 = matrix [3][2];
color33 = matrix [3][3];
color34 = matrix [3][4];
color40 = matrix [4][0];
color41 = matrix [4][1];
color42 = matrix [4][2];
color43 = matrix [4][3];
color44 = matrix [4][4];
}
// properties
public float this[int row, int column] {
get {
switch (row) {
case 0: {
switch (column) {
case 0: return color00;
case 1: return color01;
case 2: return color02;
case 3: return color03;
case 4: return color04;
default: break;
}
break;
}
case 1: {
switch (column) {
case 0: return color10;
case 1: return color11;
case 2: return color12;
case 3: return color13;
case 4: return color14;
default: break;
}
break;
}
case 2: {
switch (column) {
case 0: return color20;
case 1: return color21;
case 2: return color22;
case 3: return color23;
case 4: return color24;
default: break;
}
break;
}
case 3: {
switch (column) {
case 0: return color30;
case 1: return color31;
case 2: return color32;
case 3: return color33;
case 4: return color34;
default: break;
}
break;
}
case 4: {
switch (column) {
case 0: return color40;
case 1: return color41;
case 2: return color42;
case 3: return color43;
case 4: return color44;
default: break;
}
break;
}
default:
break;
}
throw new IndexOutOfRangeException ("Index was outside the bounds of the array");
}
set {
switch (row) {
case 0: {
switch (column) {
case 0: color00 = value; return;
case 1: color01 = value; return;
case 2: color02 = value; return;
case 3: color03 = value; return;
case 4: color04 = value; return;
default: break;
}
break;
}
case 1: {
switch (column) {
case 0: color10 = value; return;
case 1: color11 = value; return;
case 2: color12 = value; return;
case 3: color13 = value; return;
case 4: color14 = value; return;
default: break;
}
break;
}
case 2: {
switch (column) {
case 0: color20 = value; return;
case 1: color21 = value; return;
case 2: color22 = value; return;
case 3: color23 = value; return;
case 4: color24 = value; return;
default: break;
}
break;
}
case 3: {
switch (column) {
case 0: color30 = value; return;
case 1: color31 = value; return;
case 2: color32 = value; return;
case 3: color33 = value; return;
case 4: color34 = value; return;
default: break;
}
break;
}
case 4: {
switch (column) {
case 0: color40 = value; return;
case 1: color41 = value; return;
case 2: color42 = value; return;
case 3: color43 = value; return;
case 4: color44 = value; return;
default: break;
}
break;
}
default:
break;
}
throw new IndexOutOfRangeException ("Index was outside the bounds of the array");
}
}
public float Matrix00 {
get { return color00; }
set { color00 = value; }
}
public float Matrix01 {
get { return color01; }
set { color01 = value; }
}
public float Matrix02 {
get { return color02; }
set { color02 = value; }
}
public float Matrix03 {
get { return color03; }
set { color03 = value; }
}
public float Matrix04 {
get { return color04; }
set { color04 = value; }
}
public float Matrix10 {
get { return color10; }
set { color10 = value; }
}
public float Matrix11 {
get { return color11; }
set { color11 = value; }
}
public float Matrix12 {
get { return color12; }
set { color12 = value; }
}
public float Matrix13 {
get { return color13; }
set { color13 = value; }
}
public float Matrix14 {
get { return color14; }
set { color14 = value; }
}
public float Matrix20 {
get { return color20; }
set { color20 = value; }
}
public float Matrix21 {
get { return color21; }
set { color21 = value; }
}
public float Matrix22 {
get { return color22; }
set { color22 = value; }
}
public float Matrix23 {
get { return color23; }
set { color23 = value; }
}
public float Matrix24 {
get { return color24; }
set { color24 = value; }
}
public float Matrix30 {
get { return color30; }
set { color30 = value; }
}
public float Matrix31 {
get { return color31; }
set { color31 = value; }
}
public float Matrix32 {
get { return color32; }
set { color32 = value; }
}
public float Matrix33 {
get { return color33; }
set { color33 = value; }
}
public float Matrix34 {
get { return color34; }
set { color34 = value; }
}
public float Matrix40 {
get { return color40; }
set { color40 = value; }
}
public float Matrix41 {
get { return color41; }
set { color41 = value; }
}
public float Matrix42 {
get { return color42; }
set { color42 = value; }
}
public float Matrix43 {
get { return color43; }
set { color43 = value; }
}
public float Matrix44 {
get { return color44; }
set { color44 = value; }
}
}
}
|