diff --git a/Source/OpenTK/Graphics/ColorFormat.cs b/Source/OpenTK/Graphics/ColorFormat.cs
index 583109e3..48516503 100644
--- a/Source/OpenTK/Graphics/ColorFormat.cs
+++ b/Source/OpenTK/Graphics/ColorFormat.cs
@@ -1,9 +1,28 @@
-#region --- License ---
-/* Licensed under the MIT/X11 license.
- * Copyright (c) 2006-2008 the OpenTK Team.
- * This notice may not be removed from any source distribution.
- * See license.txt for licensing detailed licensing details.
- */
+#region License
+//
+// The Open Toolkit Library License
+//
+// Copyright (c) 2006 - 2010 the Open Toolkit library.
+//
+// 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.
+//
#endregion
using System;
@@ -17,13 +36,13 @@ namespace OpenTK.Graphics
/// A ColorFormat contains Red, Green, Blue and Alpha components that descibe
/// the allocated bits per pixel for the corresponding color.
///
- public struct ColorFormat
+ public struct ColorFormat : IComparable
{
byte red, green, blue, alpha;
bool isIndexed;
int bitsPerPixel;
- #region --- Constructors ---
+ #region Constructors
///
/// Constructs a new ColorFormat with the specified aggregate bits per pixel.
@@ -96,7 +115,7 @@ namespace OpenTK.Graphics
#endregion
- #region --- Public Methods ---
+ #region Public Members
/// Gets the bits per pixel for the Red channel.
public int Red { get { return red; } private set { red = (byte)value; } }
@@ -111,9 +130,11 @@ namespace OpenTK.Graphics
/// Gets the sum of Red, Green, Blue and Alpha bits per pixel.
public int BitsPerPixel { get { return bitsPerPixel; } private set { bitsPerPixel = value; } }
+ public static readonly ColorFormat Empty = new ColorFormat(0);
+
#endregion
- #region --- Operator Overloads ---
+ #region Operator Overloads
///
/// Converts the specified bpp into a new ColorFormat.
@@ -132,7 +153,32 @@ namespace OpenTK.Graphics
#endregion
- #region --- Overrides ---
+ #region IComparable Members
+
+ ///
+ /// Compares two instances.
+ ///
+ /// The other instance.
+ ///
+ /// Zero if this instance is equal to other;
+ /// a positive value if this instance is greater than other;
+ /// a negative value otherwise.
+ ///
+ public int CompareTo(ColorFormat other)
+ {
+ int result = BitsPerPixel.CompareTo(other.BitsPerPixel);
+ if (result != 0)
+ return result;
+ result = IsIndexed.CompareTo(other.IsIndexed);
+ if (result != 0)
+ return result;
+ result = Alpha.CompareTo(other.Alpha);
+ return result;
+ }
+
+ #endregion
+
+ #region Overrides
///
/// Indicates whether this instance and a specified object are equal.
@@ -176,6 +222,50 @@ namespace OpenTK.Graphics
return !(left == right);
}
+ ///
+ /// Compares two instances for inequality.
+ ///
+ /// The left operand.
+ /// The right operand.
+ /// True if left is greater than right; false otherwise.
+ public static bool operator >(ColorFormat left, ColorFormat right)
+ {
+ return left.CompareTo(right) > 0;
+ }
+
+ ///
+ /// Compares two instances for inequality.
+ ///
+ /// The left operand.
+ /// The right operand.
+ /// True if left is greater than or equal to right; false otherwise.
+ public static bool operator >=(ColorFormat left, ColorFormat right)
+ {
+ return left.CompareTo(right) >= 0;
+ }
+
+ ///
+ /// Compares two instances for inequality.
+ ///
+ /// The left operand.
+ /// The right operand.
+ /// True if left is less than right; false otherwise.
+ public static bool operator <(ColorFormat left, ColorFormat right)
+ {
+ return left.CompareTo(right) < 0;
+ }
+
+ ///
+ /// Compares two instances for inequality.
+ ///
+ /// The left operand.
+ /// The right operand.
+ /// True if left is less than or equal to right; false otherwise.
+ public static bool operator <=(ColorFormat left, ColorFormat right)
+ {
+ return left.CompareTo(right) <= 0;
+ }
+
///
/// Returns the hash code for this instance.
///