**** Merged from MCS ****
[mono-project.git] / mcs / class / System.Drawing / System.Drawing.Imaging / ColorMatrix.cs
blob3d706903455051daca3a4ca32ab1e46750295b4c
1 //
2 // System.Drawing.Imaging.ColorMatrix.cs
3 //
4 // Authors:
5 // Everaldo Canuto (everaldo.canuto@bol.com.br)
6 // Andreas Nahr (ClassDevelopment@A-SoftTech.com)
7 // Dennis Hayes (dennish@raytek.com)
8 //
9 // (C) 2002 Ximian, Inc. http://www.ximian.com
13 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
15 // Permission is hereby granted, free of charge, to any person obtaining
16 // a copy of this software and associated documentation files (the
17 // "Software"), to deal in the Software without restriction, including
18 // without limitation the rights to use, copy, modify, merge, publish,
19 // distribute, sublicense, and/or sell copies of the Software, and to
20 // permit persons to whom the Software is furnished to do so, subject to
21 // the following conditions:
22 //
23 // The above copyright notice and this permission notice shall be
24 // included in all copies or substantial portions of the Software.
25 //
26 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
30 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
31 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
32 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 using System;
37 namespace System.Drawing.Imaging {
39 public sealed class ColorMatrix {
41 private float[] colors;
43 // constructors
44 public ColorMatrix()
46 colors = new float[25];
47 // Set identity matrix by default
48 colors[0] = 1;
49 colors[6] = 1;
50 colors[12] = 1;
51 colors[18] = 1;
52 colors[24] = 1;
55 [CLSCompliant(false)]
56 public ColorMatrix(float[][] newColorMatrix)
58 colors = new float[25];
59 for (int x = 0; x < 5; x++) {
60 for (int y = 0; y < 5; y++) {
61 colors[x * 5 + y] = newColorMatrix[x][y];
66 // properties
67 public float this[int row, int column] {
68 get { return colors[row * 5 + column]; }
69 set { colors[row * 5 + column] = value; }
73 public float Matrix00 {
74 get { return colors[0]; }
75 set { colors[0] = value; }
78 public float Matrix01 {
79 get { return colors[1]; }
80 set { colors[1] = value; }
83 public float Matrix02 {
84 get { return colors[2]; }
85 set { colors[2] = value; }
88 public float Matrix03 {
89 get { return colors[3]; }
90 set { colors[3] = value; }
93 public float Matrix04 {
94 get { return colors[4]; }
95 set { colors[4] = value; }
99 public float Matrix10 {
100 get { return colors[5]; }
101 set { colors[5] = value; }
104 public float Matrix11 {
105 get { return colors[6]; }
106 set { colors[6] = value; }
109 public float Matrix12 {
110 get { return colors[7]; }
111 set { colors[7] = value; }
114 public float Matrix13 {
115 get { return colors[8]; }
116 set { colors[8] = value; }
119 public float Matrix14 {
120 get { return colors[9]; }
121 set { colors[9] = value; }
125 public float Matrix20 {
126 get { return colors[10]; }
127 set { colors[10] = value; }
130 public float Matrix21 {
131 get { return colors[11]; }
132 set { colors[11] = value; }
135 public float Matrix22 {
136 get { return colors[12]; }
137 set { colors[12] = value; }
140 public float Matrix23 {
141 get { return colors[13]; }
142 set { colors[13] = value; }
145 public float Matrix24 {
146 get { return colors[14]; }
147 set { colors[14] = value; }
151 public float Matrix30 {
152 get { return colors[15]; }
153 set { colors[15] = value; }
156 public float Matrix31 {
157 get { return colors[16]; }
158 set { colors[16] = value; }
161 public float Matrix32 {
162 get { return colors[17]; }
163 set { colors[17] = value; }
166 public float Matrix33 {
167 get { return colors[18]; }
168 set { colors[18] = value; }
171 public float Matrix34 {
172 get { return colors[19]; }
173 set { colors[19] = value; }
177 public float Matrix40 {
178 get { return colors[20]; }
179 set { colors[20] = value; }
182 public float Matrix41 {
183 get { return colors[21]; }
184 set { colors[21] = value; }
187 public float Matrix42 {
188 get { return colors[22]; }
189 set { colors[22] = value; }
192 public float Matrix43 {
193 get { return colors[23]; }
194 set { colors[23] = value; }
197 public float Matrix44 {
198 get { return colors[24]; }
199 set { colors[24] = value; }