@ -10,10 +10,7 @@
namespace ImageProcessor.Imaging.Filters
{
#region Using
using System.Diagnostics.CodeAnalysis ;
using System.Drawing.Imaging ;
#endregion
/// <summary>
/// A list of available color matrices to apply to an image.
@ -21,24 +18,56 @@ namespace ImageProcessor.Imaging.Filters
internal static class ColorMatrixes
{
/// <summary>
/// Gets the <see cref="T:System.Drawing.Imaging.ColorMatrix"/> for generating the sepia filter.
/// The <see cref="T:System.Drawing.Imaging.ColorMatrix"/> for generating the black and white filter.
/// </summary>
internal static ColorMatrix Sepia
{
get
{
return
new ColorMatrix (
new [ ]
{
new [ ] { . 3 9 3f , . 3 4 9f , . 2 7 2f , 0 , 0 } ,
new [ ] { . 7 6 9f , . 6 8 6f , . 5 3 4f , 0 , 0 } ,
new [ ] { . 1 8 9f , . 1 6 8f , . 1 3 1f , 0 , 0 } ,
new float [ ] { 0 , 0 , 0 , 1 , 0 } ,
new float [ ] { 0 , 0 , 0 , 0 , 1 }
} ) ;
}
}
private static ColorMatrix blackWhite ;
/// <summary>
/// Gets the <see cref="T:System.Drawing.Imaging.ColorMatrix"/> for generating the high pass
/// on the comic book filter.
/// </summary>
private static ColorMatrix comicHigh ;
/// <summary>
/// Gets <see cref="T:System.Drawing.Imaging.ColorMatrix"/> for generating the low pass
/// on the comic book filter.
/// </summary>
private static ColorMatrix comicLow ;
/// <summary>
/// The <see cref="T:System.Drawing.Imaging.ColorMatrix"/> for generating the greyscale filter.
/// </summary>
private static ColorMatrix greyScale ;
/// <summary>
/// The <see cref="T:System.Drawing.Imaging.ColorMatrix"/> for generating the high saturation filter.
/// </summary>
private static ColorMatrix hiSatch ;
/// <summary>
/// The <see cref="T:System.Drawing.Imaging.ColorMatrix"/> for generating the invert filter.
/// </summary>
private static ColorMatrix invert ;
/// <summary>
/// The <see cref="T:System.Drawing.Imaging.ColorMatrix"/> for generating the lomograph filter.
/// </summary>
private static ColorMatrix lomograph ;
/// <summary>
/// The <see cref="T:System.Drawing.Imaging.ColorMatrix"/> for generating the low saturation filter.
/// </summary>
private static ColorMatrix loSatch ;
/// <summary>
/// The <see cref="T:System.Drawing.Imaging.ColorMatrix"/> for generating the polaroid filter.
/// </summary>
private static ColorMatrix polaroid ;
/// <summary>
/// The <see cref="T:System.Drawing.Imaging.ColorMatrix"/> for generating the sepia filter.
/// </summary>
private static ColorMatrix sepia ;
/// <summary>
/// Gets the <see cref="T:System.Drawing.Imaging.ColorMatrix"/> for generating the black and white filter.
@ -47,7 +76,7 @@ namespace ImageProcessor.Imaging.Filters
{
get
{
return new ColorMatrix (
return blackWhite ? ? ( blackWhite = new ColorMatrix (
new [ ]
{
new [ ] { 1.5f , 1.5f , 1.5f , 0 , 0 } ,
@ -55,45 +84,47 @@ namespace ImageProcessor.Imaging.Filters
new [ ] { 1.5f , 1.5f , 1.5f , 0 , 0 } ,
new float [ ] { 0 , 0 , 0 , 1 , 0 } ,
new float [ ] { - 1 , - 1 , - 1 , 0 , 1 }
} ) ;
} ) ) ;
}
}
/// <summary>
/// Gets the <see cref="T:System.Drawing.Imaging.ColorMatrix"/> for generating the polaroid filter.
/// Gets the <see cref="T:System.Drawing.Imaging.ColorMatrix"/> for generating the high pass
/// on the comic book filter.
/// </summary>
internal static ColorMatrix Polaroid
internal static ColorMatrix ComicHigh
{
get
{
return new ColorMatrix (
return comicHigh ? ? ( comicHigh = new ColorMatrix (
new [ ]
{
new [ ] { 1.638f , - 0.062f , - 0.262 f, 0 , 0 } ,
new [ ] { - 0.122f , 1.378f , - 0.122 f , 0 , 0 } ,
new [ ] { 1.016f , - 0.016f , 1.383f , 0 , 0 } ,
new [ ] { 2 , - 0.5f , - 0.5 f, 0 , 0 } ,
new [ ] { - 0.5f , 2 , - 0.5 f , 0 , 0 } ,
new [ ] { - 0.5f , - 0.5f , 2 , 0 , 0 } ,
new float [ ] { 0 , 0 , 0 , 1 , 0 } ,
new [ ] { 0.06f , - 0.05f , - 0.05f , 0 , 1 }
} ) ;
new float [ ] { 0 , 0 , 0 , 0 , 1 }
} ) ) ;
}
}
/// <summary>
/// Gets the <see cref="T:System.Drawing.Imaging.ColorMatrix"/> for generating the lomograph filter.
/// Gets <see cref="T:System.Drawing.Imaging.ColorMatrix"/> for generating the low pass
/// on the comic book filter.
/// </summary>
internal static ColorMatrix Lomograph
internal static ColorMatrix ComicLow
{
get
{
return new ColorMatrix (
new [ ]
return comicLow ? ? ( comicLow = new ColorMatrix (
new [ ]
{
new [ ] { 1.50f , 0 , 0 , 0 , 0 } ,
new [ ] { 0 , 1.45f , 0 , 0 , 0 } ,
new [ ] { 0 , 0 , 1.09f , 0 , 0 } ,
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 [ ] { - 0.10f , 0.05f , - 0.08 f, 0 , 1 }
} ) ;
new [ ] { . 0 7 5f , . 0 7 5f , . 0 7 5 f, 0 , 1 }
} ) ) ;
}
}
@ -104,7 +135,7 @@ namespace ImageProcessor.Imaging.Filters
{
get
{
return new ColorMatrix (
return greyScale ? ? ( greyScale = new ColorMatrix (
new [ ]
{
new [ ] { . 3 3f , . 3 3f , . 3 3f , 0 , 0 } ,
@ -112,7 +143,26 @@ namespace ImageProcessor.Imaging.Filters
new [ ] { . 1 1f , . 1 1f , . 1 1f , 0 , 0 } ,
new float [ ] { 0 , 0 , 0 , 1 , 0 } ,
new float [ ] { 0 , 0 , 0 , 0 , 1 }
} ) ;
} ) ) ;
}
}
/// <summary>
/// Gets the <see cref="T:System.Drawing.Imaging.ColorMatrix"/> for generating the high saturation filter.
/// </summary>
internal static ColorMatrix HiSatch
{
get
{
return hiSatch ? ? ( hiSatch = new ColorMatrix (
new [ ]
{
new float [ ] { 3 , - 1 , - 1 , 0 , 0 } ,
new float [ ] { - 1 , 3 , - 1 , 0 , 0 } ,
new float [ ] { - 1 , - 1 , 3 , 0 , 0 } ,
new float [ ] { 0 , 0 , 0 , 1 , 0 } ,
new float [ ] { 0 , 0 , 0 , 0 , 1 }
} ) ) ;
}
}
@ -123,7 +173,7 @@ namespace ImageProcessor.Imaging.Filters
{
get
{
return new ColorMatrix (
return invert ? ? ( invert = new ColorMatrix (
new [ ]
{
new float [ ] { - 1 , 0 , 0 , 0 , 0 } ,
@ -131,39 +181,38 @@ namespace ImageProcessor.Imaging.Filters
new float [ ] { 0 , 0 , - 1 , 0 , 0 } ,
new float [ ] { 0 , 0 , 0 , 1 , 0 } ,
new float [ ] { 1 , 1 , 1 , 0 , 1 }
} ) ;
} ) ) ;
}
}
/// <summary>
/// Gets the <see cref="T:System.Drawing.Imaging.ColorMatrix"/> for generating the high saturation filter.
/// Gets the <see cref="T:System.Drawing.Imaging.ColorMatrix"/> for generating the lomograph filter.
/// </summary>
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "Reviewed. Suppression is OK here.")]
internal static ColorMatrix HiSatch
internal static ColorMatrix Lomograph
{
get
{
return new ColorMatrix (
new [ ]
{
new float [ ] { 3 , - 1 , - 1 , 0 , 0 } ,
new float [ ] { - 1 , 3 , - 1 , 0 , 0 } ,
new float [ ] { - 1 , - 1 , 3 , 0 , 0 } ,
new float [ ] { 0 , 0 , 0 , 1 , 0 } ,
new float [ ] { 0 , 0 , 0 , 0 , 1 }
} ) ;
return lomograph
? ? ( lomograph = new ColorMatrix (
new [ ]
{
new [ ] { 1.50f , 0 , 0 , 0 , 0 } ,
new [ ] { 0 , 1.45f , 0 , 0 , 0 } ,
new [ ] { 0 , 0 , 1.09f , 0 , 0 } ,
new float [ ] { 0 , 0 , 0 , 1 , 0 } ,
new [ ] { - 0.10f , 0.05f , - 0.08f , 0 , 1 }
} ) ) ;
}
}
/// <summary>
/// Gets the <see cref="T:System.Drawing.Imaging.ColorMatrix"/> for generating the low saturation filter.
/// </summary>
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "Reviewed. Suppression is OK here.")]
internal static ColorMatrix LoSatch
{
get
{
return new ColorMatrix (
return loSatch ? ? ( loSatch = new ColorMatrix (
new [ ]
{
new float [ ] { 1 , 0 , 0 , 0 , 0 } ,
@ -171,48 +220,46 @@ namespace ImageProcessor.Imaging.Filters
new float [ ] { 0 , 0 , 1 , 0 , 0 } ,
new float [ ] { 0 , 0 , 0 , 1 , 0 } ,
new [ ] { . 2 5f , . 2 5f , . 2 5f , 0 , 1 }
} ) ;
} ) ) ;
}
}
/// <summary>
/// Gets the <see cref="T:System.Drawing.Imaging.ColorMatrix"/> for generating the high pass
/// on the comic book filter.
/// Gets the <see cref="T:System.Drawing.Imaging.ColorMatrix"/> for generating the polaroid filter.
/// </summary>
internal static ColorMatrix ComicHigh
internal static ColorMatrix Polaroid
{
get
{
return new ColorMatrix (
return polaroid ? ? ( polaroid = new ColorMatrix (
new [ ]
{
new [ ] { 2 , - 0.5f , - 0.5 f, 0 , 0 } ,
new [ ] { - 0.5f , 2 , - 0.5 f , 0 , 0 } ,
new [ ] { - 0.5f , - 0.5f , 2 , 0 , 0 } ,
new [ ] { 1.638f , - 0.062f , - 0.262 f, 0 , 0 } ,
new [ ] { - 0.122f , 1.378f , - 0.122 f , 0 , 0 } ,
new [ ] { 1.016f , - 0.016f , 1.383f , 0 , 0 } ,
new float [ ] { 0 , 0 , 0 , 1 , 0 } ,
new float [ ] { 0 , 0 , 0 , 0 , 1 }
} ) ;
new [ ] { 0.06f , - 0.05f , - 0.05f , 0 , 1 }
} ) ) ;
}
}
/// <summary>
/// Gets <see cref="T:System.Drawing.Imaging.ColorMatrix"/> for generating the low pass
/// on the comic book filter.
/// Gets the <see cref="T:System.Drawing.Imaging.ColorMatrix"/> for generating the sepia filter.
/// </summary>
internal static ColorMatrix ComicLow
internal static ColorMatrix Sepia
{
get
{
return new ColorMatrix (
new [ ]
return sepia ? ? ( sepia = new ColorMatrix (
new [ ]
{
new float [ ] { 1 , 0 , 0 , 0 , 0 } ,
new float [ ] { 0 , 1 , 0 , 0 , 0 } ,
new float [ ] { 0 , 0 , 1 , 0 , 0 } ,
new [ ] { . 3 9 3f , . 3 4 9f , . 2 7 2f , 0 , 0 } ,
new [ ] { . 7 6 9f , . 6 8 6f , . 5 3 4f , 0 , 0 } ,
new [ ] { . 1 8 9f , . 1 6 8f , . 1 3 1f , 0 , 0 } ,
new float [ ] { 0 , 0 , 0 , 1 , 0 } ,
new [ ] { . 0 7 5f , . 0 7 5f , . 0 7 5f , 0 , 1 }
} ) ;
new float [ ] { 0 , 0 , 0 , 0 , 1 }
} ) ) ;
}
}
}
}
}