ColorMatrix.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. //
  2. // System.Drawing.Imaging.ColorMatrix.cs
  3. //
  4. // Authors:
  5. // Everaldo Canuto ([email protected])
  6. // Andreas Nahr ([email protected])
  7. // Dennis Hayes ([email protected])
  8. //
  9. // (C) 2002 Ximian, Inc. http://www.ximian.com
  10. //
  11. using System;
  12. namespace System.Drawing.Imaging {
  13. public sealed class ColorMatrix {
  14. float[] colors;
  15. // constructors
  16. public ColorMatrix()
  17. {
  18. colors = new float[25];
  19. // Set identity matrix by default
  20. colors[0] = 1;
  21. colors[6] = 1;
  22. colors[12] = 1;
  23. colors[18] = 1;
  24. colors[24] = 1;
  25. }
  26. [CLSCompliant(false)]
  27. public ColorMatrix(float[][] newColorMatrix)
  28. {
  29. colors = new float[25];
  30. for (int x = 0; x < 5; x++) {
  31. for (int y = 0; y < 5; y++) {
  32. colors[x * 5 + y] = newColorMatrix[x][y];
  33. }
  34. }
  35. }
  36. // properties
  37. public float this[int row, int column] {
  38. get { return colors[row * 5 + column]; }
  39. set { colors[row * 5 + column] = value; }
  40. }
  41. public float Matrix00 {
  42. get { return colors[0]; }
  43. set { colors[0] = value; }
  44. }
  45. public float Matrix01 {
  46. get { return colors[1]; }
  47. set { colors[1] = value; }
  48. }
  49. public float Matrix02 {
  50. get { return colors[2]; }
  51. set { colors[2] = value; }
  52. }
  53. public float Matrix03 {
  54. get { return colors[3]; }
  55. set { colors[3] = value; }
  56. }
  57. public float Matrix04 {
  58. get { return colors[4]; }
  59. set { colors[4] = value; }
  60. }
  61. public float Matrix10 {
  62. get { return colors[5]; }
  63. set { colors[5] = value; }
  64. }
  65. public float Matrix11 {
  66. get { return colors[6]; }
  67. set { colors[6] = value; }
  68. }
  69. public float Matrix12 {
  70. get { return colors[7]; }
  71. set { colors[7] = value; }
  72. }
  73. public float Matrix13 {
  74. get { return colors[8]; }
  75. set { colors[8] = value; }
  76. }
  77. public float Matrix14 {
  78. get { return colors[9]; }
  79. set { colors[9] = value; }
  80. }
  81. public float Matrix20 {
  82. get { return colors[10]; }
  83. set { colors[10] = value; }
  84. }
  85. public float Matrix21 {
  86. get { return colors[11]; }
  87. set { colors[11] = value; }
  88. }
  89. public float Matrix22 {
  90. get { return colors[12]; }
  91. set { colors[12] = value; }
  92. }
  93. public float Matrix23 {
  94. get { return colors[13]; }
  95. set { colors[13] = value; }
  96. }
  97. public float Matrix24 {
  98. get { return colors[14]; }
  99. set { colors[14] = value; }
  100. }
  101. public float Matrix30 {
  102. get { return colors[15]; }
  103. set { colors[15] = value; }
  104. }
  105. public float Matrix31 {
  106. get { return colors[16]; }
  107. set { colors[16] = value; }
  108. }
  109. public float Matrix32 {
  110. get { return colors[17]; }
  111. set { colors[17] = value; }
  112. }
  113. public float Matrix33 {
  114. get { return colors[18]; }
  115. set { colors[18] = value; }
  116. }
  117. public float Matrix34 {
  118. get { return colors[19]; }
  119. set { colors[19] = value; }
  120. }
  121. public float Matrix40 {
  122. get { return colors[20]; }
  123. set { colors[20] = value; }
  124. }
  125. public float Matrix41 {
  126. get { return colors[21]; }
  127. set { colors[21] = value; }
  128. }
  129. public float Matrix42 {
  130. get { return colors[22]; }
  131. set { colors[22] = value; }
  132. }
  133. public float Matrix43 {
  134. get { return colors[23]; }
  135. set { colors[23] = value; }
  136. }
  137. public float Matrix44 {
  138. get { return colors[24]; }
  139. set { colors[24] = value; }
  140. }
  141. }
  142. }