using System.Drawing.Imaging;
namespace Developpez.Dotnet.Drawing
{
///
/// Fournit des matrices de transformation de couleurs courantes
///
public static class ColorTransforms
{
private static readonly ColorMatrix _grayScale;
private static readonly ColorMatrix _negative;
private static readonly ColorMatrix _sepia;
static ColorTransforms()
{
_grayScale = new ColorMatrix(
new float[][]
{
new float[] { .3f, .3f, .3f, 0, 0 },
new float[] { .59f, .59f, .59f, 0, 0 },
new float[] { .11f, .11f, .11f, 0, 0 },
new float[] { 0, 0, 0, 1, 0 },
new float[] { 0, 0, 0, 0, 1 }
});
_negative = new ColorMatrix(
new float[][]
{
new float[] { -1, 0, 0, 0, 0 },
new float[] { 0, -1, 0, 0, 0 },
new float[] { 0, 0, -1, 0, 0 },
new float[] { 0, 0, 0, 1, 0 },
new float[] { 1, 1, 1, 0, 1 },
});
_sepia = new ColorMatrix(
new float[][]
{
new float[] { 0.393f, 0.349f, 0.272f, 0, 0 },
new float[] { 0.769f, 0.686f, 0.534f, 0, 0 },
new float[] { 0.189f, 0.168f, 0.131f, 0, 0 },
new float[] { 0, 0, 0, 1, 0 },
new float[] { 0, 0, 0, 0, 1 }
});
}
///
/// Transformation en niveau de gris
///
public static ColorMatrix GrayScale
{
get { return _grayScale; }
}
///
/// Transformation en négatif
///
public static ColorMatrix Negative
{
get { return _negative; }
}
///
/// Transformation sépia
///
public static ColorMatrix Sepia
{
get { return _sepia; }
}
}
}