diff --git a/README.md b/README.md index 6d37dd5e7..d62d430f6 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ using (var pixels = image.Lock()) } ``` -For advanced usage the `Image` and `PixelAccessor` classes are available allowing developers to implement their own color models in the same manner as Microsoft XNA Game Studio and MonoGame. +For advanced usage the `Image` and `PixelAccessor` classes are available allowing developers to implement their own color models in the same manner as Microsoft XNA Game Studio and MonoGame. All in all this should allow image processing to be much more accessible to developers which has always been my goal from the start. diff --git a/src/ImageSharp.Drawing/Brushes/Brushes{TColor}.cs b/src/ImageSharp.Drawing/Brushes/Brushes{TPixel}.cs similarity index 78% rename from src/ImageSharp.Drawing/Brushes/Brushes{TColor}.cs rename to src/ImageSharp.Drawing/Brushes/Brushes{TPixel}.cs index 6e092bf18..d56e9e6eb 100644 --- a/src/ImageSharp.Drawing/Brushes/Brushes{TColor}.cs +++ b/src/ImageSharp.Drawing/Brushes/Brushes{TPixel}.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // @@ -10,10 +10,10 @@ namespace ImageSharp.Drawing.Brushes /// /// A collection of methods for creating generic brushes. /// - /// The pixel format. + /// The pixel format. /// A Brush - public class Brushes - where TColor : struct, IPixel + public class Brushes + where TPixel : struct, IPixel { /// /// Percent10 Hatch Pattern @@ -99,8 +99,8 @@ namespace ImageSharp.Drawing.Brushes /// /// The color. /// A Brush - public static SolidBrush Solid(TColor color) - => new SolidBrush(color); + public static SolidBrush Solid(TPixel color) + => new SolidBrush(color); /// /// Create as brush that will paint a Percent10 Hatch Pattern within the specified colors @@ -108,8 +108,8 @@ namespace ImageSharp.Drawing.Brushes /// Color of the foreground. /// Color of the background. /// A Brush - public static PatternBrush Percent10(TColor foreColor, TColor backColor) - => new PatternBrush(foreColor, backColor, Percent10Pattern); + public static PatternBrush Percent10(TPixel foreColor, TPixel backColor) + => new PatternBrush(foreColor, backColor, Percent10Pattern); /// /// Create as brush that will paint a Percent20 Hatch Pattern within the specified colors @@ -117,8 +117,8 @@ namespace ImageSharp.Drawing.Brushes /// Color of the foreground. /// Color of the background. /// A Brush - public static PatternBrush Percent20(TColor foreColor, TColor backColor) - => new PatternBrush(foreColor, backColor, Percent20Pattern); + public static PatternBrush Percent20(TPixel foreColor, TPixel backColor) + => new PatternBrush(foreColor, backColor, Percent20Pattern); /// /// Create as brush that will paint a Horizontal Hatch Pattern within the specified colors @@ -126,8 +126,8 @@ namespace ImageSharp.Drawing.Brushes /// Color of the foreground. /// Color of the background. /// A Brush - public static PatternBrush Horizontal(TColor foreColor, TColor backColor) - => new PatternBrush(foreColor, backColor, HorizontalPattern); + public static PatternBrush Horizontal(TPixel foreColor, TPixel backColor) + => new PatternBrush(foreColor, backColor, HorizontalPattern); /// /// Create as brush that will paint a Min Hatch Pattern within the specified colors @@ -135,8 +135,8 @@ namespace ImageSharp.Drawing.Brushes /// Color of the foreground. /// Color of the background. /// A Brush - public static PatternBrush Min(TColor foreColor, TColor backColor) - => new PatternBrush(foreColor, backColor, MinPattern); + public static PatternBrush Min(TPixel foreColor, TPixel backColor) + => new PatternBrush(foreColor, backColor, MinPattern); /// /// Create as brush that will paint a Vertical Hatch Pattern within the specified colors @@ -144,8 +144,8 @@ namespace ImageSharp.Drawing.Brushes /// Color of the foreground. /// Color of the background. /// A Brush - public static PatternBrush Vertical(TColor foreColor, TColor backColor) - => new PatternBrush(foreColor, backColor, VerticalPattern); + public static PatternBrush Vertical(TPixel foreColor, TPixel backColor) + => new PatternBrush(foreColor, backColor, VerticalPattern); /// /// Create as brush that will paint a Forward Diagonal Hatch Pattern within the specified colors @@ -153,8 +153,8 @@ namespace ImageSharp.Drawing.Brushes /// Color of the foreground. /// Color of the background. /// A Brush - public static PatternBrush ForwardDiagonal(TColor foreColor, TColor backColor) - => new PatternBrush(foreColor, backColor, ForwardDiagonalPattern); + public static PatternBrush ForwardDiagonal(TPixel foreColor, TPixel backColor) + => new PatternBrush(foreColor, backColor, ForwardDiagonalPattern); /// /// Create as brush that will paint a Backward Diagonal Hatch Pattern within the specified colors @@ -162,7 +162,7 @@ namespace ImageSharp.Drawing.Brushes /// Color of the foreground. /// Color of the background. /// A Brush - public static PatternBrush BackwardDiagonal(TColor foreColor, TColor backColor) - => new PatternBrush(foreColor, backColor, BackwardDiagonalPattern); + public static PatternBrush BackwardDiagonal(TPixel foreColor, TPixel backColor) + => new PatternBrush(foreColor, backColor, BackwardDiagonalPattern); } } diff --git a/src/ImageSharp.Drawing/Brushes/IBrush.cs b/src/ImageSharp.Drawing/Brushes/IBrush.cs index df05fa23e..a19c55169 100644 --- a/src/ImageSharp.Drawing/Brushes/IBrush.cs +++ b/src/ImageSharp.Drawing/Brushes/IBrush.cs @@ -12,13 +12,13 @@ namespace ImageSharp.Drawing /// /// Brush represents a logical configuration of a brush which can be used to source pixel colors /// - /// The pixel format. + /// The pixel format. /// - /// A brush is a simple class that will return an that will perform the - /// logic for converting a pixel location to a . + /// A brush is a simple class that will return an that will perform the + /// logic for converting a pixel location to a . /// - public interface IBrush - where TColor : struct, IPixel + public interface IBrush + where TPixel : struct, IPixel { /// /// Creates the applicator for this brush. @@ -32,6 +32,6 @@ namespace ImageSharp.Drawing /// The when being applied to things like shapes would usually be the /// bounding box of the shape not necessarily the bounds of the whole image /// - BrushApplicator CreateApplicator(PixelAccessor pixelSource, RectangleF region); + BrushApplicator CreateApplicator(PixelAccessor pixelSource, RectangleF region); } } \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Brushes/ImageBrush{TColor}.cs b/src/ImageSharp.Drawing/Brushes/ImageBrush{TPixel}.cs similarity index 83% rename from src/ImageSharp.Drawing/Brushes/ImageBrush{TColor}.cs rename to src/ImageSharp.Drawing/Brushes/ImageBrush{TPixel}.cs index b68b02eff..e7ae27b60 100644 --- a/src/ImageSharp.Drawing/Brushes/ImageBrush{TColor}.cs +++ b/src/ImageSharp.Drawing/Brushes/ImageBrush{TPixel}.cs @@ -1,11 +1,10 @@ -// +// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // namespace ImageSharp.Drawing.Brushes { - using System; using System.Numerics; using Processors; @@ -13,26 +12,26 @@ namespace ImageSharp.Drawing.Brushes /// /// Provides an implementation of an image brush for painting images within areas. /// - /// The pixel format. - public class ImageBrush : IBrush - where TColor : struct, IPixel + /// The pixel format. + public class ImageBrush : IBrush + where TPixel : struct, IPixel { /// /// The image to paint. /// - private readonly IImageBase image; + private readonly IImageBase image; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The image. - public ImageBrush(IImageBase image) + public ImageBrush(IImageBase image) { this.image = image; } /// - public BrushApplicator CreateApplicator(PixelAccessor sourcePixels, RectangleF region) + public BrushApplicator CreateApplicator(PixelAccessor sourcePixels, RectangleF region) { return new ImageBrushApplicator(sourcePixels, this.image, region); } @@ -40,12 +39,12 @@ namespace ImageSharp.Drawing.Brushes /// /// The image brush applicator. /// - private class ImageBrushApplicator : BrushApplicator + private class ImageBrushApplicator : BrushApplicator { /// /// The source pixel accessor. /// - private readonly PixelAccessor source; + private readonly PixelAccessor source; /// /// The y-length. @@ -74,7 +73,7 @@ namespace ImageSharp.Drawing.Brushes /// /// The sourcePixels. /// - public ImageBrushApplicator(PixelAccessor sourcePixels, IImageBase image, RectangleF region) + public ImageBrushApplicator(PixelAccessor sourcePixels, IImageBase image, RectangleF region) : base(sourcePixels) { this.source = image.Lock(); @@ -91,7 +90,7 @@ namespace ImageSharp.Drawing.Brushes /// /// The color /// - internal override TColor this[int x, int y] + internal override TPixel this[int x, int y] { get { @@ -135,7 +134,7 @@ namespace ImageSharp.Drawing.Brushes Vector4 finalColor = Vector4BlendTransforms.PremultipliedLerp(backgroundVector, sourceVector, opacity); - TColor packed = default(TColor); + TPixel packed = default(TPixel); packed.PackFromVector4(finalColor); this.Target[targetX, targetY] = packed; } diff --git a/src/ImageSharp.Drawing/Brushes/PatternBrush{TColor}.cs b/src/ImageSharp.Drawing/Brushes/PatternBrush{TPixel}.cs similarity index 85% rename from src/ImageSharp.Drawing/Brushes/PatternBrush{TColor}.cs rename to src/ImageSharp.Drawing/Brushes/PatternBrush{TPixel}.cs index 1af58bc62..4f3240247 100644 --- a/src/ImageSharp.Drawing/Brushes/PatternBrush{TColor}.cs +++ b/src/ImageSharp.Drawing/Brushes/PatternBrush{TPixel}.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // @@ -31,38 +31,38 @@ namespace ImageSharp.Drawing.Brushes /// 0 /// /// - /// The pixel format. - public class PatternBrush : IBrush - where TColor : struct, IPixel + /// The pixel format. + public class PatternBrush : IBrush + where TPixel : struct, IPixel { /// /// The pattern. /// - private readonly Fast2DArray pattern; + private readonly Fast2DArray pattern; private readonly Fast2DArray patternVector; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// Color of the fore. /// Color of the back. /// The pattern. - public PatternBrush(TColor foreColor, TColor backColor, bool[,] pattern) + public PatternBrush(TPixel foreColor, TPixel backColor, bool[,] pattern) : this(foreColor, backColor, new Fast2DArray(pattern)) { } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// Color of the fore. /// Color of the back. /// The pattern. - internal PatternBrush(TColor foreColor, TColor backColor, Fast2DArray pattern) + internal PatternBrush(TPixel foreColor, TPixel backColor, Fast2DArray pattern) { Vector4 foreColorVector = foreColor.ToVector4(); Vector4 backColorVector = backColor.ToVector4(); - this.pattern = new Fast2DArray(pattern.Width, pattern.Height); + this.pattern = new Fast2DArray(pattern.Width, pattern.Height); this.patternVector = new Fast2DArray(pattern.Width, pattern.Height); for (int i = 0; i < pattern.Data.Length; i++) { @@ -80,17 +80,17 @@ namespace ImageSharp.Drawing.Brushes } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The brush. - internal PatternBrush(PatternBrush brush) + internal PatternBrush(PatternBrush brush) { this.pattern = brush.pattern; this.patternVector = brush.patternVector; } /// - public BrushApplicator CreateApplicator(PixelAccessor sourcePixels, RectangleF region) + public BrushApplicator CreateApplicator(PixelAccessor sourcePixels, RectangleF region) { return new PatternBrushApplicator(sourcePixels, this.pattern, this.patternVector); } @@ -98,12 +98,12 @@ namespace ImageSharp.Drawing.Brushes /// /// The pattern brush applicator. /// - private class PatternBrushApplicator : BrushApplicator + private class PatternBrushApplicator : BrushApplicator { /// /// The pattern. /// - private readonly Fast2DArray pattern; + private readonly Fast2DArray pattern; private readonly Fast2DArray patternVector; /// @@ -112,7 +112,7 @@ namespace ImageSharp.Drawing.Brushes /// The sourcePixels. /// The pattern. /// The patternVector. - public PatternBrushApplicator(PixelAccessor sourcePixels, Fast2DArray pattern, Fast2DArray patternVector) + public PatternBrushApplicator(PixelAccessor sourcePixels, Fast2DArray pattern, Fast2DArray patternVector) : base(sourcePixels) { this.pattern = pattern; @@ -127,7 +127,7 @@ namespace ImageSharp.Drawing.Brushes /// /// The Color. /// - internal override TColor this[int x, int y] + internal override TPixel this[int x, int y] { get { @@ -169,7 +169,7 @@ namespace ImageSharp.Drawing.Brushes Vector4 finalColor = Vector4BlendTransforms.PremultipliedLerp(backgroundVector, sourceVector, opacity); - TColor packed = default(TColor); + TPixel packed = default(TPixel); packed.PackFromVector4(finalColor); this.Target[targetX, targetY] = packed; } diff --git a/src/ImageSharp.Drawing/Brushes/Processors/BrushApplicator.cs b/src/ImageSharp.Drawing/Brushes/Processors/BrushApplicator.cs index 0ef11e161..0116a13ae 100644 --- a/src/ImageSharp.Drawing/Brushes/Processors/BrushApplicator.cs +++ b/src/ImageSharp.Drawing/Brushes/Processors/BrushApplicator.cs @@ -12,16 +12,16 @@ namespace ImageSharp.Drawing.Processors /// /// primitive that converts a point in to a color for discovering the fill color based on an implementation /// - /// The pixel format. + /// The pixel format. /// - public abstract class BrushApplicator : IDisposable // disposable will be required if/when there is an ImageBrush - where TColor : struct, IPixel + public abstract class BrushApplicator : IDisposable // disposable will be required if/when there is an ImageBrush + where TPixel : struct, IPixel { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The target. - internal BrushApplicator(PixelAccessor target) + internal BrushApplicator(PixelAccessor target) { this.Target = target; } @@ -29,15 +29,15 @@ namespace ImageSharp.Drawing.Processors /// /// Gets the destinaion /// - protected PixelAccessor Target { get; } + protected PixelAccessor Target { get; } /// /// Gets the color for a single pixel. /// /// The x cordinate. /// The y cordinate. - /// The a that should be applied to the pixel. - internal abstract TColor this[int x, int y] { get; } + /// The a that should be applied to the pixel. + internal abstract TPixel this[int x, int y] { get; } /// public abstract void Dispose(); @@ -73,7 +73,7 @@ namespace ImageSharp.Drawing.Processors Vector4 finalColor = Vector4BlendTransforms.PremultipliedLerp(backgroundVector, sourceVector, opacity); - TColor packed = default(TColor); + TPixel packed = default(TPixel); packed.PackFromVector4(finalColor); this.Target[targetX, targetY] = packed; } diff --git a/src/ImageSharp.Drawing/Brushes/RecolorBrush.cs b/src/ImageSharp.Drawing/Brushes/RecolorBrush.cs index b18800371..3041d0edf 100644 --- a/src/ImageSharp.Drawing/Brushes/RecolorBrush.cs +++ b/src/ImageSharp.Drawing/Brushes/RecolorBrush.cs @@ -14,10 +14,10 @@ namespace ImageSharp.Drawing.Brushes /// Initializes a new instance of the class. /// /// Color of the source. - /// Color of the target. + /// Color of the target. /// The threshold. - public RecolorBrush(Rgba32 sourceColor, Rgba32 targetColor, float threshold) - : base(sourceColor, targetColor, threshold) + public RecolorBrush(Rgba32 sourceColor, Rgba32 targeTPixel, float threshold) + : base(sourceColor, targeTPixel, threshold) { } } diff --git a/src/ImageSharp.Drawing/Brushes/RecolorBrush{TColor}.cs b/src/ImageSharp.Drawing/Brushes/RecolorBrush{TPixel}.cs similarity index 80% rename from src/ImageSharp.Drawing/Brushes/RecolorBrush{TColor}.cs rename to src/ImageSharp.Drawing/Brushes/RecolorBrush{TPixel}.cs index 4e3cd01ae..aa1b5cb82 100644 --- a/src/ImageSharp.Drawing/Brushes/RecolorBrush{TColor}.cs +++ b/src/ImageSharp.Drawing/Brushes/RecolorBrush{TPixel}.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // @@ -13,21 +13,21 @@ namespace ImageSharp.Drawing.Brushes /// /// Provides an implementation of a brush that can recolor an image /// - /// The pixel format. - public class RecolorBrush : IBrush - where TColor : struct, IPixel + /// The pixel format. + public class RecolorBrush : IBrush + where TPixel : struct, IPixel { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// Color of the source. - /// Color of the target. + /// Color of the target. /// The threshold as a value between 0 and 1. - public RecolorBrush(TColor sourceColor, TColor targetColor, float threshold) + public RecolorBrush(TPixel sourceColor, TPixel targeTPixel, float threshold) { this.SourceColor = sourceColor; this.Threshold = threshold; - this.TargetColor = targetColor; + this.TargeTPixel = targeTPixel; } /// @@ -44,7 +44,7 @@ namespace ImageSharp.Drawing.Brushes /// /// The color of the source. /// - public TColor SourceColor { get; } + public TPixel SourceColor { get; } /// /// Gets the target color. @@ -52,18 +52,18 @@ namespace ImageSharp.Drawing.Brushes /// /// The color of the target. /// - public TColor TargetColor { get; } + public TPixel TargeTPixel { get; } /// - public BrushApplicator CreateApplicator(PixelAccessor sourcePixels, RectangleF region) + public BrushApplicator CreateApplicator(PixelAccessor sourcePixels, RectangleF region) { - return new RecolorBrushApplicator(sourcePixels, this.SourceColor, this.TargetColor, this.Threshold); + return new RecolorBrushApplicator(sourcePixels, this.SourceColor, this.TargeTPixel, this.Threshold); } /// /// The recolor brush applicator. /// - private class RecolorBrushApplicator : BrushApplicator + private class RecolorBrushApplicator : BrushApplicator { /// /// The source color. @@ -73,7 +73,7 @@ namespace ImageSharp.Drawing.Brushes /// /// The target color. /// - private readonly Vector4 targetColor; + private readonly Vector4 targeTPixel; /// /// The threshold. @@ -85,18 +85,18 @@ namespace ImageSharp.Drawing.Brushes /// /// The source pixels. /// Color of the source. - /// Color of the target. + /// Color of the target. /// The threshold . - public RecolorBrushApplicator(PixelAccessor sourcePixels, TColor sourceColor, TColor targetColor, float threshold) + public RecolorBrushApplicator(PixelAccessor sourcePixels, TPixel sourceColor, TPixel targeTPixel, float threshold) : base(sourcePixels) { this.sourceColor = sourceColor.ToVector4(); - this.targetColor = targetColor.ToVector4(); + this.targeTPixel = targeTPixel.ToVector4(); // Lets hack a min max extreams for a color space by letteing the IPackedPixel clamp our values to something in the correct spaces :) - TColor maxColor = default(TColor); + TPixel maxColor = default(TPixel); maxColor.PackFromVector4(new Vector4(float.MaxValue)); - TColor minColor = default(TColor); + TPixel minColor = default(TPixel); minColor.PackFromVector4(new Vector4(float.MinValue)); this.threshold = Vector4.DistanceSquared(maxColor.ToVector4(), minColor.ToVector4()) * threshold; } @@ -109,12 +109,12 @@ namespace ImageSharp.Drawing.Brushes /// /// The color /// - internal override TColor this[int x, int y] + internal override TPixel this[int x, int y] { get { // Offset the requested pixel by the value in the rectangle (the shapes position) - TColor result = this.Target[x, y]; + TPixel result = this.Target[x, y]; Vector4 background = result.ToVector4(); float distance = Vector4.DistanceSquared(background, this.sourceColor); if (distance <= this.threshold) @@ -122,7 +122,7 @@ namespace ImageSharp.Drawing.Brushes float lerpAmount = (this.threshold - distance) / this.threshold; Vector4 blended = Vector4BlendTransforms.PremultipliedLerp( background, - this.targetColor, + this.targeTPixel, lerpAmount); result.PackFromVector4(blended); } @@ -162,12 +162,12 @@ namespace ImageSharp.Drawing.Brushes float lerpAmount = (this.threshold - distance) / this.threshold; sourceVector = Vector4BlendTransforms.PremultipliedLerp( sourceVector, - this.targetColor, + this.targeTPixel, lerpAmount); Vector4 finalColor = Vector4BlendTransforms.PremultipliedLerp(backgroundVector, sourceVector, opacity); - TColor packed = default(TColor); + TPixel packed = default(TPixel); packed.PackFromVector4(finalColor); this.Target[targetX, targetY] = packed; } diff --git a/src/ImageSharp.Drawing/Brushes/SolidBrush{TColor}.cs b/src/ImageSharp.Drawing/Brushes/SolidBrush{TPixel}.cs similarity index 80% rename from src/ImageSharp.Drawing/Brushes/SolidBrush{TColor}.cs rename to src/ImageSharp.Drawing/Brushes/SolidBrush{TPixel}.cs index 74c7081b3..4d9b6adb3 100644 --- a/src/ImageSharp.Drawing/Brushes/SolidBrush{TColor}.cs +++ b/src/ImageSharp.Drawing/Brushes/SolidBrush{TPixel}.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // @@ -13,20 +13,20 @@ namespace ImageSharp.Drawing.Brushes /// /// Provides an implementation of a solid brush for painting solid color areas. /// - /// The pixel format. - public class SolidBrush : IBrush - where TColor : struct, IPixel + /// The pixel format. + public class SolidBrush : IBrush + where TPixel : struct, IPixel { /// /// The color to paint. /// - private readonly TColor color; + private readonly TPixel color; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The color. - public SolidBrush(TColor color) + public SolidBrush(TPixel color) { this.color = color; } @@ -37,10 +37,10 @@ namespace ImageSharp.Drawing.Brushes /// /// The color. /// - public TColor Color => this.color; + public TPixel Color => this.color; /// - public BrushApplicator CreateApplicator(PixelAccessor sourcePixels, RectangleF region) + public BrushApplicator CreateApplicator(PixelAccessor sourcePixels, RectangleF region) { return new SolidBrushApplicator(sourcePixels, this.color); } @@ -48,12 +48,12 @@ namespace ImageSharp.Drawing.Brushes /// /// The solid brush applicator. /// - private class SolidBrushApplicator : BrushApplicator + private class SolidBrushApplicator : BrushApplicator { /// /// The solid color. /// - private readonly TColor color; + private readonly TPixel color; private readonly Vector4 colorVector; /// @@ -61,7 +61,7 @@ namespace ImageSharp.Drawing.Brushes /// /// The color. /// The sourcePixels. - public SolidBrushApplicator(PixelAccessor sourcePixels, TColor color) + public SolidBrushApplicator(PixelAccessor sourcePixels, TPixel color) : base(sourcePixels) { this.color = color; @@ -76,7 +76,7 @@ namespace ImageSharp.Drawing.Brushes /// /// The color /// - internal override TColor this[int x, int y] => this.color; + internal override TPixel this[int x, int y] => this.color; /// public override void Dispose() @@ -106,7 +106,7 @@ namespace ImageSharp.Drawing.Brushes Vector4 finalColor = Vector4BlendTransforms.PremultipliedLerp(backgroundVector, sourceVector, opacity); - TColor packed = default(TColor); + TPixel packed = default(TPixel); packed.PackFromVector4(finalColor); this.Target[targetX, targetY] = packed; } diff --git a/src/ImageSharp.Drawing/DrawImage.cs b/src/ImageSharp.Drawing/DrawImage.cs index 16582e7ee..7f4fb3392 100644 --- a/src/ImageSharp.Drawing/DrawImage.cs +++ b/src/ImageSharp.Drawing/DrawImage.cs @@ -17,13 +17,13 @@ namespace ImageSharp /// /// Draws the given image together with the current one by blending their pixels. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The image to blend with the currently processing image. /// The opacity of the image image to blend. Must be between 0 and 100. - /// The . - public static Image Blend(this Image source, Image image, int percent = 50) - where TColor : struct, IPixel + /// The . + public static Image Blend(this Image source, Image image, int percent = 50) + where TPixel : struct, IPixel { return DrawImage(source, image, percent, default(Size), default(Point)); } @@ -33,13 +33,13 @@ namespace ImageSharp /// /// The image this method extends. /// The image to blend with the currently processing image. - /// The pixel format. + /// The pixel format. /// The opacity of the image image to blend. Must be between 0 and 100. /// The size to draw the blended image. /// The location to draw the blended image. - /// The . - public static Image DrawImage(this Image source, Image image, int percent, Size size, Point location) - where TColor : struct, IPixel + /// The . + public static Image DrawImage(this Image source, Image image, int percent, Size size, Point location) + where TPixel : struct, IPixel { if (size == default(Size)) { @@ -51,7 +51,7 @@ namespace ImageSharp location = Point.Empty; } - source.ApplyProcessor(new DrawImageProcessor(image, size, location, percent), source.Bounds); + source.ApplyProcessor(new DrawImageProcessor(image, size, location, percent), source.Bounds); return source; } } diff --git a/src/ImageSharp.Drawing/DrawPath.cs b/src/ImageSharp.Drawing/DrawPath.cs index e91b97203..64f69c4db 100644 --- a/src/ImageSharp.Drawing/DrawPath.cs +++ b/src/ImageSharp.Drawing/DrawPath.cs @@ -13,35 +13,35 @@ namespace ImageSharp using Drawing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Draws the outline of the region with the provided pen. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The pen. /// The path. /// The options. - /// The . - public static Image Draw(this Image source, IPen pen, Drawable path, GraphicsOptions options) - where TColor : struct, IPixel + /// The . + public static Image Draw(this Image source, IPen pen, Drawable path, GraphicsOptions options) + where TPixel : struct, IPixel { - return source.Apply(new DrawPathProcessor(pen, path, options)); + return source.Apply(new DrawPathProcessor(pen, path, options)); } /// /// Draws the outline of the polygon with the provided pen. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The pen. /// The path. - /// The . - public static Image Draw(this Image source, IPen pen, Drawable path) - where TColor : struct, IPixel + /// The . + public static Image Draw(this Image source, IPen pen, Drawable path) + where TPixel : struct, IPixel { return source.Draw(pen, path, GraphicsOptions.Default); } @@ -49,63 +49,63 @@ namespace ImageSharp /// /// Draws the outline of the polygon with the provided brush at the provided thickness. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The brush. /// The thickness. /// The path. /// The options. - /// The . - public static Image Draw(this Image source, IBrush brush, float thickness, Drawable path, GraphicsOptions options) - where TColor : struct, IPixel + /// The . + public static Image Draw(this Image source, IBrush brush, float thickness, Drawable path, GraphicsOptions options) + where TPixel : struct, IPixel { - return source.Draw(new Pen(brush, thickness), path, options); + return source.Draw(new Pen(brush, thickness), path, options); } /// /// Draws the outline of the polygon with the provided brush at the provided thickness. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The brush. /// The thickness. /// The path. - /// The . - public static Image Draw(this Image source, IBrush brush, float thickness, Drawable path) - where TColor : struct, IPixel + /// The . + public static Image Draw(this Image source, IBrush brush, float thickness, Drawable path) + where TPixel : struct, IPixel { - return source.Draw(new Pen(brush, thickness), path); + return source.Draw(new Pen(brush, thickness), path); } /// /// Draws the outline of the polygon with the provided brush at the provided thickness. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The color. /// The thickness. /// The path. /// The options. - /// The . - public static Image Draw(this Image source, TColor color, float thickness, Drawable path, GraphicsOptions options) - where TColor : struct, IPixel + /// The . + public static Image Draw(this Image source, TPixel color, float thickness, Drawable path, GraphicsOptions options) + where TPixel : struct, IPixel { - return source.Draw(new SolidBrush(color), thickness, path, options); + return source.Draw(new SolidBrush(color), thickness, path, options); } /// /// Draws the outline of the polygon with the provided brush at the provided thickness. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The color. /// The thickness. /// The path. - /// The . - public static Image Draw(this Image source, TColor color, float thickness, Drawable path) - where TColor : struct, IPixel + /// The . + public static Image Draw(this Image source, TPixel color, float thickness, Drawable path) + where TPixel : struct, IPixel { - return source.Draw(new SolidBrush(color), thickness, path); + return source.Draw(new SolidBrush(color), thickness, path); } } } diff --git a/src/ImageSharp.Drawing/FillRegion.cs b/src/ImageSharp.Drawing/FillRegion.cs index 8aab20251..fda5c2c26 100644 --- a/src/ImageSharp.Drawing/FillRegion.cs +++ b/src/ImageSharp.Drawing/FillRegion.cs @@ -12,61 +12,61 @@ namespace ImageSharp using Drawing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Flood fills the image with the specified brush. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The details how to fill the region of interest. - /// The . - public static Image Fill(this Image source, IBrush brush) - where TColor : struct, IPixel + /// The . + public static Image Fill(this Image source, IBrush brush) + where TPixel : struct, IPixel { - return source.Apply(new FillProcessor(brush)); + return source.Apply(new FillProcessor(brush)); } /// /// Flood fills the image with the specified color. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The color. - /// The . - public static Image Fill(this Image source, TColor color) - where TColor : struct, IPixel + /// The . + public static Image Fill(this Image source, TPixel color) + where TPixel : struct, IPixel { - return source.Fill(new SolidBrush(color)); + return source.Fill(new SolidBrush(color)); } /// /// Flood fills the image with in the region with the specified brush. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The brush. /// The region. /// The graphics options. - /// The . - public static Image Fill(this Image source, IBrush brush, Region region, GraphicsOptions options) - where TColor : struct, IPixel + /// The . + public static Image Fill(this Image source, IBrush brush, Region region, GraphicsOptions options) + where TPixel : struct, IPixel { - return source.Apply(new FillRegionProcessor(brush, region, options)); + return source.Apply(new FillRegionProcessor(brush, region, options)); } /// /// Flood fills the image with in the region with the specified brush. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The brush. /// The region. - /// The . - public static Image Fill(this Image source, IBrush brush, Region region) - where TColor : struct, IPixel + /// The . + public static Image Fill(this Image source, IBrush brush, Region region) + where TPixel : struct, IPixel { return source.Fill(brush, region, GraphicsOptions.Default); } @@ -74,30 +74,30 @@ namespace ImageSharp /// /// Flood fills the image with in the region with the specified color. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The color. /// The region. /// The options. - /// The . - public static Image Fill(this Image source, TColor color, Region region, GraphicsOptions options) - where TColor : struct, IPixel + /// The . + public static Image Fill(this Image source, TPixel color, Region region, GraphicsOptions options) + where TPixel : struct, IPixel { - return source.Fill(new SolidBrush(color), region, options); + return source.Fill(new SolidBrush(color), region, options); } /// /// Flood fills the image with in the region with the specified color. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The color. /// The region. - /// The . - public static Image Fill(this Image source, TColor color, Region region) - where TColor : struct, IPixel + /// The . + public static Image Fill(this Image source, TPixel color, Region region) + where TPixel : struct, IPixel { - return source.Fill(new SolidBrush(color), region); + return source.Fill(new SolidBrush(color), region); } } } diff --git a/src/ImageSharp.Drawing/Paths/DrawBeziers.cs b/src/ImageSharp.Drawing/Paths/DrawBeziers.cs index 936d5a9ce..af96ef50e 100644 --- a/src/ImageSharp.Drawing/Paths/DrawBeziers.cs +++ b/src/ImageSharp.Drawing/Paths/DrawBeziers.cs @@ -14,83 +14,83 @@ namespace ImageSharp using SixLabors.Shapes; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Draws the provided Points as an open Bezier path at the provided thickness with the supplied brush /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The brush. /// The thickness. /// The points. /// The options. - /// The . - public static Image DrawBeziers(this Image source, IBrush brush, float thickness, Vector2[] points, GraphicsOptions options) - where TColor : struct, IPixel + /// The . + public static Image DrawBeziers(this Image source, IBrush brush, float thickness, Vector2[] points, GraphicsOptions options) + where TPixel : struct, IPixel { - return source.Draw(new Pen(brush, thickness), new Path(new BezierLineSegment(points)), options); + return source.Draw(new Pen(brush, thickness), new Path(new BezierLineSegment(points)), options); } /// /// Draws the provided Points as an open Bezier path at the provided thickness with the supplied brush /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The brush. /// The thickness. /// The points. - /// The . - public static Image DrawBeziers(this Image source, IBrush brush, float thickness, Vector2[] points) - where TColor : struct, IPixel + /// The . + public static Image DrawBeziers(this Image source, IBrush brush, float thickness, Vector2[] points) + where TPixel : struct, IPixel { - return source.Draw(new Pen(brush, thickness), new Path(new BezierLineSegment(points))); + return source.Draw(new Pen(brush, thickness), new Path(new BezierLineSegment(points))); } /// /// Draws the provided Points as an open Bezier path at the provided thickness with the supplied brush /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The color. /// The thickness. /// The points. - /// The . - public static Image DrawBeziers(this Image source, TColor color, float thickness, Vector2[] points) - where TColor : struct, IPixel + /// The . + public static Image DrawBeziers(this Image source, TPixel color, float thickness, Vector2[] points) + where TPixel : struct, IPixel { - return source.DrawBeziers(new SolidBrush(color), thickness, points); + return source.DrawBeziers(new SolidBrush(color), thickness, points); } /// /// Draws the provided Points as an open Bezier path at the provided thickness with the supplied brush /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The color. /// The thickness. /// The points. /// The options. - /// The . - public static Image DrawBeziers(this Image source, TColor color, float thickness, Vector2[] points, GraphicsOptions options) - where TColor : struct, IPixel + /// The . + public static Image DrawBeziers(this Image source, TPixel color, float thickness, Vector2[] points, GraphicsOptions options) + where TPixel : struct, IPixel { - return source.DrawBeziers(new SolidBrush(color), thickness, points, options); + return source.DrawBeziers(new SolidBrush(color), thickness, points, options); } /// /// Draws the provided Points as an open Bezier path with the supplied pen /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The pen. /// The points. /// The options. - /// The . - public static Image DrawBeziers(this Image source, IPen pen, Vector2[] points, GraphicsOptions options) - where TColor : struct, IPixel + /// The . + public static Image DrawBeziers(this Image source, IPen pen, Vector2[] points, GraphicsOptions options) + where TPixel : struct, IPixel { return source.Draw(pen, new Path(new BezierLineSegment(points)), options); } @@ -98,13 +98,13 @@ namespace ImageSharp /// /// Draws the provided Points as an open Bezier path with the supplied pen /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The pen. /// The points. - /// The . - public static Image DrawBeziers(this Image source, IPen pen, Vector2[] points) - where TColor : struct, IPixel + /// The . + public static Image DrawBeziers(this Image source, IPen pen, Vector2[] points) + where TPixel : struct, IPixel { return source.Draw(pen, new Path(new BezierLineSegment(points))); } diff --git a/src/ImageSharp.Drawing/Paths/DrawLines.cs b/src/ImageSharp.Drawing/Paths/DrawLines.cs index 42f4406e8..c0c49a77a 100644 --- a/src/ImageSharp.Drawing/Paths/DrawLines.cs +++ b/src/ImageSharp.Drawing/Paths/DrawLines.cs @@ -14,83 +14,83 @@ namespace ImageSharp using SixLabors.Shapes; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Draws the provided Points as an open Linear path at the provided thickness with the supplied brush /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The brush. /// The thickness. /// The points. /// The options. - /// The . - public static Image DrawLines(this Image source, IBrush brush, float thickness, Vector2[] points, GraphicsOptions options) - where TColor : struct, IPixel + /// The . + public static Image DrawLines(this Image source, IBrush brush, float thickness, Vector2[] points, GraphicsOptions options) + where TPixel : struct, IPixel { - return source.Draw(new Pen(brush, thickness), new Path(new LinearLineSegment(points)), options); + return source.Draw(new Pen(brush, thickness), new Path(new LinearLineSegment(points)), options); } /// /// Draws the provided Points as an open Linear path at the provided thickness with the supplied brush /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The brush. /// The thickness. /// The points. - /// The . - public static Image DrawLines(this Image source, IBrush brush, float thickness, Vector2[] points) - where TColor : struct, IPixel + /// The . + public static Image DrawLines(this Image source, IBrush brush, float thickness, Vector2[] points) + where TPixel : struct, IPixel { - return source.Draw(new Pen(brush, thickness), new Path(new LinearLineSegment(points))); + return source.Draw(new Pen(brush, thickness), new Path(new LinearLineSegment(points))); } /// /// Draws the provided Points as an open Linear path at the provided thickness with the supplied brush /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The color. /// The thickness. /// The points. - /// The . - public static Image DrawLines(this Image source, TColor color, float thickness, Vector2[] points) - where TColor : struct, IPixel + /// The . + public static Image DrawLines(this Image source, TPixel color, float thickness, Vector2[] points) + where TPixel : struct, IPixel { - return source.DrawLines(new SolidBrush(color), thickness, points); + return source.DrawLines(new SolidBrush(color), thickness, points); } /// /// Draws the provided Points as an open Linear path at the provided thickness with the supplied brush /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The color. /// The thickness. /// The points. /// The options. - /// The .> - public static Image DrawLines(this Image source, TColor color, float thickness, Vector2[] points, GraphicsOptions options) - where TColor : struct, IPixel + /// The .> + public static Image DrawLines(this Image source, TPixel color, float thickness, Vector2[] points, GraphicsOptions options) + where TPixel : struct, IPixel { - return source.DrawLines(new SolidBrush(color), thickness, points, options); + return source.DrawLines(new SolidBrush(color), thickness, points, options); } /// /// Draws the provided Points as an open Linear path with the supplied pen /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The pen. /// The points. /// The options. - /// The . - public static Image DrawLines(this Image source, IPen pen, Vector2[] points, GraphicsOptions options) - where TColor : struct, IPixel + /// The . + public static Image DrawLines(this Image source, IPen pen, Vector2[] points, GraphicsOptions options) + where TPixel : struct, IPixel { return source.Draw(pen, new Path(new LinearLineSegment(points)), options); } @@ -98,13 +98,13 @@ namespace ImageSharp /// /// Draws the provided Points as an open Linear path with the supplied pen /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The pen. /// The points. - /// The . - public static Image DrawLines(this Image source, IPen pen, Vector2[] points) - where TColor : struct, IPixel + /// The . + public static Image DrawLines(this Image source, IPen pen, Vector2[] points) + where TPixel : struct, IPixel { return source.Draw(pen, new Path(new LinearLineSegment(points))); } diff --git a/src/ImageSharp.Drawing/Paths/DrawPath.cs b/src/ImageSharp.Drawing/Paths/DrawPath.cs index e2c1442de..f25c15336 100644 --- a/src/ImageSharp.Drawing/Paths/DrawPath.cs +++ b/src/ImageSharp.Drawing/Paths/DrawPath.cs @@ -14,21 +14,21 @@ namespace ImageSharp using SixLabors.Shapes; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Draws the outline of the polygon with the provided pen. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The pen. /// The path. /// The options. - /// The . - public static Image Draw(this Image source, IPen pen, IPath path, GraphicsOptions options) - where TColor : struct, IPixel + /// The . + public static Image Draw(this Image source, IPen pen, IPath path, GraphicsOptions options) + where TPixel : struct, IPixel { return source.Draw(pen, new ShapePath(path), options); } @@ -36,13 +36,13 @@ namespace ImageSharp /// /// Draws the outline of the polygon with the provided pen. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The pen. /// The path. - /// The . - public static Image Draw(this Image source, IPen pen, IPath path) - where TColor : struct, IPixel + /// The . + public static Image Draw(this Image source, IPen pen, IPath path) + where TPixel : struct, IPixel { return source.Draw(pen, path, GraphicsOptions.Default); } @@ -50,63 +50,63 @@ namespace ImageSharp /// /// Draws the outline of the polygon with the provided brush at the provided thickness. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The brush. /// The thickness. /// The shape. /// The options. - /// The . - public static Image Draw(this Image source, IBrush brush, float thickness, IPath path, GraphicsOptions options) - where TColor : struct, IPixel + /// The . + public static Image Draw(this Image source, IBrush brush, float thickness, IPath path, GraphicsOptions options) + where TPixel : struct, IPixel { - return source.Draw(new Pen(brush, thickness), path, options); + return source.Draw(new Pen(brush, thickness), path, options); } /// /// Draws the outline of the polygon with the provided brush at the provided thickness. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The brush. /// The thickness. /// The path. - /// The . - public static Image Draw(this Image source, IBrush brush, float thickness, IPath path) - where TColor : struct, IPixel + /// The . + public static Image Draw(this Image source, IBrush brush, float thickness, IPath path) + where TPixel : struct, IPixel { - return source.Draw(new Pen(brush, thickness), path); + return source.Draw(new Pen(brush, thickness), path); } /// /// Draws the outline of the polygon with the provided brush at the provided thickness. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The color. /// The thickness. /// The path. /// The options. - /// The . - public static Image Draw(this Image source, TColor color, float thickness, IPath path, GraphicsOptions options) - where TColor : struct, IPixel + /// The . + public static Image Draw(this Image source, TPixel color, float thickness, IPath path, GraphicsOptions options) + where TPixel : struct, IPixel { - return source.Draw(new SolidBrush(color), thickness, path, options); + return source.Draw(new SolidBrush(color), thickness, path, options); } /// /// Draws the outline of the polygon with the provided brush at the provided thickness. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The color. /// The thickness. /// The path. - /// The . - public static Image Draw(this Image source, TColor color, float thickness, IPath path) - where TColor : struct, IPixel + /// The . + public static Image Draw(this Image source, TPixel color, float thickness, IPath path) + where TPixel : struct, IPixel { - return source.Draw(new SolidBrush(color), thickness, path); + return source.Draw(new SolidBrush(color), thickness, path); } } } diff --git a/src/ImageSharp.Drawing/Paths/DrawPolygon.cs b/src/ImageSharp.Drawing/Paths/DrawPolygon.cs index 8043d18e5..5f62759ce 100644 --- a/src/ImageSharp.Drawing/Paths/DrawPolygon.cs +++ b/src/ImageSharp.Drawing/Paths/DrawPolygon.cs @@ -14,82 +14,82 @@ namespace ImageSharp using SixLabors.Shapes; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Draws the provided Points as a closed Linear Polygon with the provided brush at the provided thickness. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The brush. /// The thickness. /// The points. /// The options. - /// The . - public static Image DrawPolygon(this Image source, IBrush brush, float thickness, Vector2[] points, GraphicsOptions options) - where TColor : struct, IPixel + /// The . + public static Image DrawPolygon(this Image source, IBrush brush, float thickness, Vector2[] points, GraphicsOptions options) + where TPixel : struct, IPixel { - return source.Draw(new Pen(brush, thickness), new Polygon(new LinearLineSegment(points)), options); + return source.Draw(new Pen(brush, thickness), new Polygon(new LinearLineSegment(points)), options); } /// /// Draws the provided Points as a closed Linear Polygon with the provided brush at the provided thickness. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The brush. /// The thickness. /// The points. - /// The . - public static Image DrawPolygon(this Image source, IBrush brush, float thickness, Vector2[] points) - where TColor : struct, IPixel + /// The . + public static Image DrawPolygon(this Image source, IBrush brush, float thickness, Vector2[] points) + where TPixel : struct, IPixel { - return source.Draw(new Pen(brush, thickness), new Polygon(new LinearLineSegment(points))); + return source.Draw(new Pen(brush, thickness), new Polygon(new LinearLineSegment(points))); } /// /// Draws the provided Points as a closed Linear Polygon with the provided brush at the provided thickness. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The color. /// The thickness. /// The points. - /// The . - public static Image DrawPolygon(this Image source, TColor color, float thickness, Vector2[] points) - where TColor : struct, IPixel + /// The . + public static Image DrawPolygon(this Image source, TPixel color, float thickness, Vector2[] points) + where TPixel : struct, IPixel { - return source.DrawPolygon(new SolidBrush(color), thickness, points); + return source.DrawPolygon(new SolidBrush(color), thickness, points); } /// /// Draws the provided Points as a closed Linear Polygon with the provided brush at the provided thickness. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The color. /// The thickness. /// The points. /// The options. - /// The . - public static Image DrawPolygon(this Image source, TColor color, float thickness, Vector2[] points, GraphicsOptions options) - where TColor : struct, IPixel + /// The . + public static Image DrawPolygon(this Image source, TPixel color, float thickness, Vector2[] points, GraphicsOptions options) + where TPixel : struct, IPixel { - return source.DrawPolygon(new SolidBrush(color), thickness, points, options); + return source.DrawPolygon(new SolidBrush(color), thickness, points, options); } /// /// Draws the provided Points as a closed Linear Polygon with the provided Pen. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The pen. /// The points. - /// The . - public static Image DrawPolygon(this Image source, IPen pen, Vector2[] points) - where TColor : struct, IPixel + /// The . + public static Image DrawPolygon(this Image source, IPen pen, Vector2[] points) + where TPixel : struct, IPixel { return source.Draw(pen, new Polygon(new LinearLineSegment(points)), GraphicsOptions.Default); } @@ -97,14 +97,14 @@ namespace ImageSharp /// /// Draws the provided Points as a closed Linear Polygon with the provided Pen. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The pen. /// The points. /// The options. - /// The . - public static Image DrawPolygon(this Image source, IPen pen, Vector2[] points, GraphicsOptions options) - where TColor : struct, IPixel + /// The . + public static Image DrawPolygon(this Image source, IPen pen, Vector2[] points, GraphicsOptions options) + where TPixel : struct, IPixel { return source.Draw(pen, new Polygon(new LinearLineSegment(points)), options); } diff --git a/src/ImageSharp.Drawing/Paths/DrawRectangle.cs b/src/ImageSharp.Drawing/Paths/DrawRectangle.cs index b35665240..5514217ff 100644 --- a/src/ImageSharp.Drawing/Paths/DrawRectangle.cs +++ b/src/ImageSharp.Drawing/Paths/DrawRectangle.cs @@ -12,21 +12,21 @@ namespace ImageSharp using Drawing.Pens; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Draws the outline of the polygon with the provided pen. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The pen. /// The shape. /// The options. - /// The . - public static Image Draw(this Image source, IPen pen, Rectangle shape, GraphicsOptions options) - where TColor : struct, IPixel + /// The . + public static Image Draw(this Image source, IPen pen, Rectangle shape, GraphicsOptions options) + where TPixel : struct, IPixel { return source.Draw(pen, new SixLabors.Shapes.Rectangle(shape.X, shape.Y, shape.Width, shape.Height), options); } @@ -34,13 +34,13 @@ namespace ImageSharp /// /// Draws the outline of the polygon with the provided pen. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The pen. /// The shape. - /// The . - public static Image Draw(this Image source, IPen pen, Rectangle shape) - where TColor : struct, IPixel + /// The . + public static Image Draw(this Image source, IPen pen, Rectangle shape) + where TPixel : struct, IPixel { return source.Draw(pen, shape, GraphicsOptions.Default); } @@ -48,63 +48,63 @@ namespace ImageSharp /// /// Draws the outline of the polygon with the provided brush at the provided thickness. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The brush. /// The thickness. /// The shape. /// The options. - /// The . - public static Image Draw(this Image source, IBrush brush, float thickness, Rectangle shape, GraphicsOptions options) - where TColor : struct, IPixel + /// The . + public static Image Draw(this Image source, IBrush brush, float thickness, Rectangle shape, GraphicsOptions options) + where TPixel : struct, IPixel { - return source.Draw(new Pen(brush, thickness), shape, options); + return source.Draw(new Pen(brush, thickness), shape, options); } /// /// Draws the outline of the polygon with the provided brush at the provided thickness. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The brush. /// The thickness. /// The shape. - /// The . - public static Image Draw(this Image source, IBrush brush, float thickness, Rectangle shape) - where TColor : struct, IPixel + /// The . + public static Image Draw(this Image source, IBrush brush, float thickness, Rectangle shape) + where TPixel : struct, IPixel { - return source.Draw(new Pen(brush, thickness), shape); + return source.Draw(new Pen(brush, thickness), shape); } /// /// Draws the outline of the polygon with the provided brush at the provided thickness. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The color. /// The thickness. /// The shape. /// The options. - /// The . - public static Image Draw(this Image source, TColor color, float thickness, Rectangle shape, GraphicsOptions options) - where TColor : struct, IPixel + /// The . + public static Image Draw(this Image source, TPixel color, float thickness, Rectangle shape, GraphicsOptions options) + where TPixel : struct, IPixel { - return source.Draw(new SolidBrush(color), thickness, shape, options); + return source.Draw(new SolidBrush(color), thickness, shape, options); } /// /// Draws the outline of the polygon with the provided brush at the provided thickness. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The color. /// The thickness. /// The shape. - /// The . - public static Image Draw(this Image source, TColor color, float thickness, Rectangle shape) - where TColor : struct, IPixel + /// The . + public static Image Draw(this Image source, TPixel color, float thickness, Rectangle shape) + where TPixel : struct, IPixel { - return source.Draw(new SolidBrush(color), thickness, shape); + return source.Draw(new SolidBrush(color), thickness, shape); } } } diff --git a/src/ImageSharp.Drawing/Paths/FillPaths.cs b/src/ImageSharp.Drawing/Paths/FillPaths.cs index 92e227ce1..b4d0b14cb 100644 --- a/src/ImageSharp.Drawing/Paths/FillPaths.cs +++ b/src/ImageSharp.Drawing/Paths/FillPaths.cs @@ -13,21 +13,21 @@ namespace ImageSharp using SixLabors.Shapes; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Flood fills the image in the shape of the provided polygon with the specified brush.. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The brush. /// The shape. /// The graphics options. - /// The . - public static Image Fill(this Image source, IBrush brush, IPath path, GraphicsOptions options) - where TColor : struct, IPixel + /// The . + public static Image Fill(this Image source, IBrush brush, IPath path, GraphicsOptions options) + where TPixel : struct, IPixel { return source.Fill(brush, new ShapeRegion(path), options); } @@ -35,13 +35,13 @@ namespace ImageSharp /// /// Flood fills the image in the shape of the provided polygon with the specified brush. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The brush. /// The path. - /// The . - public static Image Fill(this Image source, IBrush brush, IPath path) - where TColor : struct, IPixel + /// The . + public static Image Fill(this Image source, IBrush brush, IPath path) + where TPixel : struct, IPixel { return source.Fill(brush, new ShapeRegion(path), GraphicsOptions.Default); } @@ -49,30 +49,30 @@ namespace ImageSharp /// /// Flood fills the image in the shape of the provided polygon with the specified brush.. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The color. /// The path. /// The options. - /// The . - public static Image Fill(this Image source, TColor color, IPath path, GraphicsOptions options) - where TColor : struct, IPixel + /// The . + public static Image Fill(this Image source, TPixel color, IPath path, GraphicsOptions options) + where TPixel : struct, IPixel { - return source.Fill(new SolidBrush(color), path, options); + return source.Fill(new SolidBrush(color), path, options); } /// /// Flood fills the image in the shape of the provided polygon with the specified brush.. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The color. /// The path. - /// The . - public static Image Fill(this Image source, TColor color, IPath path) - where TColor : struct, IPixel + /// The . + public static Image Fill(this Image source, TPixel color, IPath path) + where TPixel : struct, IPixel { - return source.Fill(new SolidBrush(color), path); + return source.Fill(new SolidBrush(color), path); } } } diff --git a/src/ImageSharp.Drawing/Paths/FillPolygon.cs b/src/ImageSharp.Drawing/Paths/FillPolygon.cs index cd3d15466..dfc56c5d2 100644 --- a/src/ImageSharp.Drawing/Paths/FillPolygon.cs +++ b/src/ImageSharp.Drawing/Paths/FillPolygon.cs @@ -13,21 +13,21 @@ namespace ImageSharp using SixLabors.Shapes; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Flood fills the image in the shape of a Linear polygon described by the points /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The brush. /// The points. /// The options. - /// The . - public static Image FillPolygon(this Image source, IBrush brush, Vector2[] points, GraphicsOptions options) - where TColor : struct, IPixel + /// The . + public static Image FillPolygon(this Image source, IBrush brush, Vector2[] points, GraphicsOptions options) + where TPixel : struct, IPixel { return source.Fill(brush, new Polygon(new LinearLineSegment(points)), options); } @@ -35,13 +35,13 @@ namespace ImageSharp /// /// Flood fills the image in the shape of a Linear polygon described by the points /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The brush. /// The points. - /// The . - public static Image FillPolygon(this Image source, IBrush brush, Vector2[] points) - where TColor : struct, IPixel + /// The . + public static Image FillPolygon(this Image source, IBrush brush, Vector2[] points) + where TPixel : struct, IPixel { return source.Fill(brush, new Polygon(new LinearLineSegment(points))); } @@ -49,30 +49,30 @@ namespace ImageSharp /// /// Flood fills the image in the shape of a Linear polygon described by the points /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The color. /// The points. /// The options. - /// The . - public static Image FillPolygon(this Image source, TColor color, Vector2[] points, GraphicsOptions options) - where TColor : struct, IPixel + /// The . + public static Image FillPolygon(this Image source, TPixel color, Vector2[] points, GraphicsOptions options) + where TPixel : struct, IPixel { - return source.Fill(new SolidBrush(color), new Polygon(new LinearLineSegment(points)), options); + return source.Fill(new SolidBrush(color), new Polygon(new LinearLineSegment(points)), options); } /// /// Flood fills the image in the shape of a Linear polygon described by the points /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The color. /// The points. - /// The . - public static Image FillPolygon(this Image source, TColor color, Vector2[] points) - where TColor : struct, IPixel + /// The . + public static Image FillPolygon(this Image source, TPixel color, Vector2[] points) + where TPixel : struct, IPixel { - return source.Fill(new SolidBrush(color), new Polygon(new LinearLineSegment(points))); + return source.Fill(new SolidBrush(color), new Polygon(new LinearLineSegment(points))); } } } diff --git a/src/ImageSharp.Drawing/Paths/FillRectangle.cs b/src/ImageSharp.Drawing/Paths/FillRectangle.cs index 1928e54d3..b20cb8971 100644 --- a/src/ImageSharp.Drawing/Paths/FillRectangle.cs +++ b/src/ImageSharp.Drawing/Paths/FillRectangle.cs @@ -11,21 +11,21 @@ namespace ImageSharp using Drawing.Brushes; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Flood fills the image in the shape of the provided polygon with the specified brush.. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The brush. /// The shape. /// The options. - /// The . - public static Image Fill(this Image source, IBrush brush, Rectangle shape, GraphicsOptions options) - where TColor : struct, IPixel + /// The . + public static Image Fill(this Image source, IBrush brush, Rectangle shape, GraphicsOptions options) + where TPixel : struct, IPixel { return source.Fill(brush, new SixLabors.Shapes.Rectangle(shape.X, shape.Y, shape.Width, shape.Height), options); } @@ -33,13 +33,13 @@ namespace ImageSharp /// /// Flood fills the image in the shape of the provided polygon with the specified brush.. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The brush. /// The shape. - /// The . - public static Image Fill(this Image source, IBrush brush, Rectangle shape) - where TColor : struct, IPixel + /// The . + public static Image Fill(this Image source, IBrush brush, Rectangle shape) + where TPixel : struct, IPixel { return source.Fill(brush, new SixLabors.Shapes.Rectangle(shape.X, shape.Y, shape.Width, shape.Height)); } @@ -47,30 +47,30 @@ namespace ImageSharp /// /// Flood fills the image in the shape of the provided polygon with the specified brush.. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The color. /// The shape. /// The options. - /// The . - public static Image Fill(this Image source, TColor color, Rectangle shape, GraphicsOptions options) - where TColor : struct, IPixel + /// The . + public static Image Fill(this Image source, TPixel color, Rectangle shape, GraphicsOptions options) + where TPixel : struct, IPixel { - return source.Fill(new SolidBrush(color), shape, options); + return source.Fill(new SolidBrush(color), shape, options); } /// /// Flood fills the image in the shape of the provided polygon with the specified brush.. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The color. /// The shape. - /// The . - public static Image Fill(this Image source, TColor color, Rectangle shape) - where TColor : struct, IPixel + /// The . + public static Image Fill(this Image source, TPixel color, Rectangle shape) + where TPixel : struct, IPixel { - return source.Fill(new SolidBrush(color), shape); + return source.Fill(new SolidBrush(color), shape); } } } diff --git a/src/ImageSharp.Drawing/Pens/IPen.cs b/src/ImageSharp.Drawing/Pens/IPen.cs index 72a5ffc36..573a126de 100644 --- a/src/ImageSharp.Drawing/Pens/IPen.cs +++ b/src/ImageSharp.Drawing/Pens/IPen.cs @@ -11,9 +11,9 @@ namespace ImageSharp.Drawing.Pens /// /// Interface representing a Pen /// - /// The type of the color. - public interface IPen - where TColor : struct, IPixel + /// The type of the color. + public interface IPen + where TPixel : struct, IPixel { /// /// Creates the applicator for applying this pen to an Image @@ -26,6 +26,6 @@ namespace ImageSharp.Drawing.Pens /// /// The when being applied to things like shapes would usually be the bounding box of the shape not necessarily the shape of the whole image. /// - PenApplicator CreateApplicator(PixelAccessor pixelSource, RectangleF region); + PenApplicator CreateApplicator(PixelAccessor pixelSource, RectangleF region); } } diff --git a/src/ImageSharp.Drawing/Pens/Pen.cs b/src/ImageSharp.Drawing/Pens/Pen.cs index 991ee14de..c3a530964 100644 --- a/src/ImageSharp.Drawing/Pens/Pen.cs +++ b/src/ImageSharp.Drawing/Pens/Pen.cs @@ -6,7 +6,7 @@ namespace ImageSharp.Drawing.Pens { /// - /// Represents a in the color space. + /// Represents a in the color space. /// public class Pen : Pen { diff --git a/src/ImageSharp.Drawing/Pens/Pens{TColor}.cs b/src/ImageSharp.Drawing/Pens/Pens{TPixel}.cs similarity index 68% rename from src/ImageSharp.Drawing/Pens/Pens{TColor}.cs rename to src/ImageSharp.Drawing/Pens/Pens{TPixel}.cs index 49eed370d..096262f44 100644 --- a/src/ImageSharp.Drawing/Pens/Pens{TColor}.cs +++ b/src/ImageSharp.Drawing/Pens/Pens{TPixel}.cs @@ -1,18 +1,16 @@ -// +// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // namespace ImageSharp.Drawing.Pens { - using System; - /// /// Common Pen styles /// - /// The type of the color. - public class Pens - where TColor : struct, IPixel + /// The type of the color. + public class Pens + where TPixel : struct, IPixel { private static readonly float[] DashDotPattern = new[] { 3f, 1f, 1f, 1f }; private static readonly float[] DashDotDotPattern = new[] { 3f, 1f, 1f, 1f, 1f, 1f }; @@ -25,8 +23,8 @@ namespace ImageSharp.Drawing.Pens /// The color. /// The width. /// The Pen - public static Pen Solid(TColor color, float width) - => new Pen(color, width); + public static Pen Solid(TPixel color, float width) + => new Pen(color, width); /// /// Create a solid pen with out any drawing patterns @@ -34,8 +32,8 @@ namespace ImageSharp.Drawing.Pens /// The brush. /// The width. /// The Pen - public static Pen Solid(IBrush brush, float width) - => new Pen(brush, width); + public static Pen Solid(IBrush brush, float width) + => new Pen(brush, width); /// /// Create a pen with a 'Dash' drawing patterns @@ -43,8 +41,8 @@ namespace ImageSharp.Drawing.Pens /// The color. /// The width. /// The Pen - public static Pen Dash(TColor color, float width) - => new Pen(color, width, DashedPattern); + public static Pen Dash(TPixel color, float width) + => new Pen(color, width, DashedPattern); /// /// Create a pen with a 'Dash' drawing patterns @@ -52,8 +50,8 @@ namespace ImageSharp.Drawing.Pens /// The brush. /// The width. /// The Pen - public static Pen Dash(IBrush brush, float width) - => new Pen(brush, width, DashedPattern); + public static Pen Dash(IBrush brush, float width) + => new Pen(brush, width, DashedPattern); /// /// Create a pen with a 'Dot' drawing patterns @@ -61,8 +59,8 @@ namespace ImageSharp.Drawing.Pens /// The color. /// The width. /// The Pen - public static Pen Dot(TColor color, float width) - => new Pen(color, width, DottedPattern); + public static Pen Dot(TPixel color, float width) + => new Pen(color, width, DottedPattern); /// /// Create a pen with a 'Dot' drawing patterns @@ -70,8 +68,8 @@ namespace ImageSharp.Drawing.Pens /// The brush. /// The width. /// The Pen - public static Pen Dot(IBrush brush, float width) - => new Pen(brush, width, DottedPattern); + public static Pen Dot(IBrush brush, float width) + => new Pen(brush, width, DottedPattern); /// /// Create a pen with a 'Dash Dot' drawing patterns @@ -79,8 +77,8 @@ namespace ImageSharp.Drawing.Pens /// The color. /// The width. /// The Pen - public static Pen DashDot(TColor color, float width) - => new Pen(color, width, DashDotPattern); + public static Pen DashDot(TPixel color, float width) + => new Pen(color, width, DashDotPattern); /// /// Create a pen with a 'Dash Dot' drawing patterns @@ -88,8 +86,8 @@ namespace ImageSharp.Drawing.Pens /// The brush. /// The width. /// The Pen - public static Pen DashDot(IBrush brush, float width) - => new Pen(brush, width, DashDotPattern); + public static Pen DashDot(IBrush brush, float width) + => new Pen(brush, width, DashDotPattern); /// /// Create a pen with a 'Dash Dot Dot' drawing patterns @@ -97,8 +95,8 @@ namespace ImageSharp.Drawing.Pens /// The color. /// The width. /// The Pen - public static Pen DashDotDot(TColor color, float width) - => new Pen(color, width, DashDotDotPattern); + public static Pen DashDotDot(TPixel color, float width) + => new Pen(color, width, DashDotDotPattern); /// /// Create a pen with a 'Dash Dot Dot' drawing patterns @@ -106,7 +104,7 @@ namespace ImageSharp.Drawing.Pens /// The brush. /// The width. /// The Pen - public static Pen DashDotDot(IBrush brush, float width) - => new Pen(brush, width, DashDotDotPattern); + public static Pen DashDotDot(IBrush brush, float width) + => new Pen(brush, width, DashDotDotPattern); } } \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Pens/Pen{TColor}.cs b/src/ImageSharp.Drawing/Pens/Pen{TPixel}.cs similarity index 81% rename from src/ImageSharp.Drawing/Pens/Pen{TColor}.cs rename to src/ImageSharp.Drawing/Pens/Pen{TPixel}.cs index e3716124e..05af44ca3 100644 --- a/src/ImageSharp.Drawing/Pens/Pen{TColor}.cs +++ b/src/ImageSharp.Drawing/Pens/Pen{TPixel}.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // @@ -14,7 +14,7 @@ namespace ImageSharp.Drawing.Pens /// /// Provides a pen that can apply a pattern to a line with a set brush and thickness /// - /// The type of the color. + /// The type of the color. /// /// The pattern will be in to the form of new float[]{ 1f, 2f, 0.5f} this will be /// converted into a pattern that is 3.5 times longer that the width with 3 sections @@ -23,30 +23,30 @@ namespace ImageSharp.Drawing.Pens /// section 3 will be width/2 long and will be filled /// the the pattern will imidiatly repeat without gap. /// - public class Pen : IPen - where TColor : struct, IPixel + public class Pen : IPen + where TPixel : struct, IPixel { private static readonly float[] EmptyPattern = new float[0]; private readonly float[] pattern; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The color. /// The width. /// The pattern. - public Pen(TColor color, float width, float[] pattern) - : this(new SolidBrush(color), width, pattern) + public Pen(TPixel color, float width, float[] pattern) + : this(new SolidBrush(color), width, pattern) { } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The brush. /// The width. /// The pattern. - public Pen(IBrush brush, float width, float[] pattern) + public Pen(IBrush brush, float width, float[] pattern) { this.Brush = brush; this.Width = width; @@ -54,30 +54,30 @@ namespace ImageSharp.Drawing.Pens } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The color. /// The width. - public Pen(TColor color, float width) - : this(new SolidBrush(color), width) + public Pen(TPixel color, float width) + : this(new SolidBrush(color), width) { } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The brush. /// The width. - public Pen(IBrush brush, float width) + public Pen(IBrush brush, float width) : this(brush, width, EmptyPattern) { } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The pen. - internal Pen(Pen pen) + internal Pen(Pen pen) : this(pen.Brush, pen.Width, pen.pattern) { } @@ -88,7 +88,7 @@ namespace ImageSharp.Drawing.Pens /// /// The brush. /// - public IBrush Brush { get; } + public IBrush Brush { get; } /// /// Gets the width. @@ -110,7 +110,7 @@ namespace ImageSharp.Drawing.Pens /// The when being applied to things like shapes would ussually be the /// bounding box of the shape not necorserrally the shape of the whole image /// - public PenApplicator CreateApplicator(PixelAccessor sourcePixels, RectangleF region) + public PenApplicator CreateApplicator(PixelAccessor sourcePixels, RectangleF region) { if (this.pattern == null || this.pattern.Length < 2) { @@ -122,12 +122,12 @@ namespace ImageSharp.Drawing.Pens return new PatternPenApplicator(sourcePixels, this.Brush, region, this.Width, this.pattern); } - private class SolidPenApplicator : PenApplicator + private class SolidPenApplicator : PenApplicator { - private readonly BrushApplicator brush; + private readonly BrushApplicator brush; private readonly float halfWidth; - public SolidPenApplicator(PixelAccessor sourcePixels, IBrush brush, RectangleF region, float width) + public SolidPenApplicator(PixelAccessor sourcePixels, IBrush brush, RectangleF region, float width) { this.brush = brush.CreateApplicator(sourcePixels, region); this.halfWidth = width / 2; @@ -144,9 +144,9 @@ namespace ImageSharp.Drawing.Pens this.brush.Dispose(); } - public override ColoredPointInfo GetColor(int x, int y, PointInfo info) + public override ColoredPointInfo GetColor(int x, int y, PointInfo info) { - ColoredPointInfo result = default(ColoredPointInfo); + ColoredPointInfo result = default(ColoredPointInfo); result.Color = this.brush[x, y]; if (info.DistanceFromPath < this.halfWidth) @@ -163,14 +163,14 @@ namespace ImageSharp.Drawing.Pens } } - private class PatternPenApplicator : PenApplicator + private class PatternPenApplicator : PenApplicator { - private readonly BrushApplicator brush; + private readonly BrushApplicator brush; private readonly float halfWidth; private readonly float[] pattern; private readonly float totalLength; - public PatternPenApplicator(PixelAccessor sourcePixels, IBrush brush, RectangleF region, float width, float[] pattern) + public PatternPenApplicator(PixelAccessor sourcePixels, IBrush brush, RectangleF region, float width, float[] pattern) { this.brush = brush.CreateApplicator(sourcePixels, region); this.halfWidth = width / 2; @@ -197,16 +197,16 @@ namespace ImageSharp.Drawing.Pens this.brush.Dispose(); } - public override ColoredPointInfo GetColor(int x, int y, PointInfo info) + public override ColoredPointInfo GetColor(int x, int y, PointInfo info) { - ColoredPointInfo infoResult = default(ColoredPointInfo); + ColoredPointInfo infoResult = default(ColoredPointInfo); infoResult.DistanceFromElement = float.MaxValue; // is really outside the element float length = info.DistanceAlongPath % this.totalLength; // we can treat the DistanceAlongPath and DistanceFromPath as x,y coords for the pattern // we need to calcualte the distance from the outside edge of the pattern - // and set them on the ColoredPointInfo along with the color. + // and set them on the ColoredPointInfo along with the color. infoResult.Color = this.brush[x, y]; float distanceWAway = 0; diff --git a/src/ImageSharp.Drawing/Pens/Processors/ColoredPointInfo.cs b/src/ImageSharp.Drawing/Pens/Processors/ColoredPointInfo.cs index d042bdccb..edee5bb19 100644 --- a/src/ImageSharp.Drawing/Pens/Processors/ColoredPointInfo.cs +++ b/src/ImageSharp.Drawing/Pens/Processors/ColoredPointInfo.cs @@ -10,14 +10,14 @@ namespace ImageSharp.Drawing.Processors /// /// Returns details about how far away from the inside of a shape and the color the pixel could be. /// - /// The type of the color. - public struct ColoredPointInfo - where TColor : struct, IPixel + /// The type of the color. + public struct ColoredPointInfo + where TPixel : struct, IPixel { /// /// The color /// - public TColor Color; + public TPixel Color; /// /// The distance from element diff --git a/src/ImageSharp.Drawing/Pens/Processors/PenApplicator.cs b/src/ImageSharp.Drawing/Pens/Processors/PenApplicator.cs index 8cdb04b45..7e9671cac 100644 --- a/src/ImageSharp.Drawing/Pens/Processors/PenApplicator.cs +++ b/src/ImageSharp.Drawing/Pens/Processors/PenApplicator.cs @@ -11,9 +11,9 @@ namespace ImageSharp.Drawing.Processors /// /// primitive that converts a into a color and a distance away from the drawable part of the path. /// - /// The type of the color. - public abstract class PenApplicator : IDisposable - where TColor : struct, IPixel + /// The type of the color. + public abstract class PenApplicator : IDisposable + where TPixel : struct, IPixel { /// /// Gets the required region. @@ -27,7 +27,7 @@ namespace ImageSharp.Drawing.Processors public abstract void Dispose(); /// - /// Gets a from a point represented by a . + /// Gets a from a point represented by a . /// /// The x. /// The y. @@ -35,6 +35,6 @@ namespace ImageSharp.Drawing.Processors /// /// Returns the color details and distance from a solid bit of the line. /// - public abstract ColoredPointInfo GetColor(int x, int y, PointInfo info); + public abstract ColoredPointInfo GetColor(int x, int y, PointInfo info); } } diff --git a/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs b/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs index c67ba0370..9bb452f19 100644 --- a/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs +++ b/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs @@ -14,18 +14,18 @@ namespace ImageSharp.Drawing.Processors /// /// Combines two images together by blending the pixels. /// - /// The pixel format. - internal class DrawImageProcessor : ImageProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class DrawImageProcessor : ImageProcessor + where TPixel : struct, IPixel { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The image to blend with the currently processing image. /// The size to draw the blended image. /// The location to draw the blended image. /// The opacity of the image to blend. Between 0 and 100. - public DrawImageProcessor(Image image, Size size, Point location, int alpha = 100) + public DrawImageProcessor(Image image, Size size, Point location, int alpha = 100) { Guard.MustBeBetweenOrEqualTo(alpha, 0, 100, nameof(alpha)); this.Image = image; @@ -37,7 +37,7 @@ namespace ImageSharp.Drawing.Processors /// /// Gets the image to blend. /// - public Image Image { get; private set; } + public Image Image { get; private set; } /// /// Gets the alpha percentage value. @@ -55,7 +55,7 @@ namespace ImageSharp.Drawing.Processors public Point Location { get; } /// - protected override void OnApply(ImageBase source, Rectangle sourceRectangle) + protected override void OnApply(ImageBase source, Rectangle sourceRectangle) { if (this.Image.Bounds.Size != this.Size) { @@ -72,8 +72,8 @@ namespace ImageSharp.Drawing.Processors float alpha = this.Alpha / 100F; - using (PixelAccessor toBlendPixels = this.Image.Lock()) - using (PixelAccessor sourcePixels = source.Lock()) + using (PixelAccessor toBlendPixels = this.Image.Lock()) + using (PixelAccessor sourcePixels = source.Lock()) { Parallel.For( minY, @@ -89,7 +89,7 @@ namespace ImageSharp.Drawing.Processors // Lerping colors is dependent on the alpha of the blended color backgroundVector = Vector4BlendTransforms.PremultipliedLerp(backgroundVector, sourceVector, alpha); - TColor packed = default(TColor); + TPixel packed = default(TPixel); packed.PackFromVector4(backgroundVector); sourcePixels[x, y] = packed; } diff --git a/src/ImageSharp.Drawing/Processors/DrawPathProcessor.cs b/src/ImageSharp.Drawing/Processors/DrawPathProcessor.cs index 89ba0968b..32e44bce9 100644 --- a/src/ImageSharp.Drawing/Processors/DrawPathProcessor.cs +++ b/src/ImageSharp.Drawing/Processors/DrawPathProcessor.cs @@ -15,21 +15,21 @@ namespace ImageSharp.Drawing.Processors /// /// Draws a path using the processor pipeline /// - /// The type of the color. - /// - internal class DrawPathProcessor : ImageProcessor - where TColor : struct, IPixel + /// The type of the color. + /// + internal class DrawPathProcessor : ImageProcessor + where TPixel : struct, IPixel { private const float AntialiasFactor = 1f; private const int PaddingFactor = 1; // needs to been the same or greater than AntialiasFactor /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The details how to draw the outline/path. /// The details of the paths and outlines to draw. /// The drawing configuration options. - public DrawPathProcessor(IPen pen, Drawable drawable, GraphicsOptions options) + public DrawPathProcessor(IPen pen, Drawable drawable, GraphicsOptions options) { this.Path = drawable; this.Pen = pen; @@ -44,7 +44,7 @@ namespace ImageSharp.Drawing.Processors /// /// Gets the pen. /// - public IPen Pen { get; } + public IPen Pen { get; } /// /// Gets the path. @@ -52,10 +52,10 @@ namespace ImageSharp.Drawing.Processors public Drawable Path { get; } /// - protected override void OnApply(ImageBase source, Rectangle sourceRectangle) + protected override void OnApply(ImageBase source, Rectangle sourceRectangle) { - using (PixelAccessor sourcePixels = source.Lock()) - using (PenApplicator applicator = this.Pen.CreateApplicator(sourcePixels, this.Path.Bounds)) + using (PixelAccessor sourcePixels = source.Lock()) + using (PenApplicator applicator = this.Pen.CreateApplicator(sourcePixels, this.Path.Bounds)) { Rectangle rect = RectangleF.Ceiling(applicator.RequiredRegion); @@ -100,7 +100,7 @@ namespace ImageSharp.Drawing.Processors int offsetX = x - startX; PointInfo info = this.Path.GetPointInfo(offsetX, offsetY); - ColoredPointInfo color = applicator.GetColor(offsetX, offsetY, info); + ColoredPointInfo color = applicator.GetColor(offsetX, offsetY, info); float opacity = this.Opacity(color.DistanceFromElement); @@ -111,7 +111,7 @@ namespace ImageSharp.Drawing.Processors Vector4 finalColor = Vector4BlendTransforms.PremultipliedLerp(backgroundVector, sourceVector, opacity); - TColor packed = default(TColor); + TPixel packed = default(TPixel); packed.PackFromVector4(finalColor); sourcePixels[offsetX, offsetY] = packed; } diff --git a/src/ImageSharp.Drawing/Processors/FillProcessor.cs b/src/ImageSharp.Drawing/Processors/FillProcessor.cs index 635829e9f..d0ad0cc1d 100644 --- a/src/ImageSharp.Drawing/Processors/FillProcessor.cs +++ b/src/ImageSharp.Drawing/Processors/FillProcessor.cs @@ -15,26 +15,26 @@ namespace ImageSharp.Drawing.Processors /// /// Using the bursh as a source of pixels colors blends the brush color with source. /// - /// The pixel format. - internal class FillProcessor : ImageProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class FillProcessor : ImageProcessor + where TPixel : struct, IPixel { /// /// The brush. /// - private readonly IBrush brush; + private readonly IBrush brush; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The brush to source pixel colors from. - public FillProcessor(IBrush brush) + public FillProcessor(IBrush brush) { this.brush = brush; } /// - protected override void OnApply(ImageBase source, Rectangle sourceRectangle) + protected override void OnApply(ImageBase source, Rectangle sourceRectangle) { int startX = sourceRectangle.X; int endX = sourceRectangle.Right; @@ -59,10 +59,10 @@ namespace ImageSharp.Drawing.Processors } // we could possibly do some optermising by having knowledge about the individual brushes operate - // for example If brush is SolidBrush then we could just get the color upfront - // and skip using the IBrushApplicator?. - using (PixelAccessor sourcePixels = source.Lock()) - using (BrushApplicator applicator = this.brush.CreateApplicator(sourcePixels, sourceRectangle)) + // for example If brush is SolidBrush then we could just get the color upfront + // and skip using the IBrushApplicator?. + using (PixelAccessor sourcePixels = source.Lock()) + using (BrushApplicator applicator = this.brush.CreateApplicator(sourcePixels, sourceRectangle)) { Parallel.For( minY, @@ -80,7 +80,7 @@ namespace ImageSharp.Drawing.Processors Vector4 finalColor = Vector4BlendTransforms.PremultipliedLerp(backgroundVector, sourceVector, 1); - TColor packed = default(TColor); + TPixel packed = default(TPixel); packed.PackFromVector4(finalColor); sourcePixels[offsetX, offsetY] = packed; } diff --git a/src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs b/src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs index 80a3e6793..88830f094 100644 --- a/src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs +++ b/src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs @@ -15,21 +15,21 @@ namespace ImageSharp.Drawing.Processors /// /// Usinf a brsuh and a shape fills shape with contents of brush the /// - /// The type of the color. - /// - internal class FillRegionProcessor : ImageProcessor - where TColor : struct, IPixel + /// The type of the color. + /// + internal class FillRegionProcessor : ImageProcessor + where TPixel : struct, IPixel { private const float AntialiasFactor = 1f; private const int DrawPadding = 1; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The details how to fill the region of interest. /// The region of interest to be filled. /// The configuration options. - public FillRegionProcessor(IBrush brush, Region region, GraphicsOptions options) + public FillRegionProcessor(IBrush brush, Region region, GraphicsOptions options) { this.Region = region; this.Brush = brush; @@ -39,7 +39,7 @@ namespace ImageSharp.Drawing.Processors /// /// Gets the brush. /// - public IBrush Brush { get; } + public IBrush Brush { get; } /// /// Gets the region that this processor applies to. @@ -55,7 +55,7 @@ namespace ImageSharp.Drawing.Processors public GraphicsOptions Options { get; } /// - protected override void OnApply(ImageBase source, Rectangle sourceRectangle) + protected override void OnApply(ImageBase source, Rectangle sourceRectangle) { Region region = this.Region; Rectangle rect = region.Bounds; @@ -88,8 +88,8 @@ namespace ImageSharp.Drawing.Processors } } - using (PixelAccessor sourcePixels = source.Lock()) - using (BrushApplicator applicator = this.Brush.CreateApplicator(sourcePixels, rect)) + using (PixelAccessor sourcePixels = source.Lock()) + using (BrushApplicator applicator = this.Brush.CreateApplicator(sourcePixels, rect)) { float[] buffer = arrayPool.Rent(maxIntersections); int scanlineWidth = maxX - minX; diff --git a/src/ImageSharp.Drawing/Text/DrawText.cs b/src/ImageSharp.Drawing/Text/DrawText.cs index eba11b5c5..93486e2bb 100644 --- a/src/ImageSharp.Drawing/Text/DrawText.cs +++ b/src/ImageSharp.Drawing/Text/DrawText.cs @@ -14,7 +14,7 @@ namespace ImageSharp using SixLabors.Fonts; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { @@ -23,17 +23,17 @@ namespace ImageSharp /// /// Draws the text onto the the image filled via the brush. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The text. /// The font. /// The color. /// The location. /// - /// The . + /// The . /// - public static Image DrawText(this Image source, string text, Font font, TColor color, Vector2 location) - where TColor : struct, IPixel + public static Image DrawText(this Image source, string text, Font font, TPixel color, Vector2 location) + where TPixel : struct, IPixel { return source.DrawText(text, font, color, location, TextGraphicsOptions.Default); } @@ -41,7 +41,7 @@ namespace ImageSharp /// /// Draws the text onto the the image filled via the brush. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The text. /// The font. @@ -49,28 +49,28 @@ namespace ImageSharp /// The location. /// The options. /// - /// The . + /// The . /// - public static Image DrawText(this Image source, string text, Font font, TColor color, Vector2 location, TextGraphicsOptions options) - where TColor : struct, IPixel + public static Image DrawText(this Image source, string text, Font font, TPixel color, Vector2 location, TextGraphicsOptions options) + where TPixel : struct, IPixel { - return source.DrawText(text, font, Brushes.Solid(color), null, location, options); + return source.DrawText(text, font, Brushes.Solid(color), null, location, options); } /// /// Draws the text onto the the image filled via the brush. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The text. /// The font. /// The brush. /// The location. /// - /// The . + /// The . /// - public static Image DrawText(this Image source, string text, Font font, IBrush brush, Vector2 location) - where TColor : struct, IPixel + public static Image DrawText(this Image source, string text, Font font, IBrush brush, Vector2 location) + where TPixel : struct, IPixel { return source.DrawText(text, font, brush, location, TextGraphicsOptions.Default); } @@ -78,7 +78,7 @@ namespace ImageSharp /// /// Draws the text onto the the image filled via the brush. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The text. /// The font. @@ -86,10 +86,10 @@ namespace ImageSharp /// The location. /// The options. /// - /// The . + /// The . /// - public static Image DrawText(this Image source, string text, Font font, IBrush brush, Vector2 location, TextGraphicsOptions options) - where TColor : struct, IPixel + public static Image DrawText(this Image source, string text, Font font, IBrush brush, Vector2 location, TextGraphicsOptions options) + where TPixel : struct, IPixel { return source.DrawText(text, font, brush, null, location, options); } @@ -97,17 +97,17 @@ namespace ImageSharp /// /// Draws the text onto the the image outlined via the pen. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The text. /// The font. /// The pen. /// The location. /// - /// The . + /// The . /// - public static Image DrawText(this Image source, string text, Font font, IPen pen, Vector2 location) - where TColor : struct, IPixel + public static Image DrawText(this Image source, string text, Font font, IPen pen, Vector2 location) + where TPixel : struct, IPixel { return source.DrawText(text, font, pen, location, TextGraphicsOptions.Default); } @@ -115,7 +115,7 @@ namespace ImageSharp /// /// Draws the text onto the the image outlined via the pen. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The text. /// The font. @@ -123,10 +123,10 @@ namespace ImageSharp /// The location. /// The options. /// - /// The . + /// The . /// - public static Image DrawText(this Image source, string text, Font font, IPen pen, Vector2 location, TextGraphicsOptions options) - where TColor : struct, IPixel + public static Image DrawText(this Image source, string text, Font font, IPen pen, Vector2 location, TextGraphicsOptions options) + where TPixel : struct, IPixel { return source.DrawText(text, font, null, pen, location, options); } @@ -134,7 +134,7 @@ namespace ImageSharp /// /// Draws the text onto the the image filled via the brush then outlined via the pen. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The text. /// The font. @@ -142,10 +142,10 @@ namespace ImageSharp /// The pen. /// The location. /// - /// The . + /// The . /// - public static Image DrawText(this Image source, string text, Font font, IBrush brush, IPen pen, Vector2 location) - where TColor : struct, IPixel + public static Image DrawText(this Image source, string text, Font font, IBrush brush, IPen pen, Vector2 location) + where TPixel : struct, IPixel { return source.DrawText(text, font, brush, pen, location, TextGraphicsOptions.Default); } @@ -153,7 +153,7 @@ namespace ImageSharp /// /// Draws the text onto the the image filled via the brush then outlined via the pen. /// - /// The type of the color. + /// The type of the color. /// The image this method extends. /// The text. /// The font. @@ -162,10 +162,10 @@ namespace ImageSharp /// The location. /// The options. /// - /// The . + /// The . /// - public static Image DrawText(this Image source, string text, Font font, IBrush brush, IPen pen, Vector2 location, TextGraphicsOptions options) - where TColor : struct, IPixel + public static Image DrawText(this Image source, string text, Font font, IBrush brush, IPen pen, Vector2 location, TextGraphicsOptions options) + where TPixel : struct, IPixel { GlyphBuilder glyphBuilder = new GlyphBuilder(location); diff --git a/src/ImageSharp/Colors/ColorBuilder{TColor}.cs b/src/ImageSharp/Colors/ColorBuilder{TPixel}.cs similarity index 78% rename from src/ImageSharp/Colors/ColorBuilder{TColor}.cs rename to src/ImageSharp/Colors/ColorBuilder{TPixel}.cs index f60b5c8c0..3021cb39e 100644 --- a/src/ImageSharp/Colors/ColorBuilder{TColor}.cs +++ b/src/ImageSharp/Colors/ColorBuilder{TPixel}.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // @@ -11,19 +11,19 @@ namespace ImageSharp /// /// A set of named colors mapped to the provided Color space. /// - /// The type of the color. - public static class ColorBuilder - where TColor : struct, IPixel + /// The type of the color. + public static class ColorBuilder + where TPixel : struct, IPixel { /// - /// Creates a new representation from the string representing a color. + /// Creates a new representation from the string representing a color. /// /// /// The hexadecimal representation of the combined color components arranged /// in rgb, rgba, rrggbb, or rrggbbaa format to match web syntax. /// - /// Returns a that represents the color defined by the provided RGBA heax string. - public static TColor FromHex(string hex) + /// Returns a that represents the color defined by the provided RGBA heax string. + public static TPixel FromHex(string hex) { Guard.NotNullOrEmpty(hex, nameof(hex)); @@ -34,7 +34,7 @@ namespace ImageSharp throw new ArgumentException("Hexadecimal string is not in the correct format.", nameof(hex)); } - TColor result = default(TColor); + TPixel result = default(TPixel); result.PackFromBytes( (byte)(packedValue >> 24), @@ -45,30 +45,30 @@ namespace ImageSharp } /// - /// Creates a new representation from standard RGB bytes with 100% opacity. + /// Creates a new representation from standard RGB bytes with 100% opacity. /// /// The red intensity. /// The green intensity. /// The blue intensity. - /// Returns a that represents the color defined by the provided RGB values with 100% opacity. - public static TColor FromRGB(byte red, byte green, byte blue) + /// Returns a that represents the color defined by the provided RGB values with 100% opacity. + public static TPixel FromRGB(byte red, byte green, byte blue) { - TColor color = default(TColor); + TPixel color = default(TPixel); color.PackFromBytes(red, green, blue, 255); return color; } /// - /// Creates a new representation from standard RGBA bytes. + /// Creates a new representation from standard RGBA bytes. /// /// The red intensity. /// The green intensity. /// The blue intensity. /// The alpha intensity. - /// Returns a that represents the color defined by the provided RGBA values. - public static TColor FromRGBA(byte red, byte green, byte blue, byte alpha) + /// Returns a that represents the color defined by the provided RGBA values. + public static TPixel FromRGBA(byte red, byte green, byte blue, byte alpha) { - TColor color = default(TColor); + TPixel color = default(TPixel); color.PackFromBytes(red, green, blue, alpha); return color; } diff --git a/src/ImageSharp/Colors/NamedColors{TColor}.cs b/src/ImageSharp/Colors/NamedColors{TColor}.cs deleted file mode 100644 index 274ab0562..000000000 --- a/src/ImageSharp/Colors/NamedColors{TColor}.cs +++ /dev/null @@ -1,725 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp -{ - /// - /// A set of named colors mapped to the provided color space. - /// - /// The type of the color. - public static class NamedColors - where TColor : struct, IPixel - { - /// - /// Represents a matching the W3C definition that has an hex value of #F0F8FF. - /// - public static readonly TColor AliceBlue = ColorBuilder.FromRGBA(240, 248, 255, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FAEBD7. - /// - public static readonly TColor AntiqueWhite = ColorBuilder.FromRGBA(250, 235, 215, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #00FFFF. - /// - public static readonly TColor Aqua = ColorBuilder.FromRGBA(0, 255, 255, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #7FFFD4. - /// - public static readonly TColor Aquamarine = ColorBuilder.FromRGBA(127, 255, 212, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #F0FFFF. - /// - public static readonly TColor Azure = ColorBuilder.FromRGBA(240, 255, 255, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #F5F5DC. - /// - public static readonly TColor Beige = ColorBuilder.FromRGBA(245, 245, 220, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FFE4C4. - /// - public static readonly TColor Bisque = ColorBuilder.FromRGBA(255, 228, 196, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #000000. - /// - public static readonly TColor Black = ColorBuilder.FromRGBA(0, 0, 0, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FFEBCD. - /// - public static readonly TColor BlanchedAlmond = ColorBuilder.FromRGBA(255, 235, 205, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #0000FF. - /// - public static readonly TColor Blue = ColorBuilder.FromRGBA(0, 0, 255, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #8A2BE2. - /// - public static readonly TColor BlueViolet = ColorBuilder.FromRGBA(138, 43, 226, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #A52A2A. - /// - public static readonly TColor Brown = ColorBuilder.FromRGBA(165, 42, 42, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #DEB887. - /// - public static readonly TColor BurlyWood = ColorBuilder.FromRGBA(222, 184, 135, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #5F9EA0. - /// - public static readonly TColor CadetBlue = ColorBuilder.FromRGBA(95, 158, 160, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #7FFF00. - /// - public static readonly TColor Chartreuse = ColorBuilder.FromRGBA(127, 255, 0, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #D2691E. - /// - public static readonly TColor Chocolate = ColorBuilder.FromRGBA(210, 105, 30, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FF7F50. - /// - public static readonly TColor Coral = ColorBuilder.FromRGBA(255, 127, 80, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #6495ED. - /// - public static readonly TColor CornflowerBlue = ColorBuilder.FromRGBA(100, 149, 237, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FFF8DC. - /// - public static readonly TColor Cornsilk = ColorBuilder.FromRGBA(255, 248, 220, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #DC143C. - /// - public static readonly TColor Crimson = ColorBuilder.FromRGBA(220, 20, 60, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #00FFFF. - /// - public static readonly TColor Cyan = ColorBuilder.FromRGBA(0, 255, 255, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #00008B. - /// - public static readonly TColor DarkBlue = ColorBuilder.FromRGBA(0, 0, 139, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #008B8B. - /// - public static readonly TColor DarkCyan = ColorBuilder.FromRGBA(0, 139, 139, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #B8860B. - /// - public static readonly TColor DarkGoldenrod = ColorBuilder.FromRGBA(184, 134, 11, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #A9A9A9. - /// - public static readonly TColor DarkGray = ColorBuilder.FromRGBA(169, 169, 169, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #006400. - /// - public static readonly TColor DarkGreen = ColorBuilder.FromRGBA(0, 100, 0, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #BDB76B. - /// - public static readonly TColor DarkKhaki = ColorBuilder.FromRGBA(189, 183, 107, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #8B008B. - /// - public static readonly TColor DarkMagenta = ColorBuilder.FromRGBA(139, 0, 139, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #556B2F. - /// - public static readonly TColor DarkOliveGreen = ColorBuilder.FromRGBA(85, 107, 47, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FF8C00. - /// - public static readonly TColor DarkOrange = ColorBuilder.FromRGBA(255, 140, 0, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #9932CC. - /// - public static readonly TColor DarkOrchid = ColorBuilder.FromRGBA(153, 50, 204, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #8B0000. - /// - public static readonly TColor DarkRed = ColorBuilder.FromRGBA(139, 0, 0, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #E9967A. - /// - public static readonly TColor DarkSalmon = ColorBuilder.FromRGBA(233, 150, 122, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #8FBC8B. - /// - public static readonly TColor DarkSeaGreen = ColorBuilder.FromRGBA(143, 188, 139, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #483D8B. - /// - public static readonly TColor DarkSlateBlue = ColorBuilder.FromRGBA(72, 61, 139, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #2F4F4F. - /// - public static readonly TColor DarkSlateGray = ColorBuilder.FromRGBA(47, 79, 79, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #00CED1. - /// - public static readonly TColor DarkTurquoise = ColorBuilder.FromRGBA(0, 206, 209, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #9400D3. - /// - public static readonly TColor DarkViolet = ColorBuilder.FromRGBA(148, 0, 211, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FF1493. - /// - public static readonly TColor DeepPink = ColorBuilder.FromRGBA(255, 20, 147, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #00BFFF. - /// - public static readonly TColor DeepSkyBlue = ColorBuilder.FromRGBA(0, 191, 255, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #696969. - /// - public static readonly TColor DimGray = ColorBuilder.FromRGBA(105, 105, 105, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #1E90FF. - /// - public static readonly TColor DodgerBlue = ColorBuilder.FromRGBA(30, 144, 255, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #B22222. - /// - public static readonly TColor Firebrick = ColorBuilder.FromRGBA(178, 34, 34, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FFFAF0. - /// - public static readonly TColor FloralWhite = ColorBuilder.FromRGBA(255, 250, 240, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #228B22. - /// - public static readonly TColor ForestGreen = ColorBuilder.FromRGBA(34, 139, 34, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FF00FF. - /// - public static readonly TColor Fuchsia = ColorBuilder.FromRGBA(255, 0, 255, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #DCDCDC. - /// - public static readonly TColor Gainsboro = ColorBuilder.FromRGBA(220, 220, 220, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #F8F8FF. - /// - public static readonly TColor GhostWhite = ColorBuilder.FromRGBA(248, 248, 255, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FFD700. - /// - public static readonly TColor Gold = ColorBuilder.FromRGBA(255, 215, 0, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #DAA520. - /// - public static readonly TColor Goldenrod = ColorBuilder.FromRGBA(218, 165, 32, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #808080. - /// - public static readonly TColor Gray = ColorBuilder.FromRGBA(128, 128, 128, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #008000. - /// - public static readonly TColor Green = ColorBuilder.FromRGBA(0, 128, 0, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #ADFF2F. - /// - public static readonly TColor GreenYellow = ColorBuilder.FromRGBA(173, 255, 47, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #F0FFF0. - /// - public static readonly TColor Honeydew = ColorBuilder.FromRGBA(240, 255, 240, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FF69B4. - /// - public static readonly TColor HotPink = ColorBuilder.FromRGBA(255, 105, 180, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #CD5C5C. - /// - public static readonly TColor IndianRed = ColorBuilder.FromRGBA(205, 92, 92, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #4B0082. - /// - public static readonly TColor Indigo = ColorBuilder.FromRGBA(75, 0, 130, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FFFFF0. - /// - public static readonly TColor Ivory = ColorBuilder.FromRGBA(255, 255, 240, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #F0E68C. - /// - public static readonly TColor Khaki = ColorBuilder.FromRGBA(240, 230, 140, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #E6E6FA. - /// - public static readonly TColor Lavender = ColorBuilder.FromRGBA(230, 230, 250, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FFF0F5. - /// - public static readonly TColor LavenderBlush = ColorBuilder.FromRGBA(255, 240, 245, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #7CFC00. - /// - public static readonly TColor LawnGreen = ColorBuilder.FromRGBA(124, 252, 0, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FFFACD. - /// - public static readonly TColor LemonChiffon = ColorBuilder.FromRGBA(255, 250, 205, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #ADD8E6. - /// - public static readonly TColor LightBlue = ColorBuilder.FromRGBA(173, 216, 230, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #F08080. - /// - public static readonly TColor LightCoral = ColorBuilder.FromRGBA(240, 128, 128, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #E0FFFF. - /// - public static readonly TColor LightCyan = ColorBuilder.FromRGBA(224, 255, 255, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FAFAD2. - /// - public static readonly TColor LightGoldenrodYellow = ColorBuilder.FromRGBA(250, 250, 210, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #D3D3D3. - /// - public static readonly TColor LightGray = ColorBuilder.FromRGBA(211, 211, 211, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #90EE90. - /// - public static readonly TColor LightGreen = ColorBuilder.FromRGBA(144, 238, 144, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FFB6C1. - /// - public static readonly TColor LightPink = ColorBuilder.FromRGBA(255, 182, 193, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FFA07A. - /// - public static readonly TColor LightSalmon = ColorBuilder.FromRGBA(255, 160, 122, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #20B2AA. - /// - public static readonly TColor LightSeaGreen = ColorBuilder.FromRGBA(32, 178, 170, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #87CEFA. - /// - public static readonly TColor LightSkyBlue = ColorBuilder.FromRGBA(135, 206, 250, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #778899. - /// - public static readonly TColor LightSlateGray = ColorBuilder.FromRGBA(119, 136, 153, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #B0C4DE. - /// - public static readonly TColor LightSteelBlue = ColorBuilder.FromRGBA(176, 196, 222, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FFFFE0. - /// - public static readonly TColor LightYellow = ColorBuilder.FromRGBA(255, 255, 224, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #00FF00. - /// - public static readonly TColor Lime = ColorBuilder.FromRGBA(0, 255, 0, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #32CD32. - /// - public static readonly TColor LimeGreen = ColorBuilder.FromRGBA(50, 205, 50, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FAF0E6. - /// - public static readonly TColor Linen = ColorBuilder.FromRGBA(250, 240, 230, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FF00FF. - /// - public static readonly TColor Magenta = ColorBuilder.FromRGBA(255, 0, 255, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #800000. - /// - public static readonly TColor Maroon = ColorBuilder.FromRGBA(128, 0, 0, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #66CDAA. - /// - public static readonly TColor MediumAquamarine = ColorBuilder.FromRGBA(102, 205, 170, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #0000CD. - /// - public static readonly TColor MediumBlue = ColorBuilder.FromRGBA(0, 0, 205, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #BA55D3. - /// - public static readonly TColor MediumOrchid = ColorBuilder.FromRGBA(186, 85, 211, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #9370DB. - /// - public static readonly TColor MediumPurple = ColorBuilder.FromRGBA(147, 112, 219, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #3CB371. - /// - public static readonly TColor MediumSeaGreen = ColorBuilder.FromRGBA(60, 179, 113, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #7B68EE. - /// - public static readonly TColor MediumSlateBlue = ColorBuilder.FromRGBA(123, 104, 238, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #00FA9A. - /// - public static readonly TColor MediumSpringGreen = ColorBuilder.FromRGBA(0, 250, 154, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #48D1CC. - /// - public static readonly TColor MediumTurquoise = ColorBuilder.FromRGBA(72, 209, 204, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #C71585. - /// - public static readonly TColor MediumVioletRed = ColorBuilder.FromRGBA(199, 21, 133, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #191970. - /// - public static readonly TColor MidnightBlue = ColorBuilder.FromRGBA(25, 25, 112, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #F5FFFA. - /// - public static readonly TColor MintCream = ColorBuilder.FromRGBA(245, 255, 250, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FFE4E1. - /// - public static readonly TColor MistyRose = ColorBuilder.FromRGBA(255, 228, 225, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FFE4B5. - /// - public static readonly TColor Moccasin = ColorBuilder.FromRGBA(255, 228, 181, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FFDEAD. - /// - public static readonly TColor NavajoWhite = ColorBuilder.FromRGBA(255, 222, 173, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #000080. - /// - public static readonly TColor Navy = ColorBuilder.FromRGBA(0, 0, 128, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FDF5E6. - /// - public static readonly TColor OldLace = ColorBuilder.FromRGBA(253, 245, 230, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #808000. - /// - public static readonly TColor Olive = ColorBuilder.FromRGBA(128, 128, 0, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #6B8E23. - /// - public static readonly TColor OliveDrab = ColorBuilder.FromRGBA(107, 142, 35, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FFA500. - /// - public static readonly TColor Orange = ColorBuilder.FromRGBA(255, 165, 0, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FF4500. - /// - public static readonly TColor OrangeRed = ColorBuilder.FromRGBA(255, 69, 0, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #DA70D6. - /// - public static readonly TColor Orchid = ColorBuilder.FromRGBA(218, 112, 214, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #EEE8AA. - /// - public static readonly TColor PaleGoldenrod = ColorBuilder.FromRGBA(238, 232, 170, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #98FB98. - /// - public static readonly TColor PaleGreen = ColorBuilder.FromRGBA(152, 251, 152, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #AFEEEE. - /// - public static readonly TColor PaleTurquoise = ColorBuilder.FromRGBA(175, 238, 238, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #DB7093. - /// - public static readonly TColor PaleVioletRed = ColorBuilder.FromRGBA(219, 112, 147, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FFEFD5. - /// - public static readonly TColor PapayaWhip = ColorBuilder.FromRGBA(255, 239, 213, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FFDAB9. - /// - public static readonly TColor PeachPuff = ColorBuilder.FromRGBA(255, 218, 185, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #CD853F. - /// - public static readonly TColor Peru = ColorBuilder.FromRGBA(205, 133, 63, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FFC0CB. - /// - public static readonly TColor Pink = ColorBuilder.FromRGBA(255, 192, 203, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #DDA0DD. - /// - public static readonly TColor Plum = ColorBuilder.FromRGBA(221, 160, 221, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #B0E0E6. - /// - public static readonly TColor PowderBlue = ColorBuilder.FromRGBA(176, 224, 230, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #800080. - /// - public static readonly TColor Purple = ColorBuilder.FromRGBA(128, 0, 128, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #663399. - /// - public static readonly TColor RebeccaPurple = ColorBuilder.FromRGBA(102, 51, 153, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FF0000. - /// - public static readonly TColor Red = ColorBuilder.FromRGBA(255, 0, 0, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #BC8F8F. - /// - public static readonly TColor RosyBrown = ColorBuilder.FromRGBA(188, 143, 143, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #4169E1. - /// - public static readonly TColor RoyalBlue = ColorBuilder.FromRGBA(65, 105, 225, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #8B4513. - /// - public static readonly TColor SaddleBrown = ColorBuilder.FromRGBA(139, 69, 19, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FA8072. - /// - public static readonly TColor Salmon = ColorBuilder.FromRGBA(250, 128, 114, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #F4A460. - /// - public static readonly TColor SandyBrown = ColorBuilder.FromRGBA(244, 164, 96, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #2E8B57. - /// - public static readonly TColor SeaGreen = ColorBuilder.FromRGBA(46, 139, 87, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FFF5EE. - /// - public static readonly TColor SeaShell = ColorBuilder.FromRGBA(255, 245, 238, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #A0522D. - /// - public static readonly TColor Sienna = ColorBuilder.FromRGBA(160, 82, 45, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #C0C0C0. - /// - public static readonly TColor Silver = ColorBuilder.FromRGBA(192, 192, 192, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #87CEEB. - /// - public static readonly TColor SkyBlue = ColorBuilder.FromRGBA(135, 206, 235, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #6A5ACD. - /// - public static readonly TColor SlateBlue = ColorBuilder.FromRGBA(106, 90, 205, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #708090. - /// - public static readonly TColor SlateGray = ColorBuilder.FromRGBA(112, 128, 144, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FFFAFA. - /// - public static readonly TColor Snow = ColorBuilder.FromRGBA(255, 250, 250, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #00FF7F. - /// - public static readonly TColor SpringGreen = ColorBuilder.FromRGBA(0, 255, 127, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #4682B4. - /// - public static readonly TColor SteelBlue = ColorBuilder.FromRGBA(70, 130, 180, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #D2B48C. - /// - public static readonly TColor Tan = ColorBuilder.FromRGBA(210, 180, 140, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #008080. - /// - public static readonly TColor Teal = ColorBuilder.FromRGBA(0, 128, 128, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #D8BFD8. - /// - public static readonly TColor Thistle = ColorBuilder.FromRGBA(216, 191, 216, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FF6347. - /// - public static readonly TColor Tomato = ColorBuilder.FromRGBA(255, 99, 71, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FFFFFF. - /// - public static readonly TColor Transparent = ColorBuilder.FromRGBA(255, 255, 255, 0); - - /// - /// Represents a matching the W3C definition that has an hex value of #40E0D0. - /// - public static readonly TColor Turquoise = ColorBuilder.FromRGBA(64, 224, 208, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #EE82EE. - /// - public static readonly TColor Violet = ColorBuilder.FromRGBA(238, 130, 238, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #F5DEB3. - /// - public static readonly TColor Wheat = ColorBuilder.FromRGBA(245, 222, 179, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FFFFFF. - /// - public static readonly TColor White = ColorBuilder.FromRGBA(255, 255, 255, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #F5F5F5. - /// - public static readonly TColor WhiteSmoke = ColorBuilder.FromRGBA(245, 245, 245, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #FFFF00. - /// - public static readonly TColor Yellow = ColorBuilder.FromRGBA(255, 255, 0, 255); - - /// - /// Represents a matching the W3C definition that has an hex value of #9ACD32. - /// - public static readonly TColor YellowGreen = ColorBuilder.FromRGBA(154, 205, 50, 255); - } -} \ No newline at end of file diff --git a/src/ImageSharp/Colors/NamedColors{TPixel}.cs b/src/ImageSharp/Colors/NamedColors{TPixel}.cs new file mode 100644 index 000000000..ee87dd00f --- /dev/null +++ b/src/ImageSharp/Colors/NamedColors{TPixel}.cs @@ -0,0 +1,725 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp +{ + /// + /// A set of named colors mapped to the provided color space. + /// + /// The type of the color. + public static class NamedColors + where TPixel : struct, IPixel + { + /// + /// Represents a matching the W3C definition that has an hex value of #F0F8FF. + /// + public static readonly TPixel AliceBlue = ColorBuilder.FromRGBA(240, 248, 255, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FAEBD7. + /// + public static readonly TPixel AntiqueWhite = ColorBuilder.FromRGBA(250, 235, 215, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #00FFFF. + /// + public static readonly TPixel Aqua = ColorBuilder.FromRGBA(0, 255, 255, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #7FFFD4. + /// + public static readonly TPixel Aquamarine = ColorBuilder.FromRGBA(127, 255, 212, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #F0FFFF. + /// + public static readonly TPixel Azure = ColorBuilder.FromRGBA(240, 255, 255, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #F5F5DC. + /// + public static readonly TPixel Beige = ColorBuilder.FromRGBA(245, 245, 220, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFE4C4. + /// + public static readonly TPixel Bisque = ColorBuilder.FromRGBA(255, 228, 196, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #000000. + /// + public static readonly TPixel Black = ColorBuilder.FromRGBA(0, 0, 0, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFEBCD. + /// + public static readonly TPixel BlanchedAlmond = ColorBuilder.FromRGBA(255, 235, 205, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #0000FF. + /// + public static readonly TPixel Blue = ColorBuilder.FromRGBA(0, 0, 255, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #8A2BE2. + /// + public static readonly TPixel BlueViolet = ColorBuilder.FromRGBA(138, 43, 226, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #A52A2A. + /// + public static readonly TPixel Brown = ColorBuilder.FromRGBA(165, 42, 42, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #DEB887. + /// + public static readonly TPixel BurlyWood = ColorBuilder.FromRGBA(222, 184, 135, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #5F9EA0. + /// + public static readonly TPixel CadetBlue = ColorBuilder.FromRGBA(95, 158, 160, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #7FFF00. + /// + public static readonly TPixel Chartreuse = ColorBuilder.FromRGBA(127, 255, 0, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #D2691E. + /// + public static readonly TPixel Chocolate = ColorBuilder.FromRGBA(210, 105, 30, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FF7F50. + /// + public static readonly TPixel Coral = ColorBuilder.FromRGBA(255, 127, 80, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #6495ED. + /// + public static readonly TPixel CornflowerBlue = ColorBuilder.FromRGBA(100, 149, 237, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFF8DC. + /// + public static readonly TPixel Cornsilk = ColorBuilder.FromRGBA(255, 248, 220, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #DC143C. + /// + public static readonly TPixel Crimson = ColorBuilder.FromRGBA(220, 20, 60, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #00FFFF. + /// + public static readonly TPixel Cyan = ColorBuilder.FromRGBA(0, 255, 255, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #00008B. + /// + public static readonly TPixel DarkBlue = ColorBuilder.FromRGBA(0, 0, 139, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #008B8B. + /// + public static readonly TPixel DarkCyan = ColorBuilder.FromRGBA(0, 139, 139, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #B8860B. + /// + public static readonly TPixel DarkGoldenrod = ColorBuilder.FromRGBA(184, 134, 11, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #A9A9A9. + /// + public static readonly TPixel DarkGray = ColorBuilder.FromRGBA(169, 169, 169, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #006400. + /// + public static readonly TPixel DarkGreen = ColorBuilder.FromRGBA(0, 100, 0, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #BDB76B. + /// + public static readonly TPixel DarkKhaki = ColorBuilder.FromRGBA(189, 183, 107, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #8B008B. + /// + public static readonly TPixel DarkMagenta = ColorBuilder.FromRGBA(139, 0, 139, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #556B2F. + /// + public static readonly TPixel DarkOliveGreen = ColorBuilder.FromRGBA(85, 107, 47, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FF8C00. + /// + public static readonly TPixel DarkOrange = ColorBuilder.FromRGBA(255, 140, 0, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #9932CC. + /// + public static readonly TPixel DarkOrchid = ColorBuilder.FromRGBA(153, 50, 204, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #8B0000. + /// + public static readonly TPixel DarkRed = ColorBuilder.FromRGBA(139, 0, 0, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #E9967A. + /// + public static readonly TPixel DarkSalmon = ColorBuilder.FromRGBA(233, 150, 122, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #8FBC8B. + /// + public static readonly TPixel DarkSeaGreen = ColorBuilder.FromRGBA(143, 188, 139, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #483D8B. + /// + public static readonly TPixel DarkSlateBlue = ColorBuilder.FromRGBA(72, 61, 139, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #2F4F4F. + /// + public static readonly TPixel DarkSlateGray = ColorBuilder.FromRGBA(47, 79, 79, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #00CED1. + /// + public static readonly TPixel DarkTurquoise = ColorBuilder.FromRGBA(0, 206, 209, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #9400D3. + /// + public static readonly TPixel DarkViolet = ColorBuilder.FromRGBA(148, 0, 211, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FF1493. + /// + public static readonly TPixel DeepPink = ColorBuilder.FromRGBA(255, 20, 147, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #00BFFF. + /// + public static readonly TPixel DeepSkyBlue = ColorBuilder.FromRGBA(0, 191, 255, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #696969. + /// + public static readonly TPixel DimGray = ColorBuilder.FromRGBA(105, 105, 105, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #1E90FF. + /// + public static readonly TPixel DodgerBlue = ColorBuilder.FromRGBA(30, 144, 255, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #B22222. + /// + public static readonly TPixel Firebrick = ColorBuilder.FromRGBA(178, 34, 34, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFFAF0. + /// + public static readonly TPixel FloralWhite = ColorBuilder.FromRGBA(255, 250, 240, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #228B22. + /// + public static readonly TPixel ForestGreen = ColorBuilder.FromRGBA(34, 139, 34, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FF00FF. + /// + public static readonly TPixel Fuchsia = ColorBuilder.FromRGBA(255, 0, 255, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #DCDCDC. + /// + public static readonly TPixel Gainsboro = ColorBuilder.FromRGBA(220, 220, 220, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #F8F8FF. + /// + public static readonly TPixel GhostWhite = ColorBuilder.FromRGBA(248, 248, 255, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFD700. + /// + public static readonly TPixel Gold = ColorBuilder.FromRGBA(255, 215, 0, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #DAA520. + /// + public static readonly TPixel Goldenrod = ColorBuilder.FromRGBA(218, 165, 32, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #808080. + /// + public static readonly TPixel Gray = ColorBuilder.FromRGBA(128, 128, 128, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #008000. + /// + public static readonly TPixel Green = ColorBuilder.FromRGBA(0, 128, 0, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #ADFF2F. + /// + public static readonly TPixel GreenYellow = ColorBuilder.FromRGBA(173, 255, 47, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #F0FFF0. + /// + public static readonly TPixel Honeydew = ColorBuilder.FromRGBA(240, 255, 240, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FF69B4. + /// + public static readonly TPixel HotPink = ColorBuilder.FromRGBA(255, 105, 180, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #CD5C5C. + /// + public static readonly TPixel IndianRed = ColorBuilder.FromRGBA(205, 92, 92, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #4B0082. + /// + public static readonly TPixel Indigo = ColorBuilder.FromRGBA(75, 0, 130, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFFFF0. + /// + public static readonly TPixel Ivory = ColorBuilder.FromRGBA(255, 255, 240, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #F0E68C. + /// + public static readonly TPixel Khaki = ColorBuilder.FromRGBA(240, 230, 140, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #E6E6FA. + /// + public static readonly TPixel Lavender = ColorBuilder.FromRGBA(230, 230, 250, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFF0F5. + /// + public static readonly TPixel LavenderBlush = ColorBuilder.FromRGBA(255, 240, 245, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #7CFC00. + /// + public static readonly TPixel LawnGreen = ColorBuilder.FromRGBA(124, 252, 0, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFFACD. + /// + public static readonly TPixel LemonChiffon = ColorBuilder.FromRGBA(255, 250, 205, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #ADD8E6. + /// + public static readonly TPixel LightBlue = ColorBuilder.FromRGBA(173, 216, 230, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #F08080. + /// + public static readonly TPixel LightCoral = ColorBuilder.FromRGBA(240, 128, 128, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #E0FFFF. + /// + public static readonly TPixel LightCyan = ColorBuilder.FromRGBA(224, 255, 255, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FAFAD2. + /// + public static readonly TPixel LightGoldenrodYellow = ColorBuilder.FromRGBA(250, 250, 210, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #D3D3D3. + /// + public static readonly TPixel LightGray = ColorBuilder.FromRGBA(211, 211, 211, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #90EE90. + /// + public static readonly TPixel LightGreen = ColorBuilder.FromRGBA(144, 238, 144, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFB6C1. + /// + public static readonly TPixel LightPink = ColorBuilder.FromRGBA(255, 182, 193, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFA07A. + /// + public static readonly TPixel LightSalmon = ColorBuilder.FromRGBA(255, 160, 122, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #20B2AA. + /// + public static readonly TPixel LightSeaGreen = ColorBuilder.FromRGBA(32, 178, 170, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #87CEFA. + /// + public static readonly TPixel LightSkyBlue = ColorBuilder.FromRGBA(135, 206, 250, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #778899. + /// + public static readonly TPixel LightSlateGray = ColorBuilder.FromRGBA(119, 136, 153, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #B0C4DE. + /// + public static readonly TPixel LightSteelBlue = ColorBuilder.FromRGBA(176, 196, 222, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFFFE0. + /// + public static readonly TPixel LightYellow = ColorBuilder.FromRGBA(255, 255, 224, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #00FF00. + /// + public static readonly TPixel Lime = ColorBuilder.FromRGBA(0, 255, 0, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #32CD32. + /// + public static readonly TPixel LimeGreen = ColorBuilder.FromRGBA(50, 205, 50, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FAF0E6. + /// + public static readonly TPixel Linen = ColorBuilder.FromRGBA(250, 240, 230, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FF00FF. + /// + public static readonly TPixel Magenta = ColorBuilder.FromRGBA(255, 0, 255, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #800000. + /// + public static readonly TPixel Maroon = ColorBuilder.FromRGBA(128, 0, 0, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #66CDAA. + /// + public static readonly TPixel MediumAquamarine = ColorBuilder.FromRGBA(102, 205, 170, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #0000CD. + /// + public static readonly TPixel MediumBlue = ColorBuilder.FromRGBA(0, 0, 205, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #BA55D3. + /// + public static readonly TPixel MediumOrchid = ColorBuilder.FromRGBA(186, 85, 211, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #9370DB. + /// + public static readonly TPixel MediumPurple = ColorBuilder.FromRGBA(147, 112, 219, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #3CB371. + /// + public static readonly TPixel MediumSeaGreen = ColorBuilder.FromRGBA(60, 179, 113, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #7B68EE. + /// + public static readonly TPixel MediumSlateBlue = ColorBuilder.FromRGBA(123, 104, 238, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #00FA9A. + /// + public static readonly TPixel MediumSpringGreen = ColorBuilder.FromRGBA(0, 250, 154, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #48D1CC. + /// + public static readonly TPixel MediumTurquoise = ColorBuilder.FromRGBA(72, 209, 204, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #C71585. + /// + public static readonly TPixel MediumVioletRed = ColorBuilder.FromRGBA(199, 21, 133, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #191970. + /// + public static readonly TPixel MidnightBlue = ColorBuilder.FromRGBA(25, 25, 112, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #F5FFFA. + /// + public static readonly TPixel MintCream = ColorBuilder.FromRGBA(245, 255, 250, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFE4E1. + /// + public static readonly TPixel MistyRose = ColorBuilder.FromRGBA(255, 228, 225, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFE4B5. + /// + public static readonly TPixel Moccasin = ColorBuilder.FromRGBA(255, 228, 181, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFDEAD. + /// + public static readonly TPixel NavajoWhite = ColorBuilder.FromRGBA(255, 222, 173, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #000080. + /// + public static readonly TPixel Navy = ColorBuilder.FromRGBA(0, 0, 128, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FDF5E6. + /// + public static readonly TPixel OldLace = ColorBuilder.FromRGBA(253, 245, 230, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #808000. + /// + public static readonly TPixel Olive = ColorBuilder.FromRGBA(128, 128, 0, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #6B8E23. + /// + public static readonly TPixel OliveDrab = ColorBuilder.FromRGBA(107, 142, 35, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFA500. + /// + public static readonly TPixel Orange = ColorBuilder.FromRGBA(255, 165, 0, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FF4500. + /// + public static readonly TPixel OrangeRed = ColorBuilder.FromRGBA(255, 69, 0, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #DA70D6. + /// + public static readonly TPixel Orchid = ColorBuilder.FromRGBA(218, 112, 214, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #EEE8AA. + /// + public static readonly TPixel PaleGoldenrod = ColorBuilder.FromRGBA(238, 232, 170, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #98FB98. + /// + public static readonly TPixel PaleGreen = ColorBuilder.FromRGBA(152, 251, 152, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #AFEEEE. + /// + public static readonly TPixel PaleTurquoise = ColorBuilder.FromRGBA(175, 238, 238, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #DB7093. + /// + public static readonly TPixel PaleVioletRed = ColorBuilder.FromRGBA(219, 112, 147, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFEFD5. + /// + public static readonly TPixel PapayaWhip = ColorBuilder.FromRGBA(255, 239, 213, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFDAB9. + /// + public static readonly TPixel PeachPuff = ColorBuilder.FromRGBA(255, 218, 185, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #CD853F. + /// + public static readonly TPixel Peru = ColorBuilder.FromRGBA(205, 133, 63, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFC0CB. + /// + public static readonly TPixel Pink = ColorBuilder.FromRGBA(255, 192, 203, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #DDA0DD. + /// + public static readonly TPixel Plum = ColorBuilder.FromRGBA(221, 160, 221, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #B0E0E6. + /// + public static readonly TPixel PowderBlue = ColorBuilder.FromRGBA(176, 224, 230, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #800080. + /// + public static readonly TPixel Purple = ColorBuilder.FromRGBA(128, 0, 128, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #663399. + /// + public static readonly TPixel RebeccaPurple = ColorBuilder.FromRGBA(102, 51, 153, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FF0000. + /// + public static readonly TPixel Red = ColorBuilder.FromRGBA(255, 0, 0, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #BC8F8F. + /// + public static readonly TPixel RosyBrown = ColorBuilder.FromRGBA(188, 143, 143, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #4169E1. + /// + public static readonly TPixel RoyalBlue = ColorBuilder.FromRGBA(65, 105, 225, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #8B4513. + /// + public static readonly TPixel SaddleBrown = ColorBuilder.FromRGBA(139, 69, 19, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FA8072. + /// + public static readonly TPixel Salmon = ColorBuilder.FromRGBA(250, 128, 114, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #F4A460. + /// + public static readonly TPixel SandyBrown = ColorBuilder.FromRGBA(244, 164, 96, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #2E8B57. + /// + public static readonly TPixel SeaGreen = ColorBuilder.FromRGBA(46, 139, 87, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFF5EE. + /// + public static readonly TPixel SeaShell = ColorBuilder.FromRGBA(255, 245, 238, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #A0522D. + /// + public static readonly TPixel Sienna = ColorBuilder.FromRGBA(160, 82, 45, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #C0C0C0. + /// + public static readonly TPixel Silver = ColorBuilder.FromRGBA(192, 192, 192, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #87CEEB. + /// + public static readonly TPixel SkyBlue = ColorBuilder.FromRGBA(135, 206, 235, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #6A5ACD. + /// + public static readonly TPixel SlateBlue = ColorBuilder.FromRGBA(106, 90, 205, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #708090. + /// + public static readonly TPixel SlateGray = ColorBuilder.FromRGBA(112, 128, 144, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFFAFA. + /// + public static readonly TPixel Snow = ColorBuilder.FromRGBA(255, 250, 250, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #00FF7F. + /// + public static readonly TPixel SpringGreen = ColorBuilder.FromRGBA(0, 255, 127, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #4682B4. + /// + public static readonly TPixel SteelBlue = ColorBuilder.FromRGBA(70, 130, 180, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #D2B48C. + /// + public static readonly TPixel Tan = ColorBuilder.FromRGBA(210, 180, 140, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #008080. + /// + public static readonly TPixel Teal = ColorBuilder.FromRGBA(0, 128, 128, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #D8BFD8. + /// + public static readonly TPixel Thistle = ColorBuilder.FromRGBA(216, 191, 216, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FF6347. + /// + public static readonly TPixel Tomato = ColorBuilder.FromRGBA(255, 99, 71, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFFFFF. + /// + public static readonly TPixel Transparent = ColorBuilder.FromRGBA(255, 255, 255, 0); + + /// + /// Represents a matching the W3C definition that has an hex value of #40E0D0. + /// + public static readonly TPixel Turquoise = ColorBuilder.FromRGBA(64, 224, 208, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #EE82EE. + /// + public static readonly TPixel Violet = ColorBuilder.FromRGBA(238, 130, 238, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #F5DEB3. + /// + public static readonly TPixel Wheat = ColorBuilder.FromRGBA(245, 222, 179, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFFFFF. + /// + public static readonly TPixel White = ColorBuilder.FromRGBA(255, 255, 255, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #F5F5F5. + /// + public static readonly TPixel WhiteSmoke = ColorBuilder.FromRGBA(245, 245, 245, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFFF00. + /// + public static readonly TPixel Yellow = ColorBuilder.FromRGBA(255, 255, 0, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #9ACD32. + /// + public static readonly TPixel YellowGreen = ColorBuilder.FromRGBA(154, 205, 50, 255); + } +} \ No newline at end of file diff --git a/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TColor}.cs b/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TPixel}.cs similarity index 78% rename from src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TColor}.cs rename to src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TPixel}.cs index db0251703..d58e48ffd 100644 --- a/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TColor}.cs +++ b/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TPixel}.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // @@ -10,16 +10,16 @@ namespace ImageSharp /// /// A stateless class implementing Strategy Pattern for batched pixel-data conversion operations - /// for pixel buffers of type . + /// for pixel buffers of type . /// - /// The pixel format. - public class BulkPixelOperations - where TColor : struct, IPixel + /// The pixel format. + public class BulkPixelOperations + where TPixel : struct, IPixel { /// - /// Gets the global instance for the pixel type + /// Gets the global instance for the pixel type /// - public static BulkPixelOperations Instance { get; } = default(TColor).CreateBulkOperations(); + public static BulkPixelOperations Instance { get; } = default(TPixel).CreateBulkOperations(); /// /// Bulk version of @@ -27,15 +27,15 @@ namespace ImageSharp /// The to the source vectors. /// The to the destination colors. /// The number of pixels to convert. - internal virtual void PackFromVector4(BufferSpan sourceVectors, BufferSpan destColors, int count) + internal virtual void PackFromVector4(BufferSpan sourceVectors, BufferSpan destColors, int count) { ref Vector4 sourceRef = ref sourceVectors.DangerousGetPinnableReference(); - ref TColor destRef = ref destColors.DangerousGetPinnableReference(); + ref TPixel destRef = ref destColors.DangerousGetPinnableReference(); for (int i = 0; i < count; i++) { ref Vector4 sp = ref Unsafe.Add(ref sourceRef, i); - ref TColor dp = ref Unsafe.Add(ref destRef, i); + ref TPixel dp = ref Unsafe.Add(ref destRef, i); dp.PackFromVector4(sp); } } @@ -46,14 +46,14 @@ namespace ImageSharp /// The to the source colors. /// The to the destination vectors. /// The number of pixels to convert. - internal virtual void ToVector4(BufferSpan sourceColors, BufferSpan destVectors, int count) + internal virtual void ToVector4(BufferSpan sourceColors, BufferSpan destVectors, int count) { - ref TColor sourceRef = ref sourceColors.DangerousGetPinnableReference(); + ref TPixel sourceRef = ref sourceColors.DangerousGetPinnableReference(); ref Vector4 destRef = ref destVectors.DangerousGetPinnableReference(); for (int i = 0; i < count; i++) { - ref TColor sp = ref Unsafe.Add(ref sourceRef, i); + ref TPixel sp = ref Unsafe.Add(ref sourceRef, i); ref Vector4 dp = ref Unsafe.Add(ref destRef, i); dp = sp.ToVector4(); } @@ -65,15 +65,15 @@ namespace ImageSharp /// The to the source bytes. /// The to the destination colors. /// The number of pixels to convert. - internal virtual void PackFromXyzBytes(BufferSpan sourceBytes, BufferSpan destColors, int count) + internal virtual void PackFromXyzBytes(BufferSpan sourceBytes, BufferSpan destColors, int count) { ref byte sourceRef = ref sourceBytes.DangerousGetPinnableReference(); - ref TColor destRef = ref destColors.DangerousGetPinnableReference(); + ref TPixel destRef = ref destColors.DangerousGetPinnableReference(); for (int i = 0; i < count; i++) { int i3 = i * 3; - ref TColor dp = ref Unsafe.Add(ref destRef, i); + ref TPixel dp = ref Unsafe.Add(ref destRef, i); dp.PackFromBytes( Unsafe.Add(ref sourceRef, i3), Unsafe.Add(ref sourceRef, i3 + 1), @@ -88,14 +88,14 @@ namespace ImageSharp /// The to the source colors. /// The to the destination bytes. /// The number of pixels to convert. - internal virtual void ToXyzBytes(BufferSpan sourceColors, BufferSpan destBytes, int count) + internal virtual void ToXyzBytes(BufferSpan sourceColors, BufferSpan destBytes, int count) { - ref TColor sourceRef = ref sourceColors.DangerousGetPinnableReference(); + ref TPixel sourceRef = ref sourceColors.DangerousGetPinnableReference(); byte[] dest = destBytes.Array; for (int i = 0; i < count; i++) { - ref TColor sp = ref Unsafe.Add(ref sourceRef, i); + ref TPixel sp = ref Unsafe.Add(ref sourceRef, i); sp.ToXyzBytes(dest, destBytes.Start + (i * 3)); } } @@ -106,15 +106,15 @@ namespace ImageSharp /// The to the source bytes. /// The to the destination colors. /// The number of pixels to convert. - internal virtual void PackFromXyzwBytes(BufferSpan sourceBytes, BufferSpan destColors, int count) + internal virtual void PackFromXyzwBytes(BufferSpan sourceBytes, BufferSpan destColors, int count) { ref byte sourceRef = ref sourceBytes.DangerousGetPinnableReference(); - ref TColor destRef = ref destColors.DangerousGetPinnableReference(); + ref TPixel destRef = ref destColors.DangerousGetPinnableReference(); for (int i = 0; i < count; i++) { int i4 = i * 4; - ref TColor dp = ref Unsafe.Add(ref destRef, i); + ref TPixel dp = ref Unsafe.Add(ref destRef, i); dp.PackFromBytes( Unsafe.Add(ref sourceRef, i4), Unsafe.Add(ref sourceRef, i4 + 1), @@ -129,14 +129,14 @@ namespace ImageSharp /// The to the source colors. /// The to the destination bytes. /// The number of pixels to convert. - internal virtual void ToXyzwBytes(BufferSpan sourceColors, BufferSpan destBytes, int count) + internal virtual void ToXyzwBytes(BufferSpan sourceColors, BufferSpan destBytes, int count) { - ref TColor sourceRef = ref sourceColors.DangerousGetPinnableReference(); + ref TPixel sourceRef = ref sourceColors.DangerousGetPinnableReference(); byte[] dest = destBytes.Array; for (int i = 0; i < count; i++) { - ref TColor sp = ref Unsafe.Add(ref sourceRef, i); + ref TPixel sp = ref Unsafe.Add(ref sourceRef, i); sp.ToXyzwBytes(dest, destBytes.Start + (i * 4)); } } @@ -147,15 +147,15 @@ namespace ImageSharp /// The to the source bytes. /// The to the destination colors. /// The number of pixels to convert. - internal virtual void PackFromZyxBytes(BufferSpan sourceBytes, BufferSpan destColors, int count) + internal virtual void PackFromZyxBytes(BufferSpan sourceBytes, BufferSpan destColors, int count) { ref byte sourceRef = ref sourceBytes.DangerousGetPinnableReference(); - ref TColor destRef = ref destColors.DangerousGetPinnableReference(); + ref TPixel destRef = ref destColors.DangerousGetPinnableReference(); for (int i = 0; i < count; i++) { int i3 = i * 3; - ref TColor dp = ref Unsafe.Add(ref destRef, i); + ref TPixel dp = ref Unsafe.Add(ref destRef, i); dp.PackFromBytes( Unsafe.Add(ref sourceRef, i3 + 2), Unsafe.Add(ref sourceRef, i3 + 1), @@ -170,14 +170,14 @@ namespace ImageSharp /// The to the source colors. /// The to the destination bytes. /// The number of pixels to convert. - internal virtual void ToZyxBytes(BufferSpan sourceColors, BufferSpan destBytes, int count) + internal virtual void ToZyxBytes(BufferSpan sourceColors, BufferSpan destBytes, int count) { - ref TColor sourceRef = ref sourceColors.DangerousGetPinnableReference(); + ref TPixel sourceRef = ref sourceColors.DangerousGetPinnableReference(); byte[] dest = destBytes.Array; for (int i = 0; i < count; i++) { - ref TColor sp = ref Unsafe.Add(ref sourceRef, i); + ref TPixel sp = ref Unsafe.Add(ref sourceRef, i); sp.ToZyxBytes(dest, destBytes.Start + (i * 3)); } } @@ -188,15 +188,15 @@ namespace ImageSharp /// The to the source bytes. /// The to the destination colors. /// The number of pixels to convert. - internal virtual void PackFromZyxwBytes(BufferSpan sourceBytes, BufferSpan destColors, int count) + internal virtual void PackFromZyxwBytes(BufferSpan sourceBytes, BufferSpan destColors, int count) { ref byte sourceRef = ref sourceBytes.DangerousGetPinnableReference(); - ref TColor destRef = ref destColors.DangerousGetPinnableReference(); + ref TPixel destRef = ref destColors.DangerousGetPinnableReference(); for (int i = 0; i < count; i++) { int i4 = i * 4; - ref TColor dp = ref Unsafe.Add(ref destRef, i); + ref TPixel dp = ref Unsafe.Add(ref destRef, i); dp.PackFromBytes( Unsafe.Add(ref sourceRef, i4 + 2), Unsafe.Add(ref sourceRef, i4 + 1), @@ -211,14 +211,14 @@ namespace ImageSharp /// The to the source colors. /// The to the destination bytes. /// The number of pixels to convert. - internal virtual void ToZyxwBytes(BufferSpan sourceColors, BufferSpan destBytes, int count) + internal virtual void ToZyxwBytes(BufferSpan sourceColors, BufferSpan destBytes, int count) { - ref TColor sourceRef = ref sourceColors.DangerousGetPinnableReference(); + ref TPixel sourceRef = ref sourceColors.DangerousGetPinnableReference(); byte[] dest = destBytes.Array; for (int i = 0; i < count; i++) { - ref TColor sp = ref Unsafe.Add(ref sourceRef, i); + ref TPixel sp = ref Unsafe.Add(ref sourceRef, i); sp.ToZyxwBytes(dest, destBytes.Start + (i * 4)); } } diff --git a/src/ImageSharp/Colors/PackedPixel/IPixel.cs b/src/ImageSharp/Colors/PackedPixel/IPixel.cs index 024ceafb3..08f2eafb0 100644 --- a/src/ImageSharp/Colors/PackedPixel/IPixel.cs +++ b/src/ImageSharp/Colors/PackedPixel/IPixel.cs @@ -16,10 +16,10 @@ namespace ImageSharp where TSelf : struct, IPixel { /// - /// Creates a instance for this pixel type. - /// This method is not intended to be consumed directly. Use instead. + /// Creates a instance for this pixel type. + /// This method is not intended to be consumed directly. Use instead. /// - /// The instance. + /// The instance. BulkPixelOperations CreateBulkOperations(); } diff --git a/src/ImageSharp/Colors/PackedPixel/PackedPixelConverterHelper.cs b/src/ImageSharp/Colors/PackedPixel/PackedPixelConverterHelper.cs index 5e8ad66fe..16d73f785 100644 --- a/src/ImageSharp/Colors/PackedPixel/PackedPixelConverterHelper.cs +++ b/src/ImageSharp/Colors/PackedPixel/PackedPixelConverterHelper.cs @@ -22,10 +22,10 @@ namespace ImageSharp /// Returns the correct scaling function for the given types The compute scale function. /// /// The scale function. - /// The source pixel format. - /// The target pixel format. + /// The source pixel format. + /// The target pixel format. /// The - public static Func ComputeScaleFunction(Func scaleFunc) + public static Func ComputeScaleFunction(Func scaleFunc) { // Custom type with a custom function. if (scaleFunc != null) @@ -33,8 +33,8 @@ namespace ImageSharp return scaleFunc; } - Type source = typeof(TColor); - Type target = typeof(TColor2); + Type source = typeof(TPixel); + Type target = typeof(TPixel2); // Normalized standard if (IsStandardNormalizedType(source)) diff --git a/src/ImageSharp/Colors/Rgba32.BulkOperations.cs b/src/ImageSharp/Colors/Rgba32.BulkOperations.cs index 4dc8bb051..e35de0ad5 100644 --- a/src/ImageSharp/Colors/Rgba32.BulkOperations.cs +++ b/src/ImageSharp/Colors/Rgba32.BulkOperations.cs @@ -21,7 +21,7 @@ namespace ImageSharp public partial struct Rgba32 { /// - /// implementation optimized for . + /// implementation optimized for . /// internal class BulkOperations : BulkPixelOperations { diff --git a/src/ImageSharp/Colors/Rgba32.ColorspaceTransforms.cs b/src/ImageSharp/Colors/Rgba32.ColorspaceTransforms.cs index aa83c31d9..0e5029920 100644 --- a/src/ImageSharp/Colors/Rgba32.ColorspaceTransforms.cs +++ b/src/ImageSharp/Colors/Rgba32.ColorspaceTransforms.cs @@ -189,9 +189,9 @@ namespace ImageSharp float temp2 = (l < 0.5f) ? l * (1f + s) : l + s - (l * s); float temp1 = (2f * l) - temp2; - r = GeTPixelComponent(temp1, temp2, rangedH + 0.3333333F); - g = GeTPixelComponent(temp1, temp2, rangedH); - b = GeTPixelComponent(temp1, temp2, rangedH - 0.3333333F); + r = GetColorComponent(temp1, temp2, rangedH + 0.3333333F); + g = GetColorComponent(temp1, temp2, rangedH); + b = GetColorComponent(temp1, temp2, rangedH - 0.3333333F); } } @@ -241,7 +241,7 @@ namespace ImageSharp /// /// The . /// - private static float GeTPixelComponent(float first, float second, float third) + private static float GetColorComponent(float first, float second, float third) { third = MoveIntoRange(third); if (third < 0.1666667F) diff --git a/src/ImageSharp/Colors/RgbaVector.BulkOperations.cs b/src/ImageSharp/Colors/RgbaVector.BulkOperations.cs index 1a3357c51..e26048fc4 100644 --- a/src/ImageSharp/Colors/RgbaVector.BulkOperations.cs +++ b/src/ImageSharp/Colors/RgbaVector.BulkOperations.cs @@ -18,7 +18,7 @@ namespace ImageSharp public partial struct RgbaVector { /// - /// implementation optimized for . + /// implementation optimized for . /// internal class BulkOperations : BulkPixelOperations { diff --git a/src/ImageSharp/Colors/Spaces/IAlmostEquatable.cs b/src/ImageSharp/Colors/Spaces/IAlmostEquatable.cs index a2183d396..04ea91cba 100644 --- a/src/ImageSharp/Colors/Spaces/IAlmostEquatable.cs +++ b/src/ImageSharp/Colors/Spaces/IAlmostEquatable.cs @@ -11,9 +11,9 @@ namespace ImageSharp.Colors.Spaces /// Defines a generalized method that a value type or class implements to create /// a type-specific method for determining approximate equality of instances. /// - /// The type of objects to compare. + /// The type of objects to compare. /// The object specifying the type to specify precision with. - public interface IAlmostEquatable + public interface IAlmostEquatable where TPrecision : struct, IComparable { /// @@ -25,6 +25,6 @@ namespace ImageSharp.Colors.Spaces /// /// true if the current object is equal to the other parameter; otherwise, false. /// - bool AlmostEquals(TColor other, TPrecision precision); + bool AlmostEquals(TPixel other, TPrecision precision); } } diff --git a/src/ImageSharp/Common/Helpers/ImageMaths.cs b/src/ImageSharp/Common/Helpers/ImageMaths.cs index 224b267e4..3cfea581d 100644 --- a/src/ImageSharp/Common/Helpers/ImageMaths.cs +++ b/src/ImageSharp/Common/Helpers/ImageMaths.cs @@ -175,22 +175,22 @@ namespace ImageSharp /// Finds the bounding rectangle based on the first instance of any color component other /// than the given one. /// - /// The pixel format. + /// The pixel format. /// The to search within. /// The color component value to remove. /// The channel to test against. /// /// The . /// - public static Rectangle GetFilteredBoundingRectangle(ImageBase bitmap, float componentValue, RgbaComponent channel = RgbaComponent.B) - where TColor : struct, IPixel + public static Rectangle GetFilteredBoundingRectangle(ImageBase bitmap, float componentValue, RgbaComponent channel = RgbaComponent.B) + where TPixel : struct, IPixel { int width = bitmap.Width; int height = bitmap.Height; Point topLeft = default(Point); Point bottomRight = default(Point); - Func, int, int, float, bool> delegateFunc; + Func, int, int, float, bool> delegateFunc; // Determine which channel to check against switch (channel) @@ -212,7 +212,7 @@ namespace ImageSharp break; } - Func, int> getMinY = pixels => + Func, int> getMinY = pixels => { for (int y = 0; y < height; y++) { @@ -228,7 +228,7 @@ namespace ImageSharp return 0; }; - Func, int> getMaxY = pixels => + Func, int> getMaxY = pixels => { for (int y = height - 1; y > -1; y--) { @@ -244,7 +244,7 @@ namespace ImageSharp return height; }; - Func, int> getMinX = pixels => + Func, int> getMinX = pixels => { for (int x = 0; x < width; x++) { @@ -260,7 +260,7 @@ namespace ImageSharp return 0; }; - Func, int> getMaxX = pixels => + Func, int> getMaxX = pixels => { for (int x = width - 1; x > -1; x--) { @@ -276,7 +276,7 @@ namespace ImageSharp return height; }; - using (PixelAccessor bitmapPixels = bitmap.Lock()) + using (PixelAccessor bitmapPixels = bitmap.Lock()) { topLeft.Y = getMinY(bitmapPixels); topLeft.X = getMinX(bitmapPixels); diff --git a/src/ImageSharp/Common/Memory/PixelDataPool{T}.cs b/src/ImageSharp/Common/Memory/PixelDataPool{T}.cs index f5c787140..8bb446535 100644 --- a/src/ImageSharp/Common/Memory/PixelDataPool{T}.cs +++ b/src/ImageSharp/Common/Memory/PixelDataPool{T}.cs @@ -24,7 +24,7 @@ namespace ImageSharp /// Rents the pixel array from the pool. /// /// The minimum length of the array to return. - /// The + /// The public static T[] Rent(int minimumLength) { return ArrayPool.Rent(minimumLength); diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/ErrorDiffuser.cs b/src/ImageSharp/Dithering/ErrorDiffusion/ErrorDiffuser.cs index d6ab8eb64..af78c8f86 100644 --- a/src/ImageSharp/Dithering/ErrorDiffusion/ErrorDiffuser.cs +++ b/src/ImageSharp/Dithering/ErrorDiffusion/ErrorDiffuser.cs @@ -68,16 +68,16 @@ namespace ImageSharp.Dithering /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Dither(PixelAccessor pixels, TColor source, TColor transformed, int x, int y, int width, int height) - where TColor : struct, IPixel + public void Dither(PixelAccessor pixels, TPixel source, TPixel transformed, int x, int y, int width, int height) + where TPixel : struct, IPixel { this.Dither(pixels, source, transformed, x, y, width, height, true); } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Dither(PixelAccessor pixels, TColor source, TColor transformed, int x, int y, int width, int height, bool replacePixel) - where TColor : struct, IPixel + public void Dither(PixelAccessor pixels, TPixel source, TPixel transformed, int x, int y, int width, int height, bool replacePixel) + where TPixel : struct, IPixel { if (replacePixel) { @@ -113,7 +113,7 @@ namespace ImageSharp.Dithering Vector4 result = ((error * coefficientVector) / this.divisorVector) + offsetColor; result.W = offsetColor.W; - TColor packed = default(TColor); + TPixel packed = default(TPixel); packed.PackFromVector4(result); pixels[matrixX, matrixY] = packed; } diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/IErrorDiffuser.cs b/src/ImageSharp/Dithering/ErrorDiffusion/IErrorDiffuser.cs index 66ec3d515..f7a13984a 100644 --- a/src/ImageSharp/Dithering/ErrorDiffusion/IErrorDiffuser.cs +++ b/src/ImageSharp/Dithering/ErrorDiffusion/IErrorDiffuser.cs @@ -22,9 +22,9 @@ namespace ImageSharp.Dithering /// The row index. /// The image width. /// The image height. - /// The pixel format. - void Dither(PixelAccessor pixels, TColor source, TColor transformed, int x, int y, int width, int height) - where TColor : struct, IPixel; + /// The pixel format. + void Dither(PixelAccessor pixels, TPixel source, TPixel transformed, int x, int y, int width, int height) + where TPixel : struct, IPixel; /// /// Transforms the image applying the dither matrix. This method alters the input pixels array @@ -40,8 +40,8 @@ namespace ImageSharp.Dithering /// Whether to replace the pixel at the given coordinates with the transformed value. /// Generally this would be true for standard two-color dithering but when used in conjunction with color quantization this should be false. /// - /// The pixel format. - void Dither(PixelAccessor pixels, TColor source, TColor transformed, int x, int y, int width, int height, bool replacePixel) - where TColor : struct, IPixel; + /// The pixel format. + void Dither(PixelAccessor pixels, TPixel source, TPixel transformed, int x, int y, int width, int height, bool replacePixel) + where TPixel : struct, IPixel; } } diff --git a/src/ImageSharp/Dithering/Ordered/IOrderedDither.cs b/src/ImageSharp/Dithering/Ordered/IOrderedDither.cs index 5c9897374..0762f61a7 100644 --- a/src/ImageSharp/Dithering/Ordered/IOrderedDither.cs +++ b/src/ImageSharp/Dithering/Ordered/IOrderedDither.cs @@ -23,8 +23,8 @@ namespace ImageSharp.Dithering /// The row index. /// The image width. /// The image height. - /// The pixel format. - void Dither(PixelAccessor pixels, TColor source, TColor upper, TColor lower, byte[] bytes, int index, int x, int y, int width, int height) - where TColor : struct, IPixel; + /// The pixel format. + void Dither(PixelAccessor pixels, TPixel source, TPixel upper, TPixel lower, byte[] bytes, int index, int x, int y, int width, int height) + where TPixel : struct, IPixel; } } \ No newline at end of file diff --git a/src/ImageSharp/Dithering/Ordered/OrderedDither4x4.cs b/src/ImageSharp/Dithering/Ordered/OrderedDither4x4.cs index c2b55d98e..ce0ae1d97 100644 --- a/src/ImageSharp/Dithering/Ordered/OrderedDither4x4.cs +++ b/src/ImageSharp/Dithering/Ordered/OrderedDither4x4.cs @@ -25,8 +25,8 @@ namespace ImageSharp.Dithering.Ordered } /// - public void Dither(PixelAccessor pixels, TColor source, TColor upper, TColor lower, byte[] bytes, int index, int x, int y, int width, int height) - where TColor : struct, IPixel + public void Dither(PixelAccessor pixels, TPixel source, TPixel upper, TPixel lower, byte[] bytes, int index, int x, int y, int width, int height) + where TPixel : struct, IPixel { // TODO: This doesn't really cut it for me. // I'd rather be using float but we need to add some sort of movalization vector methods to all IPixel implementations diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoder.cs b/src/ImageSharp/Formats/Bmp/BmpDecoder.cs index da5d24637..94f045efa 100644 --- a/src/ImageSharp/Formats/Bmp/BmpDecoder.cs +++ b/src/ImageSharp/Formats/Bmp/BmpDecoder.cs @@ -26,13 +26,13 @@ namespace ImageSharp.Formats public class BmpDecoder : IImageDecoder { /// - public Image Decode(Configuration configuration, Stream stream, IDecoderOptions options) + public Image Decode(Configuration configuration, Stream stream, IDecoderOptions options) - where TColor : struct, IPixel + where TPixel : struct, IPixel { Guard.NotNull(stream, "stream"); - return new BmpDecoderCore(configuration).Decode(stream); + return new BmpDecoderCore(configuration).Decode(stream); } } } diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs index 18e4e858b..9f15bf0b2 100644 --- a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs @@ -58,15 +58,15 @@ namespace ImageSharp.Formats /// Decodes the image from the specified this._stream and sets /// the data to image. /// - /// The pixel format. + /// The pixel format. /// The stream, where the image should be /// decoded from. Cannot be null (Nothing in Visual Basic). /// /// is null. /// /// The decoded image. - public Image Decode(Stream stream) - where TColor : struct, IPixel + public Image Decode(Stream stream) + where TPixel : struct, IPixel { this.currentStream = stream; @@ -118,15 +118,15 @@ namespace ImageSharp.Formats this.currentStream.Read(palette, 0, colorMapSize); } - if (this.infoHeader.Width > Image.MaxWidth || this.infoHeader.Height > Image.MaxHeight) + if (this.infoHeader.Width > Image.MaxWidth || this.infoHeader.Height > Image.MaxHeight) { throw new ArgumentOutOfRangeException( $"The input bitmap '{this.infoHeader.Width}x{this.infoHeader.Height}' is " - + $"bigger then the max allowed size '{Image.MaxWidth}x{Image.MaxHeight}'"); + + $"bigger then the max allowed size '{Image.MaxWidth}x{Image.MaxHeight}'"); } - Image image = Image.Create(this.infoHeader.Width, this.infoHeader.Height, this.configuration); - using (PixelAccessor pixels = image.Lock()) + Image image = Image.Create(this.infoHeader.Width, this.infoHeader.Height, this.configuration); + using (PixelAccessor pixels = image.Lock()) { switch (this.infoHeader.Compression) { @@ -213,15 +213,15 @@ namespace ImageSharp.Formats /// /// Reads the color palette from the stream. /// - /// The pixel format. - /// The to assign the palette to. + /// The pixel format. + /// The to assign the palette to. /// The containing the colors. /// The width of the bitmap. /// The height of the bitmap. /// The number of bits per pixel. /// Whether the bitmap is inverted. - private void ReadRgbPalette(PixelAccessor pixels, byte[] colors, int width, int height, int bits, bool inverted) - where TColor : struct, IPixel + private void ReadRgbPalette(PixelAccessor pixels, byte[] colors, int width, int height, int bits, bool inverted) + where TPixel : struct, IPixel { // Pixels per byte (bits per pixel) int ppb = 8 / bits; @@ -239,7 +239,7 @@ namespace ImageSharp.Formats } byte[] row = new byte[arrayWidth + padding]; - TColor color = default(TColor); + TPixel color = default(TPixel); for (int y = 0; y < height; y++) { @@ -270,21 +270,21 @@ namespace ImageSharp.Formats /// /// Reads the 16 bit color palette from the stream /// - /// The pixel format. - /// The to assign the palette to. + /// The pixel format. + /// The to assign the palette to. /// The width of the bitmap. /// The height of the bitmap. /// Whether the bitmap is inverted. - private void ReadRgb16(PixelAccessor pixels, int width, int height, bool inverted) - where TColor : struct, IPixel + private void ReadRgb16(PixelAccessor pixels, int width, int height, bool inverted) + where TPixel : struct, IPixel { // We divide here as we will store the colors in our floating point format. const int ScaleR = 8; // 256/32 const int ScaleG = 4; // 256/64 const int ComponentCount = 2; - TColor color = default(TColor); - using (PixelArea row = new PixelArea(width, ComponentOrder.Xyz)) + TPixel color = default(TPixel); + using (PixelArea row = new PixelArea(width, ComponentOrder.Xyz)) { for (int y = 0; y < height; y++) { @@ -312,16 +312,16 @@ namespace ImageSharp.Formats /// /// Reads the 24 bit color palette from the stream /// - /// The pixel format. - /// The to assign the palette to. + /// The pixel format. + /// The to assign the palette to. /// The width of the bitmap. /// The height of the bitmap. /// Whether the bitmap is inverted. - private void ReadRgb24(PixelAccessor pixels, int width, int height, bool inverted) - where TColor : struct, IPixel + private void ReadRgb24(PixelAccessor pixels, int width, int height, bool inverted) + where TPixel : struct, IPixel { int padding = CalculatePadding(width, 3); - using (PixelArea row = new PixelArea(width, ComponentOrder.Zyx, padding)) + using (PixelArea row = new PixelArea(width, ComponentOrder.Zyx, padding)) { for (int y = 0; y < height; y++) { @@ -336,16 +336,16 @@ namespace ImageSharp.Formats /// /// Reads the 32 bit color palette from the stream /// - /// The pixel format. - /// The to assign the palette to. + /// The pixel format. + /// The to assign the palette to. /// The width of the bitmap. /// The height of the bitmap. /// Whether the bitmap is inverted. - private void ReadRgb32(PixelAccessor pixels, int width, int height, bool inverted) - where TColor : struct, IPixel + private void ReadRgb32(PixelAccessor pixels, int width, int height, bool inverted) + where TPixel : struct, IPixel { int padding = CalculatePadding(width, 4); - using (PixelArea row = new PixelArea(width, ComponentOrder.Zyxw, padding)) + using (PixelArea row = new PixelArea(width, ComponentOrder.Zyxw, padding)) { for (int y = 0; y < height; y++) { diff --git a/src/ImageSharp/Formats/Bmp/BmpEncoder.cs b/src/ImageSharp/Formats/Bmp/BmpEncoder.cs index d0a3550f6..deca6cf2c 100644 --- a/src/ImageSharp/Formats/Bmp/BmpEncoder.cs +++ b/src/ImageSharp/Formats/Bmp/BmpEncoder.cs @@ -15,8 +15,8 @@ namespace ImageSharp.Formats public class BmpEncoder : IImageEncoder { /// - public void Encode(Image image, Stream stream, IEncoderOptions options) - where TColor : struct, IPixel + public void Encode(Image image, Stream stream, IEncoderOptions options) + where TPixel : struct, IPixel { IBmpEncoderOptions bmpOptions = BmpEncoderOptions.Create(options); @@ -24,14 +24,14 @@ namespace ImageSharp.Formats } /// - /// Encodes the image to the specified stream from the . + /// Encodes the image to the specified stream from the . /// - /// The pixel format. - /// The to encode from. + /// The pixel format. + /// The to encode from. /// The to encode the image data to. /// The options for the encoder. - public void Encode(Image image, Stream stream, IBmpEncoderOptions options) - where TColor : struct, IPixel + public void Encode(Image image, Stream stream, IBmpEncoderOptions options) + where TPixel : struct, IPixel { BmpEncoderCore encoder = new BmpEncoderCore(options); encoder.Encode(image, stream); diff --git a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs index df62fb6f4..634b3a784 100644 --- a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs @@ -35,13 +35,13 @@ namespace ImageSharp.Formats } /// - /// Encodes the image to the specified stream from the . + /// Encodes the image to the specified stream from the . /// - /// The pixel format. - /// The to encode from. + /// The pixel format. + /// The to encode from. /// The to encode the image data to. - public void Encode(ImageBase image, Stream stream) - where TColor : struct, IPixel + public void Encode(ImageBase image, Stream stream) + where TPixel : struct, IPixel { Guard.NotNull(image, nameof(image)); Guard.NotNull(stream, nameof(stream)); @@ -124,15 +124,15 @@ namespace ImageSharp.Formats /// /// Writes the pixel data to the binary stream. /// - /// The pixel format. + /// The pixel format. /// The containing the stream to write to. /// - /// The containing pixel data. + /// The containing pixel data. /// - private void WriteImage(EndianBinaryWriter writer, ImageBase image) - where TColor : struct, IPixel + private void WriteImage(EndianBinaryWriter writer, ImageBase image) + where TPixel : struct, IPixel { - using (PixelAccessor pixels = image.Lock()) + using (PixelAccessor pixels = image.Lock()) { switch (this.options.BitsPerPixel) { @@ -150,13 +150,13 @@ namespace ImageSharp.Formats /// /// Writes the 32bit color palette to the stream. /// - /// The pixel format. + /// The pixel format. /// The containing the stream to write to. - /// The containing pixel data. - private void Write32Bit(EndianBinaryWriter writer, PixelAccessor pixels) - where TColor : struct, IPixel + /// The containing pixel data. + private void Write32Bit(EndianBinaryWriter writer, PixelAccessor pixels) + where TPixel : struct, IPixel { - using (PixelArea row = new PixelArea(pixels.Width, ComponentOrder.Zyxw, this.padding)) + using (PixelArea row = new PixelArea(pixels.Width, ComponentOrder.Zyxw, this.padding)) { for (int y = pixels.Height - 1; y >= 0; y--) { @@ -169,13 +169,13 @@ namespace ImageSharp.Formats /// /// Writes the 24bit color palette to the stream. /// - /// The pixel format. + /// The pixel format. /// The containing the stream to write to. - /// The containing pixel data. - private void Write24Bit(EndianBinaryWriter writer, PixelAccessor pixels) - where TColor : struct, IPixel + /// The containing pixel data. + private void Write24Bit(EndianBinaryWriter writer, PixelAccessor pixels) + where TPixel : struct, IPixel { - using (PixelArea row = new PixelArea(pixels.Width, ComponentOrder.Zyx, this.padding)) + using (PixelArea row = new PixelArea(pixels.Width, ComponentOrder.Zyx, this.padding)) { for (int y = pixels.Height - 1; y >= 0; y--) { diff --git a/src/ImageSharp/Formats/Bmp/ImageExtensions.cs b/src/ImageSharp/Formats/Bmp/ImageExtensions.cs index 5b92b90d6..14d657c32 100644 --- a/src/ImageSharp/Formats/Bmp/ImageExtensions.cs +++ b/src/ImageSharp/Formats/Bmp/ImageExtensions.cs @@ -11,22 +11,22 @@ namespace ImageSharp using Formats; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Saves the image to the given stream with the bmp format. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The stream to save the image to. /// Thrown if the stream is null. /// - /// The . + /// The . /// - public static Image SaveAsBmp(this Image source, Stream stream) - where TColor : struct, IPixel + public static Image SaveAsBmp(this Image source, Stream stream) + where TPixel : struct, IPixel => source.Save(stream, new BmpEncoder()); } } diff --git a/src/ImageSharp/Formats/Gif/GifDecoder.cs b/src/ImageSharp/Formats/Gif/GifDecoder.cs index 2eb89de8f..4ba06efe8 100644 --- a/src/ImageSharp/Formats/Gif/GifDecoder.cs +++ b/src/ImageSharp/Formats/Gif/GifDecoder.cs @@ -14,27 +14,27 @@ namespace ImageSharp.Formats public class GifDecoder : IImageDecoder { /// - public Image Decode(Configuration configuration, Stream stream, IDecoderOptions options) + public Image Decode(Configuration configuration, Stream stream, IDecoderOptions options) - where TColor : struct, IPixel + where TPixel : struct, IPixel { IGifDecoderOptions gifOptions = GifDecoderOptions.Create(options); - return this.Decode(configuration, stream, gifOptions); + return this.Decode(configuration, stream, gifOptions); } /// - /// Decodes the image from the specified stream to the . + /// Decodes the image from the specified stream to the . /// - /// The pixel format. + /// The pixel format. /// The configuration. /// The containing image data. /// The options for the decoder. /// The image thats been decoded. - public Image Decode(Configuration configuration, Stream stream, IGifDecoderOptions options) - where TColor : struct, IPixel + public Image Decode(Configuration configuration, Stream stream, IGifDecoderOptions options) + where TPixel : struct, IPixel { - return new GifDecoderCore(options, configuration).Decode(stream); + return new GifDecoderCore(options, configuration).Decode(stream); } } } diff --git a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs index 4c119ca73..1ee2d152a 100644 --- a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs @@ -13,9 +13,9 @@ namespace ImageSharp.Formats /// /// Performs the gif decoding operation. /// - /// The pixel format. - internal class GifDecoderCore - where TColor : struct, IPixel + /// The pixel format. + internal class GifDecoderCore + where TPixel : struct, IPixel { /// /// The temp buffer used to reduce allocations. @@ -50,7 +50,7 @@ namespace ImageSharp.Formats /// /// The previous frame. /// - private ImageFrame previousFrame; + private ImageFrame previousFrame; /// /// The area to restore. @@ -75,10 +75,10 @@ namespace ImageSharp.Formats /// /// The image to decode the information to. /// - private Image image; + private Image image; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The decoder options. /// The configuration. @@ -93,7 +93,7 @@ namespace ImageSharp.Formats /// /// The stream containing image data. /// The decoded image - public Image Decode(Stream stream) + public Image Decode(Stream stream) { try { @@ -227,10 +227,10 @@ namespace ImageSharp.Formats } /* // No point doing this as the max width/height is always int.Max and that always bigger than the max size of a gif which is stored in a short. - if (this.logicalScreenDescriptor.Width > Image.MaxWidth || this.logicalScreenDescriptor.Height > Image.MaxHeight) + if (this.logicalScreenDescriptor.Width > Image.MaxWidth || this.logicalScreenDescriptor.Height > Image.MaxHeight) { throw new ArgumentOutOfRangeException( - $"The input gif '{this.logicalScreenDescriptor.Width}x{this.logicalScreenDescriptor.Height}' is bigger then the max allowed size '{Image.MaxWidth}x{Image.MaxHeight}'"); + $"The input gif '{this.logicalScreenDescriptor.Width}x{this.logicalScreenDescriptor.Height}' is bigger then the max allowed size '{Image.MaxWidth}x{Image.MaxHeight}'"); } */ } @@ -351,18 +351,18 @@ namespace ImageSharp.Formats int imageWidth = this.logicalScreenDescriptor.Width; int imageHeight = this.logicalScreenDescriptor.Height; - ImageFrame previousFrame = null; + ImageFrame previousFrame = null; - ImageFrame currentFrame = null; + ImageFrame currentFrame = null; - ImageBase image; + ImageBase image; if (this.previousFrame == null) { this.metaData.Quality = colorTableLength / 3; // This initializes the image to become fully transparent because the alpha channel is zero. - this.image = Image.Create(imageWidth, imageHeight, this.metaData, this.configuration); + this.image = Image.Create(imageWidth, imageHeight, this.metaData, this.configuration); this.SetFrameDelay(this.metaData); @@ -392,7 +392,7 @@ namespace ImageSharp.Formats int interlaceIncrement = 8; // The interlacing line increment int interlaceY = 0; // The current interlaced line - using (PixelAccessor pixelAccessor = image.Lock()) + using (PixelAccessor pixelAccessor = image.Lock()) { for (int y = descriptor.Top; y < descriptor.Top + descriptor.Height; y++) { @@ -441,7 +441,7 @@ namespace ImageSharp.Formats { int indexOffset = index * 3; - TColor pixel = default(TColor); + TPixel pixel = default(TPixel); pixel.PackFromBytes(colorTable[indexOffset], colorTable[indexOffset + 1], colorTable[indexOffset + 2], 255); pixelAccessor[x, writeY] = pixel; } @@ -470,7 +470,7 @@ namespace ImageSharp.Formats /// Restores the current frame area to the background. /// /// The frame. - private void RestoreToBackground(ImageBase frame) + private void RestoreToBackground(ImageBase frame) { if (this.restoreArea == null) { @@ -481,16 +481,16 @@ namespace ImageSharp.Formats if (this.restoreArea.Value.Width == this.image.Width && this.restoreArea.Value.Height == this.image.Height) { - using (PixelAccessor pixelAccessor = frame.Lock()) + using (PixelAccessor pixelAccessor = frame.Lock()) { pixelAccessor.Reset(); } } else { - using (PixelArea emptyRow = new PixelArea(this.restoreArea.Value.Width, ComponentOrder.Xyzw)) + using (PixelArea emptyRow = new PixelArea(this.restoreArea.Value.Width, ComponentOrder.Xyzw)) { - using (PixelAccessor pixelAccessor = frame.Lock()) + using (PixelAccessor pixelAccessor = frame.Lock()) { for (int y = this.restoreArea.Value.Top; y < this.restoreArea.Value.Top + this.restoreArea.Value.Height; y++) { diff --git a/src/ImageSharp/Formats/Gif/GifEncoder.cs b/src/ImageSharp/Formats/Gif/GifEncoder.cs index cc8516ed9..005ec1ee2 100644 --- a/src/ImageSharp/Formats/Gif/GifEncoder.cs +++ b/src/ImageSharp/Formats/Gif/GifEncoder.cs @@ -14,8 +14,8 @@ namespace ImageSharp.Formats public class GifEncoder : IImageEncoder { /// - public void Encode(Image image, Stream stream, IEncoderOptions options) - where TColor : struct, IPixel + public void Encode(Image image, Stream stream, IEncoderOptions options) + where TPixel : struct, IPixel { IGifEncoderOptions gifOptions = GifEncoderOptions.Create(options); @@ -23,14 +23,14 @@ namespace ImageSharp.Formats } /// - /// Encodes the image to the specified stream from the . + /// Encodes the image to the specified stream from the . /// - /// The pixel format. - /// The to encode from. + /// The pixel format. + /// The to encode from. /// The to encode the image data to. /// The options for the encoder. - public void Encode(Image image, Stream stream, IGifEncoderOptions options) - where TColor : struct, IPixel + public void Encode(Image image, Stream stream, IGifEncoderOptions options) + where TPixel : struct, IPixel { GifEncoderCore encoder = new GifEncoderCore(options); encoder.Encode(image, stream); diff --git a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs index 38cbba850..dec0dc411 100644 --- a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs @@ -48,18 +48,18 @@ namespace ImageSharp.Formats public IQuantizer Quantizer { get; set; } /// - /// Encodes the image to the specified stream from the . + /// Encodes the image to the specified stream from the . /// - /// The pixel format. - /// The to encode from. + /// The pixel format. + /// The to encode from. /// The to encode the image data to. - public void Encode(Image image, Stream stream) - where TColor : struct, IPixel + public void Encode(Image image, Stream stream) + where TPixel : struct, IPixel { Guard.NotNull(image, nameof(image)); Guard.NotNull(stream, nameof(stream)); - this.Quantizer = this.options.Quantizer ?? new OctreeQuantizer(); + this.Quantizer = this.options.Quantizer ?? new OctreeQuantizer(); // Do not use IDisposable pattern here as we want to preserve the stream. EndianBinaryWriter writer = new EndianBinaryWriter(Endianness.LittleEndian, stream); @@ -72,7 +72,7 @@ namespace ImageSharp.Formats this.bitDepth = ImageMaths.GetBitsNeededForColorDepth(quality); // Quantize the image returning a palette. - QuantizedImage quantized = ((IQuantizer)this.Quantizer).Quantize(image, quality); + QuantizedImage quantized = ((IQuantizer)this.Quantizer).Quantize(image, quality); int index = this.GetTransparentIndex(quantized); @@ -97,8 +97,8 @@ namespace ImageSharp.Formats // ReSharper disable once ForCanBeConvertedToForeach for (int i = 0; i < image.Frames.Count; i++) { - ImageFrame frame = image.Frames[i]; - QuantizedImage quantizedFrame = ((IQuantizer)this.Quantizer).Quantize(frame, quality); + ImageFrame frame = image.Frames[i]; + QuantizedImage quantizedFrame = ((IQuantizer)this.Quantizer).Quantize(frame, quality); this.WriteGraphicalControlExtension(frame, writer, this.GetTransparentIndex(quantizedFrame)); this.WriteImageDescriptor(frame, writer); @@ -117,12 +117,12 @@ namespace ImageSharp.Formats /// /// The quantized. /// - /// The pixel format. + /// The pixel format. /// /// The . /// - private int GetTransparentIndex(QuantizedImage quantized) - where TColor : struct, IPixel + private int GetTransparentIndex(QuantizedImage quantized) + where TPixel : struct, IPixel { // Find the lowest alpha value and make it the transparent index. int index = 255; @@ -167,12 +167,12 @@ namespace ImageSharp.Formats /// /// Writes the logical screen descriptor to the stream. /// - /// The pixel format. + /// The pixel format. /// The image to encode. /// The writer to write to the stream with. /// The transparency index to set the default background index to. - private void WriteLogicalScreenDescriptor(Image image, EndianBinaryWriter writer, int tranparencyIndex) - where TColor : struct, IPixel + private void WriteLogicalScreenDescriptor(Image image, EndianBinaryWriter writer, int tranparencyIndex) + where TPixel : struct, IPixel { GifLogicalScreenDescriptor descriptor = new GifLogicalScreenDescriptor { @@ -233,11 +233,11 @@ namespace ImageSharp.Formats /// /// Writes the image comments to the stream. /// - /// The pixel format. - /// The to be encoded. + /// The pixel format. + /// The to be encoded. /// The stream to write to. - private void WriteComments(Image image, EndianBinaryWriter writer) - where TColor : struct, IPixel + private void WriteComments(Image image, EndianBinaryWriter writer) + where TPixel : struct, IPixel { if (this.options.IgnoreMetadata == true) { @@ -266,12 +266,12 @@ namespace ImageSharp.Formats /// /// Writes the graphics control extension to the stream. /// - /// The pixel format. - /// The to encode. + /// The pixel format. + /// The to encode. /// The stream to write to. /// The index of the color in the color palette to make transparent. - private void WriteGraphicalControlExtension(Image image, EndianBinaryWriter writer, int transparencyIndex) - where TColor : struct, IPixel + private void WriteGraphicalControlExtension(Image image, EndianBinaryWriter writer, int transparencyIndex) + where TPixel : struct, IPixel { this.WriteGraphicalControlExtension(image, image.MetaData, writer, transparencyIndex); } @@ -279,12 +279,12 @@ namespace ImageSharp.Formats /// /// Writes the graphics control extension to the stream. /// - /// The pixel format. - /// The to encode. + /// The pixel format. + /// The to encode. /// The stream to write to. /// The index of the color in the color palette to make transparent. - private void WriteGraphicalControlExtension(ImageFrame imageFrame, EndianBinaryWriter writer, int transparencyIndex) - where TColor : struct, IPixel + private void WriteGraphicalControlExtension(ImageFrame imageFrame, EndianBinaryWriter writer, int transparencyIndex) + where TPixel : struct, IPixel { this.WriteGraphicalControlExtension(imageFrame, imageFrame.MetaData, writer, transparencyIndex); } @@ -292,13 +292,13 @@ namespace ImageSharp.Formats /// /// Writes the graphics control extension to the stream. /// - /// The pixel format. - /// The to encode. + /// The pixel format. + /// The to encode. /// The metadata of the image or frame. /// The stream to write to. /// The index of the color in the color palette to make transparent. - private void WriteGraphicalControlExtension(ImageBase image, IMetaData metaData, EndianBinaryWriter writer, int transparencyIndex) - where TColor : struct, IPixel + private void WriteGraphicalControlExtension(ImageBase image, IMetaData metaData, EndianBinaryWriter writer, int transparencyIndex) + where TPixel : struct, IPixel { // TODO: Check transparency logic. bool hasTransparent = transparencyIndex < 255; @@ -336,11 +336,11 @@ namespace ImageSharp.Formats /// /// Writes the image descriptor to the stream. /// - /// The pixel format. - /// The to be encoded. + /// The pixel format. + /// The to be encoded. /// The stream to write to. - private void WriteImageDescriptor(ImageBase image, EndianBinaryWriter writer) - where TColor : struct, IPixel + private void WriteImageDescriptor(ImageBase image, EndianBinaryWriter writer) + where TPixel : struct, IPixel { writer.Write(GifConstants.ImageDescriptorLabel); // 2c @@ -362,11 +362,11 @@ namespace ImageSharp.Formats /// /// Writes the color table to the stream. /// - /// The pixel format. - /// The to encode. + /// The pixel format. + /// The to encode. /// The writer to write to the stream with. - private void WriteColorTable(QuantizedImage image, EndianBinaryWriter writer) - where TColor : struct, IPixel + private void WriteColorTable(QuantizedImage image, EndianBinaryWriter writer) + where TPixel : struct, IPixel { // Grab the palette and write it to the stream. int pixelCount = image.Palette.Length; @@ -397,11 +397,11 @@ namespace ImageSharp.Formats /// /// Writes the image pixel data to the stream. /// - /// The pixel format. - /// The containing indexed pixels. + /// The pixel format. + /// The containing indexed pixels. /// The stream to write to. - private void WriteImageData(QuantizedImage image, EndianBinaryWriter writer) - where TColor : struct, IPixel + private void WriteImageData(QuantizedImage image, EndianBinaryWriter writer) + where TPixel : struct, IPixel { using (LzwEncoder encoder = new LzwEncoder(image.Pixels, (byte)this.bitDepth)) { diff --git a/src/ImageSharp/Formats/Gif/ImageExtensions.cs b/src/ImageSharp/Formats/Gif/ImageExtensions.cs index 1ba03ed35..523086ded 100644 --- a/src/ImageSharp/Formats/Gif/ImageExtensions.cs +++ b/src/ImageSharp/Formats/Gif/ImageExtensions.cs @@ -11,22 +11,22 @@ namespace ImageSharp using Formats; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Saves the image to the given stream with the gif format. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The stream to save the image to. /// Thrown if the stream is null. /// - /// The . + /// The . /// - public static Image SaveAsGif(this Image source, Stream stream) - where TColor : struct, IPixel + public static Image SaveAsGif(this Image source, Stream stream) + where TPixel : struct, IPixel { return SaveAsGif(source, stream, null); } @@ -34,16 +34,16 @@ namespace ImageSharp /// /// Saves the image to the given stream with the gif format. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The stream to save the image to. /// The options for the encoder. /// Thrown if the stream is null. /// - /// The . + /// The . /// - public static Image SaveAsGif(this Image source, Stream stream, IGifEncoderOptions options) - where TColor : struct, IPixel + public static Image SaveAsGif(this Image source, Stream stream, IGifEncoderOptions options) + where TPixel : struct, IPixel { GifEncoder encoder = new GifEncoder(); encoder.Encode(source, stream, options); diff --git a/src/ImageSharp/Formats/IImageDecoder.cs b/src/ImageSharp/Formats/IImageDecoder.cs index c85fbef10..2f71108a7 100644 --- a/src/ImageSharp/Formats/IImageDecoder.cs +++ b/src/ImageSharp/Formats/IImageDecoder.cs @@ -14,14 +14,14 @@ namespace ImageSharp.Formats public interface IImageDecoder { /// - /// Decodes the image from the specified stream to the . + /// Decodes the image from the specified stream to the . /// - /// The pixel format. + /// The pixel format. /// The configuration for the image. /// The containing image data. /// The options for the decoder. /// The decoded image - Image Decode(Configuration configuration, Stream stream, IDecoderOptions options) - where TColor : struct, IPixel; + Image Decode(Configuration configuration, Stream stream, IDecoderOptions options) + where TPixel : struct, IPixel; } } diff --git a/src/ImageSharp/Formats/IImageEncoder.cs b/src/ImageSharp/Formats/IImageEncoder.cs index 918f0d273..222fb6ed6 100644 --- a/src/ImageSharp/Formats/IImageEncoder.cs +++ b/src/ImageSharp/Formats/IImageEncoder.cs @@ -14,13 +14,13 @@ namespace ImageSharp.Formats public interface IImageEncoder { /// - /// Encodes the image to the specified stream from the . + /// Encodes the image to the specified stream from the . /// - /// The pixel format. - /// The to encode from. + /// The pixel format. + /// The to encode from. /// The to encode the image data to. /// The options for the encoder. - void Encode(Image image, Stream stream, IEncoderOptions options) - where TColor : struct, IPixel; + void Encode(Image image, Stream stream, IEncoderOptions options) + where TPixel : struct, IPixel; } } diff --git a/src/ImageSharp/Formats/Jpeg/ImageExtensions.cs b/src/ImageSharp/Formats/Jpeg/ImageExtensions.cs index 351275ebb..e52d43625 100644 --- a/src/ImageSharp/Formats/Jpeg/ImageExtensions.cs +++ b/src/ImageSharp/Formats/Jpeg/ImageExtensions.cs @@ -11,22 +11,22 @@ namespace ImageSharp using Formats; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Saves the image to the given stream with the jpeg format. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The stream to save the image to. /// Thrown if the stream is null. /// - /// The . + /// The . /// - public static Image SaveAsJpeg(this Image source, Stream stream) - where TColor : struct, IPixel + public static Image SaveAsJpeg(this Image source, Stream stream) + where TPixel : struct, IPixel { return SaveAsJpeg(source, stream, null); } @@ -34,16 +34,16 @@ namespace ImageSharp /// /// Saves the image to the given stream with the jpeg format. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The stream to save the image to. /// The options for the encoder. /// Thrown if the stream is null. /// - /// The . + /// The . /// - public static Image SaveAsJpeg(this Image source, Stream stream, IJpegEncoderOptions options) - where TColor : struct, IPixel + public static Image SaveAsJpeg(this Image source, Stream stream, IJpegEncoderOptions options) + where TPixel : struct, IPixel { JpegEncoder encoder = new JpegEncoder(); encoder.Encode(source, stream, options); diff --git a/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs index 0aac31603..97593a0a3 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs @@ -14,14 +14,14 @@ namespace ImageSharp.Formats public class JpegDecoder : IImageDecoder { /// - public Image Decode(Configuration configuration, Stream stream, IDecoderOptions options) - where TColor : struct, IPixel + public Image Decode(Configuration configuration, Stream stream, IDecoderOptions options) + where TPixel : struct, IPixel { Guard.NotNull(stream, "stream"); using (JpegDecoderCore decoder = new JpegDecoderCore(options, configuration)) { - return decoder.Decode(stream); + return decoder.Decode(stream); } } } diff --git a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs index 33533aa12..ccc6b91bb 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs @@ -121,7 +121,7 @@ namespace ImageSharp.Formats /// /// Gets the array of -s storing the "raw" frequency-domain decoded blocks. /// We need to apply IDCT, dequantiazition and unzigging to transform them into color-space blocks. - /// This is done by . + /// This is done by . /// When ==true, we are touching these blocks multiple times - each time we process a Scan. /// public DecodedBlockArray[] DecodedBlocks { get; } @@ -186,16 +186,16 @@ namespace ImageSharp.Formats /// Decodes the image from the specified and sets /// the data to image. /// - /// The pixel format. + /// The pixel format. /// The stream, where the image should be. /// The decoded image. - public Image Decode(Stream stream) - where TColor : struct, IPixel + public Image Decode(Stream stream) + where TPixel : struct, IPixel { ImageMetaData metadata = new ImageMetaData(); this.ProcessStream(metadata, stream, false); - this.ProcessBlocksIntoJpegImageChannels(); - Image image = this.ConvertJpegPixelsToImagePixels(metadata); + this.ProcessBlocksIntoJpegImageChannels(); + Image image = this.ConvertJpegPixelsToImagePixels(metadata); return image; } @@ -254,14 +254,14 @@ namespace ImageSharp.Formats /// Optimized method to pack bytes to the image from the YCbCr color space. /// This is faster than implicit casting as it avoids double packing. /// - /// The pixel format. + /// The pixel format. /// The packed pixel. /// The y luminance component. /// The cb chroma component. /// The cr chroma component. [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static void PackYcbCr(ref TColor packed, byte y, byte cb, byte cr) - where TColor : struct, IPixel + private static void PackYcbCr(ref TPixel packed, byte y, byte cb, byte cr) + where TPixel : struct, IPixel { int ccb = cb - 128; int ccr = cr - 128; @@ -481,9 +481,9 @@ namespace ImageSharp.Formats /// are in a "raw" frequency-domain form. We need to apply IDCT, dequantization and unzigging to transform them into color-space blocks. /// We can copy these blocks into -s afterwards. /// - /// The pixel type - private void ProcessBlocksIntoJpegImageChannels() - where TColor : struct, IPixel + /// The pixel type + private void ProcessBlocksIntoJpegImageChannels() + where TPixel : struct, IPixel { Parallel.For( 0, @@ -497,15 +497,15 @@ namespace ImageSharp.Formats } /// - /// Convert the pixel data in and/or into pixels of + /// Convert the pixel data in and/or into pixels of /// - /// The pixel type + /// The pixel type /// The metadata for the image. /// The decoded image. - private Image ConvertJpegPixelsToImagePixels(ImageMetaData metadata) - where TColor : struct, IPixel + private Image ConvertJpegPixelsToImagePixels(ImageMetaData metadata) + where TPixel : struct, IPixel { - Image image = Image.Create(this.ImageWidth, this.ImageHeight, metadata, this.configuration); + Image image = Image.Create(this.ImageWidth, this.ImageHeight, metadata, this.configuration); if (this.grayImage.IsInitialized) { @@ -561,10 +561,10 @@ namespace ImageSharp.Formats /// /// Assigns the horizontal and vertical resolution to the image if it has a JFIF header. /// - /// The pixel format. + /// The pixel format. /// The image to assign the resolution to. - private void AssignResolution(Image image) - where TColor : struct, IPixel + private void AssignResolution(Image image) + where TPixel : struct, IPixel { if (this.isJfif && this.horizontalResolution > 0 && this.verticalResolution > 0) { @@ -589,14 +589,14 @@ namespace ImageSharp.Formats /// /// Converts the image from the original CMYK image pixels. /// - /// The pixel format. + /// The pixel format. /// The image. - private void ConvertFromCmyk(Image image) - where TColor : struct, IPixel + private void ConvertFromCmyk(Image image) + where TPixel : struct, IPixel { int scale = this.ComponentArray[0].HorizontalFactor / this.ComponentArray[1].HorizontalFactor; - using (PixelAccessor pixels = image.Lock()) + using (PixelAccessor pixels = image.Lock()) { Parallel.For( 0, @@ -613,7 +613,7 @@ namespace ImageSharp.Formats byte magenta = this.ycbcrImage.CbChannel.Pixels[co + (x / scale)]; byte yellow = this.ycbcrImage.CrChannel.Pixels[co + (x / scale)]; - TColor packed = default(TColor); + TPixel packed = default(TPixel); this.PackCmyk(ref packed, cyan, magenta, yellow, x, y); pixels[x, y] = packed; } @@ -626,12 +626,12 @@ namespace ImageSharp.Formats /// /// Converts the image from the original grayscale image pixels. /// - /// The pixel format. + /// The pixel format. /// The image. - private void ConvertFromGrayScale(Image image) - where TColor : struct, IPixel + private void ConvertFromGrayScale(Image image) + where TPixel : struct, IPixel { - using (PixelAccessor pixels = image.Lock()) + using (PixelAccessor pixels = image.Lock()) { Parallel.For( 0, @@ -644,7 +644,7 @@ namespace ImageSharp.Formats { byte rgb = this.grayImage.Pixels[yoff + x]; - TColor packed = default(TColor); + TPixel packed = default(TPixel); packed.PackFromBytes(rgb, rgb, rgb, 255); pixels[x, y] = packed; } @@ -657,14 +657,14 @@ namespace ImageSharp.Formats /// /// Converts the image from the original RBG image pixels. /// - /// The pixel format. + /// The pixel format. /// The image. - private void ConvertFromRGB(Image image) - where TColor : struct, IPixel + private void ConvertFromRGB(Image image) + where TPixel : struct, IPixel { int scale = this.ComponentArray[0].HorizontalFactor / this.ComponentArray[1].HorizontalFactor; - using (PixelAccessor pixels = image.Lock()) + using (PixelAccessor pixels = image.Lock()) { Parallel.For( 0, @@ -682,7 +682,7 @@ namespace ImageSharp.Formats byte green = this.ycbcrImage.CbChannel.Pixels[co + (x / scale)]; byte blue = this.ycbcrImage.CrChannel.Pixels[co + (x / scale)]; - TColor packed = default(TColor); + TPixel packed = default(TPixel); packed.PackFromBytes(red, green, blue, 255); pixels[x, y] = packed; } @@ -695,13 +695,13 @@ namespace ImageSharp.Formats /// /// Converts the image from the original YCbCr image pixels. /// - /// The pixel format. + /// The pixel format. /// The image. - private void ConvertFromYCbCr(Image image) - where TColor : struct, IPixel + private void ConvertFromYCbCr(Image image) + where TPixel : struct, IPixel { int scale = this.ComponentArray[0].HorizontalFactor / this.ComponentArray[1].HorizontalFactor; - using (PixelAccessor pixels = image.Lock()) + using (PixelAccessor pixels = image.Lock()) { Parallel.For( 0, @@ -719,8 +719,8 @@ namespace ImageSharp.Formats byte cb = this.ycbcrImage.CbChannel.Pixels[co + (x / scale)]; byte cr = this.ycbcrImage.CrChannel.Pixels[co + (x / scale)]; - TColor packed = default(TColor); - PackYcbCr(ref packed, yy, cb, cr); + TPixel packed = default(TPixel); + PackYcbCr(ref packed, yy, cb, cr); pixels[x, y] = packed; } }); @@ -732,14 +732,14 @@ namespace ImageSharp.Formats /// /// Converts the image from the original YCCK image pixels. /// - /// The pixel format. + /// The pixel format. /// The image. - private void ConvertFromYcck(Image image) - where TColor : struct, IPixel + private void ConvertFromYcck(Image image) + where TPixel : struct, IPixel { int scale = this.ComponentArray[0].HorizontalFactor / this.ComponentArray[1].HorizontalFactor; - using (PixelAccessor pixels = image.Lock()) + using (PixelAccessor pixels = image.Lock()) { Parallel.For( 0, @@ -756,7 +756,7 @@ namespace ImageSharp.Formats byte cb = this.ycbcrImage.CbChannel.Pixels[co + (x / scale)]; byte cr = this.ycbcrImage.CrChannel.Pixels[co + (x / scale)]; - TColor packed = default(TColor); + TPixel packed = default(TPixel); this.PackYcck(ref packed, yy, cb, cr, x, y); pixels[x, y] = packed; } @@ -850,15 +850,15 @@ namespace ImageSharp.Formats /// Optimized method to pack bytes to the image from the CMYK color space. /// This is faster than implicit casting as it avoids double packing. /// - /// The pixel format. + /// The pixel format. /// The packed pixel. /// The cyan component. /// The magenta component. /// The yellow component. /// The x-position within the image. /// The y-position within the image. - private void PackCmyk(ref TColor packed, byte c, byte m, byte y, int xx, int yy) - where TColor : struct, IPixel + private void PackCmyk(ref TPixel packed, byte c, byte m, byte y, int xx, int yy) + where TPixel : struct, IPixel { // Get keyline float keyline = (255 - this.blackImage[xx, yy]) / 255F; @@ -875,15 +875,15 @@ namespace ImageSharp.Formats /// Optimized method to pack bytes to the image from the YCCK color space. /// This is faster than implicit casting as it avoids double packing. /// - /// The pixel format. + /// The pixel format. /// The packed pixel. /// The y luminance component. /// The cb chroma component. /// The cr chroma component. /// The x-position within the image. /// The y-position within the image. - private void PackYcck(ref TColor packed, byte y, byte cb, byte cr, int xx, int yy) - where TColor : struct, IPixel + private void PackYcck(ref TPixel packed, byte y, byte cb, byte cr, int xx, int yy) + where TPixel : struct, IPixel { // Convert the YCbCr part of the YCbCrK to RGB, invert the RGB to get // CMY, and patch in the original K. The RGB to CMY inversion cancels diff --git a/src/ImageSharp/Formats/Jpeg/JpegEncoder.cs b/src/ImageSharp/Formats/Jpeg/JpegEncoder.cs index 2f2823fa2..dd467462b 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegEncoder.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegEncoder.cs @@ -13,8 +13,8 @@ namespace ImageSharp.Formats public class JpegEncoder : IImageEncoder { /// - public void Encode(Image image, Stream stream, IEncoderOptions options) - where TColor : struct, IPixel + public void Encode(Image image, Stream stream, IEncoderOptions options) + where TPixel : struct, IPixel { IJpegEncoderOptions gifOptions = JpegEncoderOptions.Create(options); @@ -22,14 +22,14 @@ namespace ImageSharp.Formats } /// - /// Encodes the image to the specified stream from the . + /// Encodes the image to the specified stream from the . /// - /// The pixel format. - /// The to encode from. + /// The pixel format. + /// The to encode from. /// The to encode the image data to. /// The options for the encoder. - public void Encode(Image image, Stream stream, IJpegEncoderOptions options) - where TColor : struct, IPixel + public void Encode(Image image, Stream stream, IJpegEncoderOptions options) + where TPixel : struct, IPixel { JpegEncoderCore encode = new JpegEncoderCore(options); encode.Encode(image, stream); diff --git a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs index c3cf75a0f..e29b5474b 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs @@ -165,11 +165,11 @@ namespace ImageSharp.Formats /// /// Encode writes the image to the jpeg baseline format with the given options. /// - /// The pixel format. + /// The pixel format. /// The image to write from. /// The stream to write to. - public void Encode(Image image, Stream stream) - where TColor : struct, IPixel + public void Encode(Image image, Stream stream) + where TPixel : struct, IPixel { Guard.NotNull(image, nameof(image)); Guard.NotNull(stream, nameof(stream)); @@ -225,7 +225,7 @@ namespace ImageSharp.Formats this.WriteDefineHuffmanTables(componentCount); // Write the image data. - using (PixelAccessor pixels = image.Lock()) + using (PixelAccessor pixels = image.Lock()) { this.WriteStartOfScan(pixels); } @@ -282,23 +282,23 @@ namespace ImageSharp.Formats /// /// Converts the 8x8 region of the image whose top-left corner is x,y to its YCbCr values. /// - /// The pixel format. + /// The pixel format. /// The pixel accessor. /// The x-position within the image. /// The y-position within the image. /// The luminance block. /// The red chroma block. /// The blue chroma block. - /// Temporal provided by the caller - private static void ToYCbCr( - PixelAccessor pixels, + /// Temporal provided by the caller + private static void ToYCbCr( + PixelAccessor pixels, int x, int y, Block8x8F* yBlock, Block8x8F* cbBlock, Block8x8F* crBlock, - PixelArea rgbBytes) - where TColor : struct, IPixel + PixelArea rgbBytes) + where TPixel : struct, IPixel { float* yBlockRaw = (float*)yBlock; float* cbBlockRaw = (float*)cbBlock; @@ -442,12 +442,12 @@ namespace ImageSharp.Formats /// /// Encodes the image with no subsampling. /// - /// The pixel format. + /// The pixel format. /// The pixel accessor providing access to the image pixels. - private void Encode444(PixelAccessor pixels) - where TColor : struct, IPixel + private void Encode444(PixelAccessor pixels) + where TPixel : struct, IPixel { - // TODO: Need a JpegScanEncoder class or struct that encapsulates the scan-encoding implementation. (Similar to JpegScanDecoder.) + // TODO: Need a JpegScanEncoder class or struct that encapsulates the scan-encoding implementation. (Similar to JpegScanDecoder.) Block8x8F b = default(Block8x8F); Block8x8F cb = default(Block8x8F); Block8x8F cr = default(Block8x8F); @@ -463,7 +463,7 @@ namespace ImageSharp.Formats // ReSharper disable once InconsistentNaming int prevDCY = 0, prevDCCb = 0, prevDCCr = 0; - using (PixelArea rgbBytes = new PixelArea(8, 8, ComponentOrder.Xyz)) + using (PixelArea rgbBytes = new PixelArea(8, 8, ComponentOrder.Xyz)) { for (int y = 0; y < pixels.Height; y += 8) { @@ -714,9 +714,9 @@ namespace ImageSharp.Formats /// Writes the metadata profiles to the image. /// /// The image. - /// The pixel format. - private void WriteProfiles(Image image) - where TColor : struct, IPixel + /// The pixel format. + private void WriteProfiles(Image image) + where TPixel : struct, IPixel { if (this.options.IgnoreMetadata) { @@ -786,12 +786,12 @@ namespace ImageSharp.Formats /// /// Writes the StartOfScan marker. /// - /// The pixel format. + /// The pixel format. /// The pixel accessor providing access to the image pixels. - private void WriteStartOfScan(PixelAccessor pixels) - where TColor : struct, IPixel + private void WriteStartOfScan(PixelAccessor pixels) + where TPixel : struct, IPixel { - // TODO: Need a JpegScanEncoder class or struct that encapsulates the scan-encoding implementation. (Similar to JpegScanDecoder.) + // TODO: Need a JpegScanEncoder class or struct that encapsulates the scan-encoding implementation. (Similar to JpegScanDecoder.) // TODO: We should allow grayscale writing. this.outputStream.Write(SosHeaderYCbCr, 0, SosHeaderYCbCr.Length); @@ -813,12 +813,12 @@ namespace ImageSharp.Formats /// Encodes the image with subsampling. The Cb and Cr components are each subsampled /// at a factor of 2 both horizontally and vertically. /// - /// The pixel format. + /// The pixel format. /// The pixel accessor providing access to the image pixels. - private void Encode420(PixelAccessor pixels) - where TColor : struct, IPixel + private void Encode420(PixelAccessor pixels) + where TPixel : struct, IPixel { - // TODO: Need a JpegScanEncoder class or struct that encapsulates the scan-encoding implementation. (Similar to JpegScanDecoder.) + // TODO: Need a JpegScanEncoder class or struct that encapsulates the scan-encoding implementation. (Similar to JpegScanDecoder.) Block8x8F b = default(Block8x8F); BlockQuad cb = default(BlockQuad); @@ -837,7 +837,7 @@ namespace ImageSharp.Formats // ReSharper disable once InconsistentNaming int prevDCY = 0, prevDCCb = 0, prevDCCr = 0; - using (PixelArea rgbBytes = new PixelArea(8, 8, ComponentOrder.Xyz)) + using (PixelArea rgbBytes = new PixelArea(8, 8, ComponentOrder.Xyz)) { for (int y = 0; y < pixels.Height; y += 16) { diff --git a/src/ImageSharp/Formats/Jpeg/Utils/JpegUtils.cs b/src/ImageSharp/Formats/Jpeg/Utils/JpegUtils.cs index ace309812..73918c060 100644 --- a/src/ImageSharp/Formats/Jpeg/Utils/JpegUtils.cs +++ b/src/ImageSharp/Formats/Jpeg/Utils/JpegUtils.cs @@ -16,17 +16,17 @@ namespace ImageSharp.Formats.Jpg /// /// Copy a region of an image into dest. De "outlier" area will be stretched out with pixels on the right and bottom of the image. /// - /// The pixel type + /// The pixel type /// The input pixel acessor - /// The destination + /// The destination /// Starting Y coord /// Starting X coord - public static void CopyRGBBytesStretchedTo( - this PixelAccessor pixels, - PixelArea dest, + public static void CopyRGBBytesStretchedTo( + this PixelAccessor pixels, + PixelArea dest, int sourceY, int sourceX) - where TColor : struct, IPixel + where TPixel : struct, IPixel { pixels.SafeCopyTo(dest, sourceY, sourceX); int stretchFromX = pixels.Width - sourceX; @@ -36,14 +36,14 @@ namespace ImageSharp.Formats.Jpg // Nothing to stretch if (fromX, fromY) is outside the area, or is at (0,0) [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static bool IsInvalidStretchStartingPosition(PixelArea area, int fromX, int fromY) - where TColor : struct, IPixel + private static bool IsInvalidStretchStartingPosition(PixelArea area, int fromX, int fromY) + where TPixel : struct, IPixel { return fromX <= 0 || fromY <= 0 || fromX >= area.Width || fromY >= area.Height; } - private static void StretchPixels(PixelArea area, int fromX, int fromY) - where TColor : struct, IPixel + private static void StretchPixels(PixelArea area, int fromX, int fromY) + where TPixel : struct, IPixel { if (IsInvalidStretchStartingPosition(area, fromX, fromY)) { @@ -75,8 +75,8 @@ namespace ImageSharp.Formats.Jpg } [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static ref RGB24 GetRowStart(PixelArea area, int y) - where TColor : struct, IPixel + private static ref RGB24 GetRowStart(PixelArea area, int y) + where TPixel : struct, IPixel { return ref Unsafe.As(ref area.GetRowSpan(y).DangerousGetPinnableReference()); } diff --git a/src/ImageSharp/Formats/Png/ImageExtensions.cs b/src/ImageSharp/Formats/Png/ImageExtensions.cs index 79e96175c..277a3397e 100644 --- a/src/ImageSharp/Formats/Png/ImageExtensions.cs +++ b/src/ImageSharp/Formats/Png/ImageExtensions.cs @@ -10,22 +10,22 @@ namespace ImageSharp using Formats; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Saves the image to the given stream with the png format. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The stream to save the image to. /// Thrown if the stream is null. /// - /// The . + /// The . /// - public static Image SaveAsPng(this Image source, Stream stream) - where TColor : struct, IPixel + public static Image SaveAsPng(this Image source, Stream stream) + where TPixel : struct, IPixel { return SaveAsPng(source, stream, null); } @@ -33,16 +33,16 @@ namespace ImageSharp /// /// Saves the image to the given stream with the png format. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The stream to save the image to. /// The options for the encoder. /// Thrown if the stream is null. /// - /// The . + /// The . /// - public static Image SaveAsPng(this Image source, Stream stream, IPngEncoderOptions options) - where TColor : struct, IPixel + public static Image SaveAsPng(this Image source, Stream stream, IPngEncoderOptions options) + where TPixel : struct, IPixel { PngEncoder encoder = new PngEncoder(); encoder.Encode(source, stream, options); diff --git a/src/ImageSharp/Formats/Png/PngDecoder.cs b/src/ImageSharp/Formats/Png/PngDecoder.cs index d0a820c17..8dd9168f4 100644 --- a/src/ImageSharp/Formats/Png/PngDecoder.cs +++ b/src/ImageSharp/Formats/Png/PngDecoder.cs @@ -31,27 +31,27 @@ namespace ImageSharp.Formats public class PngDecoder : IImageDecoder { /// - public Image Decode(Configuration configuration, Stream stream, IDecoderOptions options) + public Image Decode(Configuration configuration, Stream stream, IDecoderOptions options) - where TColor : struct, IPixel + where TPixel : struct, IPixel { IPngDecoderOptions pngOptions = PngDecoderOptions.Create(options); - return this.Decode(configuration, stream, pngOptions); + return this.Decode(configuration, stream, pngOptions); } /// - /// Decodes the image from the specified stream to the . + /// Decodes the image from the specified stream to the . /// - /// The pixel format. + /// The pixel format. /// The configuration for the image. /// The containing image data. /// The options for the decoder. /// The decoded image. - public Image Decode(Configuration configuration, Stream stream, IPngDecoderOptions options) - where TColor : struct, IPixel + public Image Decode(Configuration configuration, Stream stream, IPngDecoderOptions options) + where TPixel : struct, IPixel { - return new PngDecoderCore(options, configuration).Decode(stream); + return new PngDecoderCore(options, configuration).Decode(stream); } } } diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index 5ce9b5eb0..d64978385 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -154,7 +154,7 @@ namespace ImageSharp.Formats /// /// Decodes the stream to the image. /// - /// The pixel format. + /// The pixel format. /// The stream containing image data. /// /// Thrown if the stream does not contain and end chunk. @@ -163,8 +163,8 @@ namespace ImageSharp.Formats /// Thrown if the image is larger than the maximum allowable size. /// /// The decoded image - public Image Decode(Stream stream) - where TColor : struct, IPixel + public Image Decode(Stream stream) + where TPixel : struct, IPixel { ImageMetaData metadata = new ImageMetaData(); this.currentStream = stream; @@ -215,14 +215,14 @@ namespace ImageSharp.Formats } } - if (this.header.Width > Image.MaxWidth || this.header.Height > Image.MaxHeight) + if (this.header.Width > Image.MaxWidth || this.header.Height > Image.MaxHeight) { - throw new ArgumentOutOfRangeException($"The input png '{this.header.Width}x{this.header.Height}' is bigger than the max allowed size '{Image.MaxWidth}x{Image.MaxHeight}'"); + throw new ArgumentOutOfRangeException($"The input png '{this.header.Width}x{this.header.Height}' is bigger than the max allowed size '{Image.MaxWidth}x{Image.MaxHeight}'"); } - Image image = Image.Create(this.header.Width, this.header.Height, metadata, this.configuration); + Image image = Image.Create(this.header.Width, this.header.Height, metadata, this.configuration); - using (PixelAccessor pixels = image.Lock()) + using (PixelAccessor pixels = image.Lock()) { this.ReadScanlines(dataStream, pixels); } @@ -340,11 +340,11 @@ namespace ImageSharp.Formats /// /// Reads the scanlines within the image. /// - /// The pixel format. + /// The pixel format. /// The containing data. /// The pixel data. - private void ReadScanlines(MemoryStream dataStream, PixelAccessor pixels) - where TColor : struct, IPixel + private void ReadScanlines(MemoryStream dataStream, PixelAccessor pixels) + where TPixel : struct, IPixel { this.bytesPerPixel = this.CalculateBytesPerPixel(); this.bytesPerScanline = this.CalculateScanlineLength(this.header.Width) + 1; @@ -371,11 +371,11 @@ namespace ImageSharp.Formats /// /// Decodes the raw pixel data row by row /// - /// The pixel format. + /// The pixel format. /// The compressed pixel data stream. /// The image pixel accessor. - private void DecodePixelData(Stream compressedStream, PixelAccessor pixels) - where TColor : struct, IPixel + private void DecodePixelData(Stream compressedStream, PixelAccessor pixels) + where TPixel : struct, IPixel { byte[] previousScanline = ArrayPool.Shared.Rent(this.bytesPerScanline); byte[] scanline = ArrayPool.Shared.Rent(this.bytesPerScanline); @@ -444,11 +444,11 @@ namespace ImageSharp.Formats /// Decodes the raw interlaced pixel data row by row /// /// - /// The pixel format. + /// The pixel format. /// The compressed pixel data stream. /// The image pixel accessor. - private void DecodeInterlacedPixelData(Stream compressedStream, PixelAccessor pixels) - where TColor : struct, IPixel + private void DecodeInterlacedPixelData(Stream compressedStream, PixelAccessor pixels) + where TPixel : struct, IPixel { byte[] previousScanline = ArrayPool.Shared.Rent(this.bytesPerScanline); byte[] scanline = ArrayPool.Shared.Rent(this.bytesPerScanline); @@ -532,14 +532,14 @@ namespace ImageSharp.Formats /// /// Processes the de-filtered scanline filling the image pixel data /// - /// The pixel format. + /// The pixel format. /// The de-filtered scanline /// The current image row. /// The image pixels - private void ProcessDefilteredScanline(byte[] defilteredScanline, int row, PixelAccessor pixels) - where TColor : struct, IPixel + private void ProcessDefilteredScanline(byte[] defilteredScanline, int row, PixelAccessor pixels) + where TPixel : struct, IPixel { - TColor color = default(TColor); + TPixel color = default(TPixel); switch (this.PngColorType) { case PngColorType.Grayscale: @@ -655,16 +655,16 @@ namespace ImageSharp.Formats /// /// Processes the interlaced de-filtered scanline filling the image pixel data /// - /// The pixel format. + /// The pixel format. /// The de-filtered scanline /// The current image row. /// The image pixels /// The column start index. Always 0 for none interlaced images. /// The column increment. Always 1 for none interlaced images. - private void ProcessInterlacedDefilteredScanline(byte[] defilteredScanline, int row, PixelAccessor pixels, int pixelOffset = 0, int increment = 1) - where TColor : struct, IPixel + private void ProcessInterlacedDefilteredScanline(byte[] defilteredScanline, int row, PixelAccessor pixels, int pixelOffset = 0, int increment = 1) + where TPixel : struct, IPixel { - TColor color = default(TColor); + TPixel color = default(TPixel); switch (this.PngColorType) { diff --git a/src/ImageSharp/Formats/Png/PngEncoder.cs b/src/ImageSharp/Formats/Png/PngEncoder.cs index e583f381f..a74916f2f 100644 --- a/src/ImageSharp/Formats/Png/PngEncoder.cs +++ b/src/ImageSharp/Formats/Png/PngEncoder.cs @@ -13,8 +13,8 @@ namespace ImageSharp.Formats public class PngEncoder : IImageEncoder { /// - public void Encode(Image image, Stream stream, IEncoderOptions options) - where TColor : struct, IPixel + public void Encode(Image image, Stream stream, IEncoderOptions options) + where TPixel : struct, IPixel { IPngEncoderOptions pngOptions = PngEncoderOptions.Create(options); @@ -22,14 +22,14 @@ namespace ImageSharp.Formats } /// - /// Encodes the image to the specified stream from the . + /// Encodes the image to the specified stream from the . /// - /// The pixel format. - /// The to encode from. + /// The pixel format. + /// The to encode from. /// The to encode the image data to. /// The options for the encoder. - public void Encode(Image image, Stream stream, IPngEncoderOptions options) - where TColor : struct, IPixel + public void Encode(Image image, Stream stream, IPngEncoderOptions options) + where TPixel : struct, IPixel { PngEncoderCore encode = new PngEncoderCore(options); encode.Encode(image, stream); diff --git a/src/ImageSharp/Formats/Png/PngEncoderCore.cs b/src/ImageSharp/Formats/Png/PngEncoderCore.cs index c11fc94df..e17902b5a 100644 --- a/src/ImageSharp/Formats/Png/PngEncoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngEncoderCore.cs @@ -114,13 +114,13 @@ namespace ImageSharp.Formats } /// - /// Encodes the image to the specified stream from the . + /// Encodes the image to the specified stream from the . /// - /// The pixel format. - /// The to encode from. + /// The pixel format. + /// The to encode from. /// The to encode the image data to. - public void Encode(Image image, Stream stream) - where TColor : struct, IPixel + public void Encode(Image image, Stream stream) + where TPixel : struct, IPixel { Guard.NotNull(image, nameof(image)); Guard.NotNull(stream, nameof(stream)); @@ -196,7 +196,7 @@ namespace ImageSharp.Formats this.WritePhysicalChunk(stream, image); this.WriteGammaChunk(stream); - using (PixelAccessor pixels = image.Lock()) + using (PixelAccessor pixels = image.Lock()) { this.WriteDataChunks(pixels, stream); } @@ -248,27 +248,27 @@ namespace ImageSharp.Formats /// /// Collects the indexed pixel data. /// - /// The pixel format. + /// The pixel format. /// The image to encode. /// The containing image data. /// The . - private void CollectIndexedBytes(ImageBase image, Stream stream, PngHeader header) - where TColor : struct, IPixel + private void CollectIndexedBytes(ImageBase image, Stream stream, PngHeader header) + where TPixel : struct, IPixel { // Quantize the image and get the pixels. - QuantizedImage quantized = this.WritePaletteChunk(stream, header, image); + QuantizedImage quantized = this.WritePaletteChunk(stream, header, image); this.palettePixelData = quantized.Pixels; } /// /// Collects a row of grayscale pixels. /// - /// The pixel format. + /// The pixel format. /// The image pixels accessor. /// The row index. /// The raw scanline. - private void CollectGrayscaleBytes(PixelAccessor pixels, int row, byte[] rawScanline) - where TColor : struct, IPixel + private void CollectGrayscaleBytes(PixelAccessor pixels, int row, byte[] rawScanline) + where TPixel : struct, IPixel { // Copy the pixels across from the image. // Reuse the chunk type buffer. @@ -297,15 +297,15 @@ namespace ImageSharp.Formats /// /// Collects a row of true color pixel data. /// - /// The pixel format. + /// The pixel format. /// The image pixel accessor. /// The row index. /// The raw scanline. - private void CollectColorBytes(PixelAccessor pixels, int row, byte[] rawScanline) - where TColor : struct, IPixel + private void CollecTPixelBytes(PixelAccessor pixels, int row, byte[] rawScanline) + where TPixel : struct, IPixel { // We can use the optimized PixelAccessor here and copy the bytes in unmanaged memory. - using (PixelArea pixelRow = new PixelArea(this.width, rawScanline, this.bytesPerPixel == 4 ? ComponentOrder.Xyzw : ComponentOrder.Xyz)) + using (PixelArea pixelRow = new PixelArea(this.width, rawScanline, this.bytesPerPixel == 4 ? ComponentOrder.Xyzw : ComponentOrder.Xyz)) { pixels.CopyTo(pixelRow, row); } @@ -315,15 +315,15 @@ namespace ImageSharp.Formats /// Encodes the pixel data line by line. /// Each scanline is encoded in the most optimal manner to improve compression. /// - /// The pixel format. + /// The pixel format. /// The image pixel accessor. /// The row. /// The previous scanline. /// The raw scanline. /// The filtered scanline result. /// The - private byte[] EncodePixelRow(PixelAccessor pixels, int row, byte[] previousScanline, byte[] rawScanline, byte[] result) - where TColor : struct, IPixel + private byte[] EncodePixelRow(PixelAccessor pixels, int row, byte[] previousScanline, byte[] rawScanline, byte[] result) + where TPixel : struct, IPixel { switch (this.pngColorType) { @@ -335,7 +335,7 @@ namespace ImageSharp.Formats this.CollectGrayscaleBytes(pixels, row, rawScanline); break; default: - this.CollectColorBytes(pixels, row, rawScanline); + this.CollecTPixelBytes(pixels, row, rawScanline); break; } @@ -471,13 +471,13 @@ namespace ImageSharp.Formats /// /// Writes the palette chunk to the stream. /// - /// The pixel format. + /// The pixel format. /// The containing image data. /// The . /// The image to encode. - /// The - private QuantizedImage WritePaletteChunk(Stream stream, PngHeader header, ImageBase image) - where TColor : struct, IPixel + /// The + private QuantizedImage WritePaletteChunk(Stream stream, PngHeader header, ImageBase image) + where TPixel : struct, IPixel { if (this.quality > 256) { @@ -486,14 +486,14 @@ namespace ImageSharp.Formats if (this.quantizer == null) { - this.quantizer = new WuQuantizer(); + this.quantizer = new WuQuantizer(); } // Quantize the image returning a palette. This boxing is icky. - QuantizedImage quantized = ((IQuantizer)this.quantizer).Quantize(image, this.quality); + QuantizedImage quantized = ((IQuantizer)this.quantizer).Quantize(image, this.quality); // Grab the palette and write it to the stream. - TColor[] palette = quantized.Palette; + TPixel[] palette = quantized.Palette; byte pixelCount = palette.Length.ToByte(); // Get max colors for bit depth. @@ -548,11 +548,11 @@ namespace ImageSharp.Formats /// /// Writes the physical dimension information to the stream. /// - /// The pixel format. + /// The pixel format. /// The containing image data. /// The image. - private void WritePhysicalChunk(Stream stream, Image image) - where TColor : struct, IPixel + private void WritePhysicalChunk(Stream stream, Image image) + where TPixel : struct, IPixel { if (image.MetaData.HorizontalResolution > 0 && image.MetaData.VerticalResolution > 0) { @@ -593,11 +593,11 @@ namespace ImageSharp.Formats /// /// Writes the pixel information to the stream. /// - /// The pixel format. + /// The pixel format. /// The pixel accessor. /// The stream. - private void WriteDataChunks(PixelAccessor pixels, Stream stream) - where TColor : struct, IPixel + private void WriteDataChunks(PixelAccessor pixels, Stream stream) + where TPixel : struct, IPixel { int bytesPerScanline = this.width * this.bytesPerPixel; byte[] previousScanline = new byte[bytesPerScanline]; diff --git a/src/ImageSharp/Image.Create.cs b/src/ImageSharp/Image.Create.cs index fe3247049..5fcb2fa21 100644 --- a/src/ImageSharp/Image.Create.cs +++ b/src/ImageSharp/Image.Create.cs @@ -12,10 +12,10 @@ namespace ImageSharp public sealed partial class Image { /// - /// Create a new instance of the class + /// Create a new instance of the class /// with the height and the width of the image. /// - /// The pixel format. + /// The pixel format. /// The width of the image in pixels. /// The height of the image in pixels. /// The images matadata to preload. @@ -23,38 +23,38 @@ namespace ImageSharp /// The configuration providing initialization code which allows extending the library. /// /// - /// A new unless is in which case it returns + /// A new unless is in which case it returns /// - internal static Image Create(int width, int height, ImageMetaData metadata, Configuration configuration) - where TColor : struct, IPixel + internal static Image Create(int width, int height, ImageMetaData metadata, Configuration configuration) + where TPixel : struct, IPixel { - if (typeof(TColor) == typeof(Rgba32)) + if (typeof(TPixel) == typeof(Rgba32)) { - return new Image(width, height, metadata, configuration) as Image; + return new Image(width, height, metadata, configuration) as Image; } else { - return new Image(width, height, metadata, configuration); + return new Image(width, height, metadata, configuration); } } /// - /// Create a new instance of the class + /// Create a new instance of the class /// with the height and the width of the image. /// - /// The pixel format. + /// The pixel format. /// The width of the image in pixels. /// The height of the image in pixels. /// /// The configuration providing initialization code which allows extending the library. /// /// - /// A new unless is in which case it returns + /// A new unless is in which case it returns /// - internal static Image Create(int width, int height, Configuration configuration) - where TColor : struct, IPixel + internal static Image Create(int width, int height, Configuration configuration) + where TPixel : struct, IPixel { - return Image.Create(width, height, null, configuration); + return Image.Create(width, height, null, configuration); } } } \ No newline at end of file diff --git a/src/ImageSharp/Image.Decode.cs b/src/ImageSharp/Image.Decode.cs index c1c137122..5e060ab6b 100644 --- a/src/ImageSharp/Image.Decode.cs +++ b/src/ImageSharp/Image.Decode.cs @@ -51,15 +51,15 @@ namespace ImageSharp /// /// Decodes the image stream to the current image. /// - /// The pixel format. + /// The pixel format. /// The stream. /// The options for the decoder. /// the configuration. /// /// The decoded image /// - private static Image Decode(Stream stream, IDecoderOptions options, Configuration config) - where TColor : struct, IPixel + private static Image Decode(Stream stream, IDecoderOptions options, Configuration config) + where TPixel : struct, IPixel { IImageFormat format = DiscoverFormat(stream, config); if (format == null) @@ -67,7 +67,7 @@ namespace ImageSharp return null; } - Image img = format.Decoder.Decode(config, stream, options); + Image img = format.Decoder.Decode(config, stream, options); img.CurrentImageFormat = format; return img; } diff --git a/src/ImageSharp/Image.FromBytes.cs b/src/ImageSharp/Image.FromBytes.cs index b2f9854f2..b2f39aae6 100644 --- a/src/ImageSharp/Image.FromBytes.cs +++ b/src/ImageSharp/Image.FromBytes.cs @@ -109,70 +109,70 @@ namespace ImageSharp /// /// Loads the image from the given byte array. /// - /// The pixel format. + /// The pixel format. /// The byte array containing image data. /// /// Thrown if the stream is not readable nor seekable. /// /// The image - public static Image Load(byte[] data) - where TColor : struct, IPixel + public static Image Load(byte[] data) + where TPixel : struct, IPixel { - return Load(null, data, null); + return Load(null, data, null); } /// /// Loads the image from the given byte array. /// - /// The pixel format. + /// The pixel format. /// The byte array containing image data. /// The options for the decoder. /// /// Thrown if the stream is not readable nor seekable. /// /// The image - public static Image Load(byte[] data, IDecoderOptions options) - where TColor : struct, IPixel + public static Image Load(byte[] data, IDecoderOptions options) + where TPixel : struct, IPixel { - return Load(null, data, options); + return Load(null, data, options); } /// /// Loads the image from the given byte array. /// - /// The pixel format. + /// The pixel format. /// The config for the decoder. /// The byte array containing image data. /// /// Thrown if the stream is not readable nor seekable. /// /// The image - public static Image Load(Configuration config, byte[] data) - where TColor : struct, IPixel + public static Image Load(Configuration config, byte[] data) + where TPixel : struct, IPixel { - return Load(config, data, null); + return Load(config, data, null); } /// /// Loads the image from the given byte array. /// - /// The pixel format. + /// The pixel format. /// The byte array containing image data. /// The decoder. /// /// Thrown if the stream is not readable nor seekable. /// /// The image - public static Image Load(byte[] data, IImageDecoder decoder) - where TColor : struct, IPixel + public static Image Load(byte[] data, IImageDecoder decoder) + where TPixel : struct, IPixel { - return Load(data, decoder, null); + return Load(data, decoder, null); } /// /// Loads the image from the given byte array. /// - /// The pixel format. + /// The pixel format. /// The configuration options. /// The byte array containing image data. /// The options for the decoder. @@ -180,19 +180,19 @@ namespace ImageSharp /// Thrown if the stream is not readable nor seekable. /// /// The image - public static Image Load(Configuration config, byte[] data, IDecoderOptions options) - where TColor : struct, IPixel + public static Image Load(Configuration config, byte[] data, IDecoderOptions options) + where TPixel : struct, IPixel { using (MemoryStream ms = new MemoryStream(data)) { - return Load(config, ms, options); + return Load(config, ms, options); } } /// /// Loads the image from the given byte array. /// - /// The pixel format. + /// The pixel format. /// The byte array containing image data. /// The decoder. /// The options for the decoder. @@ -200,12 +200,12 @@ namespace ImageSharp /// Thrown if the stream is not readable nor seekable. /// /// The image - public static Image Load(byte[] data, IImageDecoder decoder, IDecoderOptions options) - where TColor : struct, IPixel + public static Image Load(byte[] data, IImageDecoder decoder, IDecoderOptions options) + where TPixel : struct, IPixel { using (MemoryStream ms = new MemoryStream(data)) { - return Load(ms, decoder, options); + return Load(ms, decoder, options); } } } diff --git a/src/ImageSharp/Image.FromFile.cs b/src/ImageSharp/Image.FromFile.cs index 5a2cfc86d..b21307aba 100644 --- a/src/ImageSharp/Image.FromFile.cs +++ b/src/ImageSharp/Image.FromFile.cs @@ -108,70 +108,70 @@ namespace ImageSharp /// /// Loads the image from the given file. /// - /// The pixel format. + /// The pixel format. /// The file path to the image. /// /// Thrown if the stream is not readable nor seekable. /// /// The image - public static Image Load(string path) - where TColor : struct, IPixel + public static Image Load(string path) + where TPixel : struct, IPixel { - return Load(null, path, null); + return Load(null, path, null); } /// /// Loads the image from the given file. /// - /// The pixel format. + /// The pixel format. /// The file path to the image. /// The options for the decoder. /// /// Thrown if the stream is not readable nor seekable. /// /// The image - public static Image Load(string path, IDecoderOptions options) - where TColor : struct, IPixel + public static Image Load(string path, IDecoderOptions options) + where TPixel : struct, IPixel { - return Load(null, path, options); + return Load(null, path, options); } /// /// Loads the image from the given file. /// - /// The pixel format. + /// The pixel format. /// The config for the decoder. /// The file path to the image. /// /// Thrown if the stream is not readable nor seekable. /// /// The image - public static Image Load(Configuration config, string path) - where TColor : struct, IPixel + public static Image Load(Configuration config, string path) + where TPixel : struct, IPixel { - return Load(config, path, null); + return Load(config, path, null); } /// /// Loads the image from the given file. /// - /// The pixel format. + /// The pixel format. /// The file path to the image. /// The decoder. /// /// Thrown if the stream is not readable nor seekable. /// /// The image - public static Image Load(string path, IImageDecoder decoder) - where TColor : struct, IPixel + public static Image Load(string path, IImageDecoder decoder) + where TPixel : struct, IPixel { - return Load(path, decoder, null); + return Load(path, decoder, null); } /// /// Loads the image from the given file. /// - /// The pixel format. + /// The pixel format. /// The configuration options. /// The file path to the image. /// The options for the decoder. @@ -179,20 +179,20 @@ namespace ImageSharp /// Thrown if the stream is not readable nor seekable. /// /// The image - public static Image Load(Configuration config, string path, IDecoderOptions options) - where TColor : struct, IPixel + public static Image Load(Configuration config, string path, IDecoderOptions options) + where TPixel : struct, IPixel { config = config ?? Configuration.Default; using (Stream s = config.FileSystem.OpenRead(path)) { - return Load(config, s, options); + return Load(config, s, options); } } /// /// Loads the image from the given file. /// - /// The pixel format. + /// The pixel format. /// The file path to the image. /// The decoder. /// The options for the decoder. @@ -200,13 +200,13 @@ namespace ImageSharp /// Thrown if the stream is not readable nor seekable. /// /// The image - public static Image Load(string path, IImageDecoder decoder, IDecoderOptions options) - where TColor : struct, IPixel + public static Image Load(string path, IImageDecoder decoder, IDecoderOptions options) + where TPixel : struct, IPixel { Configuration config = Configuration.Default; using (Stream s = config.FileSystem.OpenRead(path)) { - return Load(s, decoder, options); + return Load(s, decoder, options); } } } diff --git a/src/ImageSharp/Image.FromStream.cs b/src/ImageSharp/Image.FromStream.cs index edff0d620..8fb1fac4e 100644 --- a/src/ImageSharp/Image.FromStream.cs +++ b/src/ImageSharp/Image.FromStream.cs @@ -108,70 +108,70 @@ namespace ImageSharp /// /// Loads the image from the given stream. /// - /// The pixel format. + /// The pixel format. /// The stream containing image information. /// /// Thrown if the stream is not readable nor seekable. /// /// The image - public static Image Load(Stream stream) - where TColor : struct, IPixel + public static Image Load(Stream stream) + where TPixel : struct, IPixel { - return Load(null, stream, null); + return Load(null, stream, null); } /// /// Loads the image from the given stream. /// - /// The pixel format. + /// The pixel format. /// The stream containing image information. /// The options for the decoder. /// /// Thrown if the stream is not readable nor seekable. /// /// The image - public static Image Load(Stream stream, IDecoderOptions options) - where TColor : struct, IPixel + public static Image Load(Stream stream, IDecoderOptions options) + where TPixel : struct, IPixel { - return Load(null, stream, options); + return Load(null, stream, options); } /// /// Loads the image from the given stream. /// - /// The pixel format. + /// The pixel format. /// The config for the decoder. /// The stream containing image information. /// /// Thrown if the stream is not readable nor seekable. /// /// The image - public static Image Load(Configuration config, Stream stream) - where TColor : struct, IPixel + public static Image Load(Configuration config, Stream stream) + where TPixel : struct, IPixel { - return Load(config, stream, null); + return Load(config, stream, null); } /// /// Loads the image from the given stream. /// - /// The pixel format. + /// The pixel format. /// The stream containing image information. /// The decoder. /// /// Thrown if the stream is not readable nor seekable. /// /// The image - public static Image Load(Stream stream, IImageDecoder decoder) - where TColor : struct, IPixel + public static Image Load(Stream stream, IImageDecoder decoder) + where TPixel : struct, IPixel { - return Load(stream, decoder, null); + return Load(stream, decoder, null); } /// /// Loads the image from the given stream. /// - /// The pixel format. + /// The pixel format. /// The stream containing image information. /// The decoder. /// The options for the decoder. @@ -179,16 +179,16 @@ namespace ImageSharp /// Thrown if the stream is not readable nor seekable. /// /// The image - public static Image Load(Stream stream, IImageDecoder decoder, IDecoderOptions options) - where TColor : struct, IPixel + public static Image Load(Stream stream, IImageDecoder decoder, IDecoderOptions options) + where TPixel : struct, IPixel { - return WithSeekableStream(stream, s => decoder.Decode(Configuration.Default, s, options)); + return WithSeekableStream(stream, s => decoder.Decode(Configuration.Default, s, options)); } /// /// Loads the image from the given stream. /// - /// The pixel format. + /// The pixel format. /// The configuration options. /// The stream containing image information. /// The options for the decoder. @@ -196,12 +196,12 @@ namespace ImageSharp /// Thrown if the stream is not readable nor seekable. /// /// The image - public static Image Load(Configuration config, Stream stream, IDecoderOptions options) - where TColor : struct, IPixel + public static Image Load(Configuration config, Stream stream, IDecoderOptions options) + where TPixel : struct, IPixel { config = config ?? Configuration.Default; - Image img = WithSeekableStream(stream, s => Decode(s, options, config)); + Image img = WithSeekableStream(stream, s => Decode(s, options, config)); if (img != null) { diff --git a/src/ImageSharp/Image/IImageBase{TColor}.cs b/src/ImageSharp/Image/IImageBase{TPixel}.cs similarity index 69% rename from src/ImageSharp/Image/IImageBase{TColor}.cs rename to src/ImageSharp/Image/IImageBase{TPixel}.cs index 14bdffc67..d95e52337 100644 --- a/src/ImageSharp/Image/IImageBase{TColor}.cs +++ b/src/ImageSharp/Image/IImageBase{TPixel}.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // @@ -10,16 +10,16 @@ namespace ImageSharp /// /// Encapsulates the basic properties and methods required to manipulate images in varying formats. /// - /// The pixel format. - public interface IImageBase : IImageBase, IDisposable - where TColor : struct, IPixel + /// The pixel format. + public interface IImageBase : IImageBase, IDisposable + where TPixel : struct, IPixel { /// /// Gets the pixels as an array of the given packed pixel format. /// Important. Due to the nature in the way this is constructed do not rely on the length /// of the array for calculations. Use Width * Height. /// - TColor[] Pixels { get; } + TPixel[] Pixels { get; } /// /// Locks the image providing access to the pixels. @@ -27,7 +27,7 @@ namespace ImageSharp /// It is imperative that the accessor is correctly disposed off after use. /// /// - /// The - PixelAccessor Lock(); + /// The + PixelAccessor Lock(); } } \ No newline at end of file diff --git a/src/ImageSharp/Image/IImageProcessor.cs b/src/ImageSharp/Image/IImageProcessor.cs index 0440cdd76..cf442cd6c 100644 --- a/src/ImageSharp/Image/IImageProcessor.cs +++ b/src/ImageSharp/Image/IImageProcessor.cs @@ -11,9 +11,9 @@ namespace ImageSharp.Processing /// /// Encapsulates methods to alter the pixels of an image. /// - /// The pixel format. - public interface IImageProcessor - where TColor : struct, IPixel + /// The pixel format. + public interface IImageProcessor + where TPixel : struct, IPixel { /// /// Gets or sets the parallel options for processing tasks in parallel. @@ -27,7 +27,7 @@ namespace ImageSharp.Processing bool Compand { get; set; } /// - /// Applies the process to the specified portion of the specified . + /// Applies the process to the specified portion of the specified . /// /// The source image. Cannot be null. /// @@ -39,6 +39,6 @@ namespace ImageSharp.Processing /// /// doesnt fit the dimension of the image. /// - void Apply(ImageBase source, Rectangle sourceRectangle); + void Apply(ImageBase source, Rectangle sourceRectangle); } } diff --git a/src/ImageSharp/Image/ImageBase{TColor}.cs b/src/ImageSharp/Image/ImageBase{TPixel}.cs similarity index 86% rename from src/ImageSharp/Image/ImageBase{TColor}.cs rename to src/ImageSharp/Image/ImageBase{TPixel}.cs index cfce7184b..ec458e676 100644 --- a/src/ImageSharp/Image/ImageBase{TColor}.cs +++ b/src/ImageSharp/Image/ImageBase{TPixel}.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // @@ -13,10 +13,10 @@ namespace ImageSharp /// The base class of all images. Encapsulates the basic properties and methods required to manipulate /// images in different pixel formats. /// - /// The pixel format. + /// The pixel format. [DebuggerDisplay("Image: {Width}x{Height}")] - public abstract class ImageBase : IImageBase - where TColor : struct, IPixel + public abstract class ImageBase : IImageBase + where TPixel : struct, IPixel { /// /// Gets or sets the maximum allowable width in pixels. @@ -31,7 +31,7 @@ namespace ImageSharp /// /// The image pixels /// - private TColor[] pixelBuffer; + private TPixel[] pixelBuffer; /// /// A value indicating whether this instance of the given entity has been disposed. @@ -45,7 +45,7 @@ namespace ImageSharp private bool isDisposed; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// /// The configuration providing initialization code which allows extending the library. @@ -56,7 +56,7 @@ namespace ImageSharp } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The width of the image in pixels. /// The height of the image in pixels. @@ -79,15 +79,15 @@ namespace ImageSharp } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// - /// The other to create this instance from. + /// The other to create this instance from. /// /// - /// Thrown if the given is null. + /// Thrown if the given is null. /// - protected ImageBase(ImageBase other) + protected ImageBase(ImageBase other) : this(other.Configuration) { Guard.NotNull(other, nameof(other), "Other image cannot be null."); @@ -98,8 +98,8 @@ namespace ImageSharp // Rent then copy the pixels. Unsafe.CopyBlock gives us a nice speed boost here. this.RentPixels(); - using (PixelAccessor sourcePixels = other.Lock()) - using (PixelAccessor target = this.Lock()) + using (PixelAccessor sourcePixels = other.Lock()) + using (PixelAccessor target = this.Lock()) { // Check we can do this without crashing sourcePixels.CopyTo(target); @@ -107,7 +107,7 @@ namespace ImageSharp } /// - public TColor[] Pixels => this.pixelBuffer; + public TPixel[] Pixels => this.pixelBuffer; /// public int Width { get; private set; } @@ -131,7 +131,7 @@ namespace ImageSharp /// /// The processor. /// The rectangle. - public virtual void ApplyProcessor(IImageProcessor processor, Rectangle rectangle) + public virtual void ApplyProcessor(IImageProcessor processor, Rectangle rectangle) { processor.Apply(this, rectangle); } @@ -150,16 +150,16 @@ namespace ImageSharp } /// - public PixelAccessor Lock() + public PixelAccessor Lock() { - return new PixelAccessor(this); + return new PixelAccessor(this); } /// /// Switches the buffers used by the image and the PixelAccessor meaning that the Image will "own" the buffer from the PixelAccessor and the PixelAccessor will now own the Images buffer. /// /// The pixel source. - internal void SwapPixelsBuffers(PixelAccessor pixelSource) + internal void SwapPixelsBuffers(PixelAccessor pixelSource) { Guard.NotNull(pixelSource, nameof(pixelSource)); @@ -167,7 +167,6 @@ namespace ImageSharp int newHeight = pixelSource.Height; // Push my memory into the accessor (which in turn unpins the old puffer ready for the images use) - TColor[] newPixels = pixelSource.ReturnCurrentPixelsAndReplaceThemInternally(this.Width, this.Height, this.pixelBuffer); this.Width = newWidth; this.Height = newHeight; this.pixelBuffer = newPixels; @@ -221,7 +220,7 @@ namespace ImageSharp /// private void RentPixels() { - this.pixelBuffer = PixelDataPool.Rent(this.Width * this.Height); + this.pixelBuffer = PixelDataPool.Rent(this.Width * this.Height); } /// @@ -229,7 +228,7 @@ namespace ImageSharp /// private void ReturnPixels() { - PixelDataPool.Return(this.pixelBuffer); + PixelDataPool.Return(this.pixelBuffer); this.pixelBuffer = null; } @@ -241,4 +240,4 @@ namespace ImageSharp Array.Clear(this.pixelBuffer, 0, this.Width * this.Height); } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/Image/ImageFrame{TColor}.cs b/src/ImageSharp/Image/ImageFrame{TPixel}.cs similarity index 74% rename from src/ImageSharp/Image/ImageFrame{TColor}.cs rename to src/ImageSharp/Image/ImageFrame{TPixel}.cs index 2712dc687..e85177f59 100644 --- a/src/ImageSharp/Image/ImageFrame{TColor}.cs +++ b/src/ImageSharp/Image/ImageFrame{TPixel}.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // @@ -12,12 +12,12 @@ namespace ImageSharp /// /// Represents a single frame in a animation. /// - /// The pixel format. - public class ImageFrame : ImageBase, IImageFrame - where TColor : struct, IPixel + /// The pixel format. + public class ImageFrame : ImageBase, IImageFrame + where TPixel : struct, IPixel { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The width of the image in pixels. /// The height of the image in pixels. @@ -30,10 +30,10 @@ namespace ImageSharp } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The image to create the frame from. - public ImageFrame(ImageBase image) + public ImageFrame(ImageBase image) : base(image) { } @@ -53,18 +53,18 @@ namespace ImageSharp /// Returns a copy of the image frame in the given pixel format. /// /// A function that allows for the correction of vector scaling between unknown color formats. - /// The pixel format. - /// The - public ImageFrame To(Func scaleFunc = null) - where TColor2 : struct, IPixel + /// The pixel format. + /// The + public ImageFrame To(Func scaleFunc = null) + where TPixel2 : struct, IPixel { - scaleFunc = PackedPixelConverterHelper.ComputeScaleFunction(scaleFunc); + scaleFunc = PackedPixelConverterHelper.ComputeScaleFunction(scaleFunc); - ImageFrame target = new ImageFrame(this.Width, this.Height, this.Configuration); + ImageFrame target = new ImageFrame(this.Width, this.Height, this.Configuration); target.CopyProperties(this); - using (PixelAccessor pixels = this.Lock()) - using (PixelAccessor targetPixels = target.Lock()) + using (PixelAccessor pixels = this.Lock()) + using (PixelAccessor targetPixels = target.Lock()) { Parallel.For( 0, @@ -74,7 +74,7 @@ namespace ImageSharp { for (int x = 0; x < target.Width; x++) { - TColor2 color = default(TColor2); + TPixel2 color = default(TPixel2); color.PackFromVector4(scaleFunc(pixels[x, y].ToVector4())); targetPixels[x, y] = color; } @@ -87,10 +87,10 @@ namespace ImageSharp /// /// Clones the current instance. /// - /// The - internal virtual ImageFrame Clone() + /// The + internal virtual ImageFrame Clone() { - return new ImageFrame(this); + return new ImageFrame(this); } /// diff --git a/src/ImageSharp/Image/ImageProcessingExtensions.cs b/src/ImageSharp/Image/ImageProcessingExtensions.cs index ff3ecd5ee..405cb48b4 100644 --- a/src/ImageSharp/Image/ImageProcessingExtensions.cs +++ b/src/ImageSharp/Image/ImageProcessingExtensions.cs @@ -5,11 +5,10 @@ namespace ImageSharp { - using System; using Processing; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { @@ -17,12 +16,12 @@ namespace ImageSharp /// Applies the processor to the image. /// This method does not resize the target image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The processor to apply to the image. - /// The . - public static Image Apply(this Image source, IImageProcessor processor) - where TColor : struct, IPixel + /// The . + public static Image Apply(this Image source, IImageProcessor processor) + where TPixel : struct, IPixel { source.ApplyProcessor(processor, source.Bounds); return source; diff --git a/src/ImageSharp/Image/Image{TColor}.cs b/src/ImageSharp/Image/Image{TPixel}.cs similarity index 82% rename from src/ImageSharp/Image/Image{TColor}.cs rename to src/ImageSharp/Image/Image{TPixel}.cs index d063c3ff1..88fb04226 100644 --- a/src/ImageSharp/Image/Image{TColor}.cs +++ b/src/ImageSharp/Image/Image{TPixel}.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // @@ -6,13 +6,11 @@ namespace ImageSharp { using System; - using System.Buffers; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Numerics; - using System.Text; using System.Threading.Tasks; using Formats; @@ -21,13 +19,13 @@ namespace ImageSharp /// /// Encapsulates an image, which consists of the pixel data for a graphics image and its attributes. /// - /// The pixel format. + /// The pixel format. [DebuggerDisplay("Image: {Width}x{Height}")] - public class Image : ImageBase, IImage - where TColor : struct, IPixel + public class Image : ImageBase, IImage + where TPixel : struct, IPixel { /// - /// Initializes a new instance of the class + /// Initializes a new instance of the class /// with the height and the width of the image. /// /// The width of the image in pixels. @@ -41,7 +39,7 @@ namespace ImageSharp } /// - /// Initializes a new instance of the class + /// Initializes a new instance of the class /// with the height and the width of the image. /// /// The width of the image in pixels. @@ -52,19 +50,19 @@ namespace ImageSharp } /// - /// Initializes a new instance of the class + /// Initializes a new instance of the class /// by making a copy from another image. /// /// The other image, where the clone should be made from. /// is null. - public Image(Image other) + public Image(Image other) : base(other) { - foreach (ImageFrame frame in other.Frames) + foreach (ImageFrame frame in other.Frames) { if (frame != null) { - this.Frames.Add(new ImageFrame(frame)); + this.Frames.Add(new ImageFrame(frame)); } } @@ -72,19 +70,19 @@ namespace ImageSharp } /// - /// Initializes a new instance of the class + /// Initializes a new instance of the class /// by making a copy from another image. /// /// The other image, where the clone should be made from. /// is null. - public Image(ImageBase other) + public Image(ImageBase other) : base(other) { this.MetaData = new ImageMetaData(); } /// - /// Initializes a new instance of the class + /// Initializes a new instance of the class /// with the height and the width of the image. /// /// The width of the image in pixels. @@ -138,7 +136,7 @@ namespace ImageSharp /// Gets the other frames for the animation. /// /// The list of frame images. - public IList> Frames { get; } = new List>(); + public IList> Frames { get; } = new List>(); /// /// Gets the currently loaded image format. @@ -150,11 +148,11 @@ namespace ImageSharp /// /// The processor to apply to the image. /// The structure that specifies the portion of the image object to draw. - public override void ApplyProcessor(IImageProcessor processor, Rectangle rectangle) + public override void ApplyProcessor(IImageProcessor processor, Rectangle rectangle) { // we want to put this on on here as it gives us a really go place to test/verify processor settings base.ApplyProcessor(processor, rectangle); - foreach (ImageFrame sourceFrame in this.Frames) + foreach (ImageFrame sourceFrame in this.Frames) { sourceFrame.ApplyProcessor(processor, rectangle); } @@ -165,8 +163,8 @@ namespace ImageSharp /// /// The stream to save the image to. /// Thrown if the stream is null. - /// The - public Image Save(Stream stream) + /// The + public Image Save(Stream stream) { return this.Save(stream, (IEncoderOptions)null); } @@ -177,8 +175,8 @@ namespace ImageSharp /// The stream to save the image to. /// The options for the encoder. /// Thrown if the stream is null. - /// The - public Image Save(Stream stream, IEncoderOptions options) + /// The + public Image Save(Stream stream, IEncoderOptions options) { return this.Save(stream, this.CurrentImageFormat?.Encoder, options); } @@ -188,8 +186,8 @@ namespace ImageSharp /// /// The stream to save the image to. /// The format to save the image as. - /// The - public Image Save(Stream stream, IImageFormat format) + /// The + public Image Save(Stream stream, IImageFormat format) { return this.Save(stream, format, null); } @@ -200,8 +198,8 @@ namespace ImageSharp /// The stream to save the image to. /// The format to save the image as. /// The options for the encoder. - /// The - public Image Save(Stream stream, IImageFormat format, IEncoderOptions options) + /// The + public Image Save(Stream stream, IImageFormat format, IEncoderOptions options) { Guard.NotNull(format, nameof(format)); @@ -215,9 +213,9 @@ namespace ImageSharp /// The encoder to save the image with. /// Thrown if the stream or encoder is null. /// - /// The . + /// The . /// - public Image Save(Stream stream, IImageEncoder encoder) + public Image Save(Stream stream, IImageEncoder encoder) { return this.Save(stream, encoder, null); } @@ -230,9 +228,9 @@ namespace ImageSharp /// The options for the encoder. /// Thrown if the stream or encoder is null. /// - /// The . + /// The . /// - public Image Save(Stream stream, IImageEncoder encoder, IEncoderOptions options) + public Image Save(Stream stream, IImageEncoder encoder, IEncoderOptions options) { Guard.NotNull(stream, nameof(stream)); Guard.NotNull(encoder, nameof(encoder)); @@ -248,8 +246,8 @@ namespace ImageSharp /// /// The file path to save the image to. /// Thrown if the stream is null. - /// The - public Image Save(string filePath) + /// The + public Image Save(string filePath) { return this.Save(filePath, (IEncoderOptions)null); } @@ -260,8 +258,8 @@ namespace ImageSharp /// The file path to save the image to. /// The options for the encoder. /// Thrown if the stream is null. - /// The - public Image Save(string filePath, IEncoderOptions options) + /// The + public Image Save(string filePath, IEncoderOptions options) { string ext = Path.GetExtension(filePath).Trim('.'); IImageFormat format = this.Configuration.ImageFormats.SingleOrDefault(f => f.SupportedExtensions.Contains(ext, StringComparer.OrdinalIgnoreCase)); @@ -279,8 +277,8 @@ namespace ImageSharp /// The file path to save the image to. /// The format to save the image as. /// Thrown if the format is null. - /// The - public Image Save(string filePath, IImageFormat format) + /// The + public Image Save(string filePath, IImageFormat format) { return this.Save(filePath, format, null); } @@ -292,8 +290,8 @@ namespace ImageSharp /// The format to save the image as. /// The options for the encoder. /// Thrown if the format is null. - /// The - public Image Save(string filePath, IImageFormat format, IEncoderOptions options) + /// The + public Image Save(string filePath, IImageFormat format, IEncoderOptions options) { Guard.NotNull(format, nameof(format)); return this.Save(filePath, format.Encoder, options); @@ -305,8 +303,8 @@ namespace ImageSharp /// The file path to save the image to. /// The encoder to save the image with. /// Thrown if the encoder is null. - /// The - public Image Save(string filePath, IImageEncoder encoder) + /// The + public Image Save(string filePath, IImageEncoder encoder) { return this.Save(filePath, encoder, null); } @@ -318,8 +316,8 @@ namespace ImageSharp /// The encoder to save the image with. /// The options for the encoder. /// Thrown if the encoder is null. - /// The - public Image Save(string filePath, IImageEncoder encoder, IEncoderOptions options) + /// The + public Image Save(string filePath, IImageEncoder encoder, IEncoderOptions options) { Guard.NotNull(encoder, nameof(encoder)); using (Stream fs = this.Configuration.FileSystem.Create(filePath)) @@ -354,18 +352,18 @@ namespace ImageSharp /// Returns a copy of the image in the given pixel format. /// /// A function that allows for the correction of vector scaling between unknown color formats. - /// The pixel format. - /// The - public Image To(Func scaleFunc = null) - where TColor2 : struct, IPixel + /// The pixel format. + /// The + public Image To(Func scaleFunc = null) + where TPixel2 : struct, IPixel { - scaleFunc = PackedPixelConverterHelper.ComputeScaleFunction(scaleFunc); + scaleFunc = PackedPixelConverterHelper.ComputeScaleFunction(scaleFunc); - Image target = new Image(this.Width, this.Height, this.Configuration); + Image target = new Image(this.Width, this.Height, this.Configuration); target.CopyProperties(this); - using (PixelAccessor pixels = this.Lock()) - using (PixelAccessor targetPixels = target.Lock()) + using (PixelAccessor pixels = this.Lock()) + using (PixelAccessor targetPixels = target.Lock()) { Parallel.For( 0, @@ -375,7 +373,7 @@ namespace ImageSharp { for (int x = 0; x < target.Width; x++) { - TColor2 color = default(TColor2); + TPixel2 color = default(TPixel2); color.PackFromVector4(scaleFunc(pixels[x, y].ToVector4())); targetPixels[x, y] = color; } @@ -384,19 +382,19 @@ namespace ImageSharp for (int i = 0; i < this.Frames.Count; i++) { - target.Frames.Add(this.Frames[i].To()); + target.Frames.Add(this.Frames[i].To()); } return target; } /// - /// Creates a new from this instance + /// Creates a new from this instance /// - /// The - internal virtual ImageFrame ToFrame() + /// The + internal virtual ImageFrame ToFrame() { - return new ImageFrame(this); + return new ImageFrame(this); } /// diff --git a/src/ImageSharp/Image/PixelAccessor{TColor}.cs b/src/ImageSharp/Image/PixelAccessor{TPixel}.cs similarity index 87% rename from src/ImageSharp/Image/PixelAccessor{TColor}.cs rename to src/ImageSharp/Image/PixelAccessor{TPixel}.cs index fb3613adf..5cb19c2e8 100644 --- a/src/ImageSharp/Image/PixelAccessor{TColor}.cs +++ b/src/ImageSharp/Image/PixelAccessor{TPixel}.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // @@ -8,15 +8,14 @@ namespace ImageSharp using System; using System.Diagnostics; using System.Runtime.CompilerServices; - using System.Runtime.InteropServices; using System.Threading.Tasks; /// - /// Provides per-pixel access to generic pixels. + /// Provides per-pixel access to generic pixels. /// - /// The pixel format. - public sealed class PixelAccessor : IDisposable, IBuffer2D - where TColor : struct, IPixel + /// The pixel format. + public sealed class PixelAccessor : IDisposable, IBuffer2D + where TPixel : struct, IPixel { /// /// A value indicating whether this instance of the given entity has been disposed. @@ -32,13 +31,13 @@ namespace ImageSharp /// /// The containing the pixel data. /// - private Buffer2D pixelBuffer; + private Buffer2D pixelBuffer; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The image to provide pixel access for. - public PixelAccessor(ImageBase image) + public PixelAccessor(ImageBase image) { Guard.NotNull(image, nameof(image)); Guard.MustBeGreaterThan(image.Width, 0, "image width"); @@ -49,22 +48,22 @@ namespace ImageSharp } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The width of the image represented by the pixel buffer. /// The height of the image represented by the pixel buffer. public PixelAccessor(int width, int height) - : this(width, height, Buffer2D.CreateClean(width, height)) + : this(width, height, Buffer2D.CreateClean(width, height)) { } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The width of the image represented by the pixel buffer. /// The height of the image represented by the pixel buffer. /// The pixel buffer. - private PixelAccessor(int width, int height, Buffer2D pixels) + private PixelAccessor(int width, int height, Buffer2D pixels) { Guard.NotNull(pixels, nameof(pixels)); Guard.MustBeGreaterThan(width, 0, nameof(width)); @@ -76,7 +75,7 @@ namespace ImageSharp } /// - /// Finalizes an instance of the class. + /// Finalizes an instance of the class. /// ~PixelAccessor() { @@ -86,7 +85,7 @@ namespace ImageSharp /// /// Gets the pixel buffer array. /// - public TColor[] PixelArray => this.pixelBuffer.Array; + public TPixel[] PixelArray => this.pixelBuffer.Array; /// /// Gets the size of a single pixel in the number of bytes. @@ -114,17 +113,17 @@ namespace ImageSharp public ParallelOptions ParallelOptions { get; } /// - BufferSpan IBuffer2D.Span => this.pixelBuffer; + BufferSpan IBuffer2D.Span => this.pixelBuffer; - private static BulkPixelOperations Operations => BulkPixelOperations.Instance; + private static BulkPixelOperations Operations => BulkPixelOperations.Instance; /// /// Gets or sets the pixel at the specified position. /// /// The x-coordinate of the pixel. Must be greater than or equal to zero and less than the width of the image. /// The y-coordinate of the pixel. Must be greater than or equal to zero and less than the height of the image. - /// The at the specified position. - public TColor this[int x, int y] + /// The at the specified position. + public TPixel this[int x, int y] { get { @@ -179,7 +178,7 @@ namespace ImageSharp /// /// Thrown when an unsupported component order value is passed. /// - internal void CopyFrom(PixelArea area, int targetY, int targetX = 0) + internal void CopyFrom(PixelArea area, int targetY, int targetX = 0) { this.CheckCoordinates(area, targetX, targetY); @@ -195,7 +194,7 @@ namespace ImageSharp /// /// Thrown when an unsupported component order value is passed. /// - internal void CopyTo(PixelArea area, int sourceY, int sourceX = 0) + internal void CopyTo(PixelArea area, int sourceY, int sourceX = 0) { this.CheckCoordinates(area, sourceX, sourceY); @@ -212,7 +211,7 @@ namespace ImageSharp /// /// Thrown when an unsupported component order value is passed. /// - internal void SafeCopyTo(PixelArea area, int sourceY, int sourceX = 0) + internal void SafeCopyTo(PixelArea area, int sourceY, int sourceX = 0) { int width = Math.Min(area.Width, this.Width - sourceX); if (width < 1) @@ -237,18 +236,17 @@ namespace ImageSharp /// The pixels. /// Returns the old pixel data thats has gust been replaced. /// If is true then caller is responsible for ensuring is called. - internal TColor[] ReturnCurrentPixelsAndReplaceThemInternally(int width, int height, TColor[] pixels) { - TColor[] oldPixels = this.pixelBuffer.TakeArrayOwnership(); + TPixel[] oldPixels = this.pixelBuffer.TakeArrayOwnership(); this.SetPixelBufferUnsafe(width, height, pixels); return oldPixels; } /// - /// Copies the pixels to another of the same size. + /// Copies the pixels to another of the same size. /// /// The target pixel buffer accessor. - internal void CopyTo(PixelAccessor target) + internal void CopyTo(PixelAccessor target) { BufferSpan.Copy(this.pixelBuffer.Span, target.pixelBuffer.Span); } @@ -262,12 +260,12 @@ namespace ImageSharp /// The width. /// The height. [MethodImpl(MethodImplOptions.AggressiveInlining)] - private void CopyFromZyx(PixelArea area, int targetX, int targetY, int width, int height) + private void CopyFromZyx(PixelArea area, int targetX, int targetY, int width, int height) { for (int y = 0; y < height; y++) { BufferSpan source = area.GetRowSpan(y); - BufferSpan destination = this.GetRowSpan(targetX, targetY + y); + BufferSpan destination = this.GetRowSpan(targetX, targetY + y); Operations.PackFromZyxBytes(source, destination, width); } @@ -282,12 +280,12 @@ namespace ImageSharp /// The width. /// The height. [MethodImpl(MethodImplOptions.AggressiveInlining)] - private void CopyFromZyxw(PixelArea area, int targetX, int targetY, int width, int height) + private void CopyFromZyxw(PixelArea area, int targetX, int targetY, int width, int height) { for (int y = 0; y < height; y++) { BufferSpan source = area.GetRowSpan(y); - BufferSpan destination = this.GetRowSpan(targetX, targetY + y); + BufferSpan destination = this.GetRowSpan(targetX, targetY + y); Operations.PackFromZyxwBytes(source, destination, width); } @@ -302,12 +300,12 @@ namespace ImageSharp /// The width. /// The height. [MethodImpl(MethodImplOptions.AggressiveInlining)] - private void CopyFromXyz(PixelArea area, int targetX, int targetY, int width, int height) + private void CopyFromXyz(PixelArea area, int targetX, int targetY, int width, int height) { for (int y = 0; y < height; y++) { BufferSpan source = area.GetRowSpan(y); - BufferSpan destination = this.GetRowSpan(targetX, targetY + y); + BufferSpan destination = this.GetRowSpan(targetX, targetY + y); Operations.PackFromXyzBytes(source, destination, width); } @@ -322,12 +320,12 @@ namespace ImageSharp /// The width. /// The height. [MethodImpl(MethodImplOptions.AggressiveInlining)] - private void CopyFromXyzw(PixelArea area, int targetX, int targetY, int width, int height) + private void CopyFromXyzw(PixelArea area, int targetX, int targetY, int width, int height) { for (int y = 0; y < height; y++) { BufferSpan source = area.GetRowSpan(y); - BufferSpan destination = this.GetRowSpan(targetX, targetY + y); + BufferSpan destination = this.GetRowSpan(targetX, targetY + y); Operations.PackFromXyzwBytes(source, destination, width); } } @@ -341,11 +339,11 @@ namespace ImageSharp /// The width. /// The height. [MethodImpl(MethodImplOptions.AggressiveInlining)] - private void CopyToZyx(PixelArea area, int sourceX, int sourceY, int width, int height) + private void CopyToZyx(PixelArea area, int sourceX, int sourceY, int width, int height) { for (int y = 0; y < height; y++) { - BufferSpan source = this.GetRowSpan(sourceX, sourceY + y); + BufferSpan source = this.GetRowSpan(sourceX, sourceY + y); BufferSpan destination = area.GetRowSpan(y); Operations.ToZyxBytes(source, destination, width); } @@ -360,11 +358,11 @@ namespace ImageSharp /// The width. /// The height. [MethodImpl(MethodImplOptions.AggressiveInlining)] - private void CopyToZyxw(PixelArea area, int sourceX, int sourceY, int width, int height) + private void CopyToZyxw(PixelArea area, int sourceX, int sourceY, int width, int height) { for (int y = 0; y < height; y++) { - BufferSpan source = this.GetRowSpan(sourceX, sourceY + y); + BufferSpan source = this.GetRowSpan(sourceX, sourceY + y); BufferSpan destination = area.GetRowSpan(y); Operations.ToZyxwBytes(source, destination, width); } @@ -379,11 +377,11 @@ namespace ImageSharp /// The width. /// The height. [MethodImpl(MethodImplOptions.AggressiveInlining)] - private void CopyToXyz(PixelArea area, int sourceX, int sourceY, int width, int height) + private void CopyToXyz(PixelArea area, int sourceX, int sourceY, int width, int height) { for (int y = 0; y < height; y++) { - BufferSpan source = this.GetRowSpan(sourceX, sourceY + y); + BufferSpan source = this.GetRowSpan(sourceX, sourceY + y); BufferSpan destination = area.GetRowSpan(y); Operations.ToXyzBytes(source, destination, width); } @@ -398,19 +396,19 @@ namespace ImageSharp /// The width. /// The height. [MethodImpl(MethodImplOptions.AggressiveInlining)] - private void CopyToXyzw(PixelArea area, int sourceX, int sourceY, int width, int height) + private void CopyToXyzw(PixelArea area, int sourceX, int sourceY, int width, int height) { for (int y = 0; y < height; y++) { - BufferSpan source = this.GetRowSpan(sourceX, sourceY + y); + BufferSpan source = this.GetRowSpan(sourceX, sourceY + y); BufferSpan destination = area.GetRowSpan(y); Operations.ToXyzwBytes(source, destination, width); } } - private void SetPixelBufferUnsafe(int width, int height, TColor[] pixels) + private void SetPixelBufferUnsafe(int width, int height, TPixel[] pixels) { - this.SetPixelBufferUnsafe(width, height, new Buffer2D(pixels, width, height)); + this.SetPixelBufferUnsafe(width, height, new Buffer2D(pixels, width, height)); } /// @@ -419,13 +417,13 @@ namespace ImageSharp /// The width. /// The height. /// The pixel buffer - private void SetPixelBufferUnsafe(int width, int height, Buffer2D pixels) + private void SetPixelBufferUnsafe(int width, int height, Buffer2D pixels) { this.pixelBuffer = pixels; this.Width = width; this.Height = height; - this.PixelSize = Unsafe.SizeOf(); + this.PixelSize = Unsafe.SizeOf(); this.RowStride = this.Width * this.PixelSize; } @@ -440,7 +438,7 @@ namespace ImageSharp /// /// Thrown when an unsupported component order value is passed. /// - private void CopyFrom(PixelArea area, int targetX, int targetY, int width, int height) + private void CopyFrom(PixelArea area, int targetX, int targetY, int width, int height) { switch (area.ComponentOrder) { @@ -472,7 +470,7 @@ namespace ImageSharp /// /// Thrown when an unsupported component order value is passed. /// - private void CopyTo(PixelArea area, int sourceX, int sourceY, int width, int height) + private void CopyTo(PixelArea area, int sourceX, int sourceY, int width, int height) { switch (area.ComponentOrder) { @@ -503,7 +501,7 @@ namespace ImageSharp /// Thrown if the dimensions are not within the bounds of the image. /// [Conditional("DEBUG")] - private void CheckCoordinates(PixelArea area, int x, int y) + private void CheckCoordinates(PixelArea area, int x, int y) { int width = Math.Min(area.Width, this.Width - x); if (width < 1) @@ -540,4 +538,4 @@ namespace ImageSharp } } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/Image/PixelArea{TColor}.cs b/src/ImageSharp/Image/PixelArea{TPixel}.cs similarity index 95% rename from src/ImageSharp/Image/PixelArea{TColor}.cs rename to src/ImageSharp/Image/PixelArea{TPixel}.cs index 176eb0a16..936fc16b3 100644 --- a/src/ImageSharp/Image/PixelArea{TColor}.cs +++ b/src/ImageSharp/Image/PixelArea{TPixel}.cs @@ -1,7 +1,8 @@ -// +// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // + namespace ImageSharp { using System; @@ -10,11 +11,11 @@ namespace ImageSharp using System.Runtime.CompilerServices; /// - /// Represents an area of generic pixels. + /// Represents an area of generic pixels. /// - /// The pixel format. - internal sealed class PixelArea : IDisposable - where TColor : struct, IPixel + /// The pixel format. + internal sealed class PixelArea : IDisposable + where TPixel : struct, IPixel { /// /// A value indicating whether this instance of the given entity has been disposed. @@ -33,7 +34,7 @@ namespace ImageSharp private Buffer byteBuffer; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The width. /// The bytes. @@ -47,7 +48,7 @@ namespace ImageSharp } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The width. /// The height. @@ -70,7 +71,7 @@ namespace ImageSharp } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The width. /// The component order. @@ -80,7 +81,7 @@ namespace ImageSharp } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The width. /// The component order. @@ -91,7 +92,7 @@ namespace ImageSharp } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The width. /// The height. @@ -102,7 +103,7 @@ namespace ImageSharp } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The width. /// The height. diff --git a/src/ImageSharp/ImageProcessor.cs b/src/ImageSharp/ImageProcessor.cs index 79525a8e8..fd577ed22 100644 --- a/src/ImageSharp/ImageProcessor.cs +++ b/src/ImageSharp/ImageProcessor.cs @@ -11,9 +11,9 @@ namespace ImageSharp.Processing /// /// Allows the application of processors to images. /// - /// The pixel format. - internal abstract class ImageProcessor : IImageProcessor - where TColor : struct, IPixel + /// The pixel format. + internal abstract class ImageProcessor : IImageProcessor + where TPixel : struct, IPixel { /// public virtual ParallelOptions ParallelOptions { get; set; } @@ -22,7 +22,7 @@ namespace ImageSharp.Processing public virtual bool Compand { get; set; } = false; /// - public void Apply(ImageBase source, Rectangle sourceRectangle) + public void Apply(ImageBase source, Rectangle sourceRectangle) { if (this.ParallelOptions == null) { @@ -50,19 +50,19 @@ namespace ImageSharp.Processing /// /// The structure that specifies the portion of the image object to draw. /// - protected virtual void BeforeApply(ImageBase source, Rectangle sourceRectangle) + protected virtual void BeforeApply(ImageBase source, Rectangle sourceRectangle) { } /// - /// Applies the process to the specified portion of the specified at the specified location + /// Applies the process to the specified portion of the specified at the specified location /// and with the specified size. /// /// The source image. Cannot be null. /// /// The structure that specifies the portion of the image object to draw. /// - protected abstract void OnApply(ImageBase source, Rectangle sourceRectangle); + protected abstract void OnApply(ImageBase source, Rectangle sourceRectangle); /// /// This method is called after the process is applied to prepare the processor. @@ -71,7 +71,7 @@ namespace ImageSharp.Processing /// /// The structure that specifies the portion of the image object to draw. /// - protected virtual void AfterApply(ImageBase source, Rectangle sourceRectangle) + protected virtual void AfterApply(ImageBase source, Rectangle sourceRectangle) { } } diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs b/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs index c4a94c5ff..89c0b9c5c 100644 --- a/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs +++ b/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs @@ -116,12 +116,12 @@ namespace ImageSharp /// /// Returns the thumbnail in the EXIF profile when available. /// - /// The pixel format. + /// The pixel format. /// - /// The . + /// The . /// - public Image CreateThumbnail() - where TColor : struct, IPixel + public Image CreateThumbnail() + where TPixel : struct, IPixel { this.InitializeValues(); @@ -137,7 +137,7 @@ namespace ImageSharp using (MemoryStream memStream = new MemoryStream(this.data, this.thumbnailOffset, this.thumbnailLength)) { - return Image.Load(memStream); + return Image.Load(memStream); } } diff --git a/src/ImageSharp/Processing/Binarization/BinaryThreshold.cs b/src/ImageSharp/Processing/Binarization/BinaryThreshold.cs index 672726d92..a704acc30 100644 --- a/src/ImageSharp/Processing/Binarization/BinaryThreshold.cs +++ b/src/ImageSharp/Processing/Binarization/BinaryThreshold.cs @@ -10,19 +10,19 @@ namespace ImageSharp using Processing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Applies binarization to the image splitting the pixels at the given threshold. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The threshold to apply binarization of the image. Must be between 0 and 1. - /// The . - public static Image BinaryThreshold(this Image source, float threshold) - where TColor : struct, IPixel + /// The . + public static Image BinaryThreshold(this Image source, float threshold) + where TPixel : struct, IPixel { return BinaryThreshold(source, threshold, source.Bounds); } @@ -30,17 +30,17 @@ namespace ImageSharp /// /// Applies binarization to the image splitting the pixels at the given threshold. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The threshold to apply binarization of the image. Must be between 0 and 1. /// /// The structure that specifies the portion of the image object to alter. /// - /// The . - public static Image BinaryThreshold(this Image source, float threshold, Rectangle rectangle) - where TColor : struct, IPixel + /// The . + public static Image BinaryThreshold(this Image source, float threshold, Rectangle rectangle) + where TPixel : struct, IPixel { - source.ApplyProcessor(new BinaryThresholdProcessor(threshold), rectangle); + source.ApplyProcessor(new BinaryThresholdProcessor(threshold), rectangle); return source; } } diff --git a/src/ImageSharp/Processing/Binarization/Dither.cs b/src/ImageSharp/Processing/Binarization/Dither.cs index dd6dfe8a1..eb58fe33f 100644 --- a/src/ImageSharp/Processing/Binarization/Dither.cs +++ b/src/ImageSharp/Processing/Binarization/Dither.cs @@ -18,13 +18,13 @@ namespace ImageSharp /// /// Dithers the image reducing it to two colors using ordered dithering. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The ordered ditherer. /// The component index to test the threshold against. Must range from 0 to 3. - /// The . - public static Image Dither(this Image source, IOrderedDither dither, int index = 0) - where TColor : struct, IPixel + /// The . + public static Image Dither(this Image source, IOrderedDither dither, int index = 0) + where TPixel : struct, IPixel { return Dither(source, dither, source.Bounds, index); } @@ -32,7 +32,7 @@ namespace ImageSharp /// /// Dithers the image reducing it to two colors using ordered dithering. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The ordered ditherer. /// @@ -40,23 +40,23 @@ namespace ImageSharp /// /// The component index to test the threshold against. Must range from 0 to 3. /// The . - public static Image Dither(this Image source, IOrderedDither dither, Rectangle rectangle, int index = 0) - where TColor : struct, IPixel + public static Image Dither(this Image source, IOrderedDither dither, Rectangle rectangle, int index = 0) + where TPixel : struct, IPixel { - source.ApplyProcessor(new OrderedDitherProcessor(dither, index), rectangle); + source.ApplyProcessor(new OrderedDitherProcessor(dither, index), rectangle); return source; } /// /// Dithers the image reducing it to two colors using error diffusion. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The diffusion algorithm to apply. /// The threshold to apply binarization of the image. Must be between 0 and 1. - /// The . - public static Image Dither(this Image source, IErrorDiffuser diffuser, float threshold) - where TColor : struct, IPixel + /// The . + public static Image Dither(this Image source, IErrorDiffuser diffuser, float threshold) + where TPixel : struct, IPixel { return Dither(source, diffuser, threshold, source.Bounds); } @@ -64,7 +64,7 @@ namespace ImageSharp /// /// Dithers the image reducing it to two colors using error diffusion. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The diffusion algorithm to apply. /// The threshold to apply binarization of the image. Must be between 0 and 1. @@ -72,10 +72,10 @@ namespace ImageSharp /// The structure that specifies the portion of the image object to alter. /// /// The . - public static Image Dither(this Image source, IErrorDiffuser diffuser, float threshold, Rectangle rectangle) - where TColor : struct, IPixel + public static Image Dither(this Image source, IErrorDiffuser diffuser, float threshold, Rectangle rectangle) + where TPixel : struct, IPixel { - source.ApplyProcessor(new ErrorDiffusionDitherProcessor(diffuser, threshold), rectangle); + source.ApplyProcessor(new ErrorDiffusionDitherProcessor(diffuser, threshold), rectangle); return source; } } diff --git a/src/ImageSharp/Processing/ColorMatrix/BlackWhite.cs b/src/ImageSharp/Processing/ColorMatrix/BlackWhite.cs index 63d6dd33c..767c72eea 100644 --- a/src/ImageSharp/Processing/ColorMatrix/BlackWhite.cs +++ b/src/ImageSharp/Processing/ColorMatrix/BlackWhite.cs @@ -11,18 +11,18 @@ namespace ImageSharp using Processing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Applies black and white toning to the image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. - /// The . - public static Image BlackWhite(this Image source) - where TColor : struct, IPixel + /// The . + public static Image BlackWhite(this Image source) + where TPixel : struct, IPixel { return BlackWhite(source, source.Bounds); } @@ -30,16 +30,16 @@ namespace ImageSharp /// /// Applies black and white toning to the image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// /// The structure that specifies the portion of the image object to alter. /// - /// The . - public static Image BlackWhite(this Image source, Rectangle rectangle) - where TColor : struct, IPixel + /// The . + public static Image BlackWhite(this Image source, Rectangle rectangle) + where TPixel : struct, IPixel { - source.ApplyProcessor(new BlackWhiteProcessor(), rectangle); + source.ApplyProcessor(new BlackWhiteProcessor(), rectangle); return source; } } diff --git a/src/ImageSharp/Processing/ColorMatrix/ColorBlindness.cs b/src/ImageSharp/Processing/ColorMatrix/ColorBlindness.cs index 36a139d0e..784d52cce 100644 --- a/src/ImageSharp/Processing/ColorMatrix/ColorBlindness.cs +++ b/src/ImageSharp/Processing/ColorMatrix/ColorBlindness.cs @@ -11,19 +11,19 @@ namespace ImageSharp using Processing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Applies the given colorblindness simulator to the image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The type of color blindness simulator to apply. - /// The . - public static Image ColorBlindness(this Image source, ColorBlindness colorBlindness) - where TColor : struct, IPixel + /// The . + public static Image ColorBlindness(this Image source, ColorBlindness colorBlindness) + where TPixel : struct, IPixel { return ColorBlindness(source, colorBlindness, source.Bounds); } @@ -31,50 +31,50 @@ namespace ImageSharp /// /// Applies the given colorblindness simulator to the image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The type of color blindness simulator to apply. /// /// The structure that specifies the portion of the image object to alter. /// - /// The . - public static Image ColorBlindness(this Image source, ColorBlindness colorBlindness, Rectangle rectangle) - where TColor : struct, IPixel + /// The . + public static Image ColorBlindness(this Image source, ColorBlindness colorBlindness, Rectangle rectangle) + where TPixel : struct, IPixel { - IImageProcessor processor; + IImageProcessor processor; switch (colorBlindness) { case ImageSharp.Processing.ColorBlindness.Achromatomaly: - processor = new AchromatomalyProcessor(); + processor = new AchromatomalyProcessor(); break; case ImageSharp.Processing.ColorBlindness.Achromatopsia: - processor = new AchromatopsiaProcessor(); + processor = new AchromatopsiaProcessor(); break; case ImageSharp.Processing.ColorBlindness.Deuteranomaly: - processor = new DeuteranomalyProcessor(); + processor = new DeuteranomalyProcessor(); break; case ImageSharp.Processing.ColorBlindness.Deuteranopia: - processor = new DeuteranopiaProcessor(); + processor = new DeuteranopiaProcessor(); break; case ImageSharp.Processing.ColorBlindness.Protanomaly: - processor = new ProtanomalyProcessor(); + processor = new ProtanomalyProcessor(); break; case ImageSharp.Processing.ColorBlindness.Protanopia: - processor = new ProtanopiaProcessor(); + processor = new ProtanopiaProcessor(); break; case ImageSharp.Processing.ColorBlindness.Tritanomaly: - processor = new TritanomalyProcessor(); + processor = new TritanomalyProcessor(); break; default: - processor = new TritanopiaProcessor(); + processor = new TritanopiaProcessor(); break; } diff --git a/src/ImageSharp/Processing/ColorMatrix/Grayscale.cs b/src/ImageSharp/Processing/ColorMatrix/Grayscale.cs index 613b999d4..10888da44 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Grayscale.cs +++ b/src/ImageSharp/Processing/ColorMatrix/Grayscale.cs @@ -11,19 +11,19 @@ namespace ImageSharp using Processing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Applies Grayscale toning to the image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The formula to apply to perform the operation. - /// The . - public static Image Grayscale(this Image source, GrayscaleMode mode = GrayscaleMode.Bt709) - where TColor : struct, IPixel + /// The . + public static Image Grayscale(this Image source, GrayscaleMode mode = GrayscaleMode.Bt709) + where TPixel : struct, IPixel { return Grayscale(source, source.Bounds, mode); } @@ -31,19 +31,19 @@ namespace ImageSharp /// /// Applies Grayscale toning to the image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// /// The structure that specifies the portion of the image object to alter. /// /// The formula to apply to perform the operation. - /// The . - public static Image Grayscale(this Image source, Rectangle rectangle, GrayscaleMode mode = GrayscaleMode.Bt709) - where TColor : struct, IPixel + /// The . + public static Image Grayscale(this Image source, Rectangle rectangle, GrayscaleMode mode = GrayscaleMode.Bt709) + where TPixel : struct, IPixel { - IImageProcessor processor = mode == GrayscaleMode.Bt709 - ? (IImageProcessor)new GrayscaleBt709Processor() - : new GrayscaleBt601Processor(); + IImageProcessor processor = mode == GrayscaleMode.Bt709 + ? (IImageProcessor)new GrayscaleBt709Processor() + : new GrayscaleBt601Processor(); source.ApplyProcessor(processor, rectangle); return source; diff --git a/src/ImageSharp/Processing/ColorMatrix/Hue.cs b/src/ImageSharp/Processing/ColorMatrix/Hue.cs index 8edeb2ff3..5e6a20523 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Hue.cs +++ b/src/ImageSharp/Processing/ColorMatrix/Hue.cs @@ -11,19 +11,19 @@ namespace ImageSharp using Processing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Alters the hue component of the image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The angle in degrees to adjust the image. - /// The . - public static Image Hue(this Image source, float degrees) - where TColor : struct, IPixel + /// The . + public static Image Hue(this Image source, float degrees) + where TPixel : struct, IPixel { return Hue(source, degrees, source.Bounds); } @@ -31,17 +31,17 @@ namespace ImageSharp /// /// Alters the hue component of the image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The angle in degrees to adjust the image. /// /// The structure that specifies the portion of the image object to alter. /// - /// The . - public static Image Hue(this Image source, float degrees, Rectangle rectangle) - where TColor : struct, IPixel + /// The . + public static Image Hue(this Image source, float degrees, Rectangle rectangle) + where TPixel : struct, IPixel { - source.ApplyProcessor(new HueProcessor(degrees), rectangle); + source.ApplyProcessor(new HueProcessor(degrees), rectangle); return source; } } diff --git a/src/ImageSharp/Processing/ColorMatrix/Kodachrome.cs b/src/ImageSharp/Processing/ColorMatrix/Kodachrome.cs index 5084c96b2..2fca3f1c2 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Kodachrome.cs +++ b/src/ImageSharp/Processing/ColorMatrix/Kodachrome.cs @@ -11,18 +11,18 @@ namespace ImageSharp using Processing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Alters the colors of the image recreating an old Kodachrome camera effect. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. - /// The . - public static Image Kodachrome(this Image source) - where TColor : struct, IPixel + /// The . + public static Image Kodachrome(this Image source) + where TPixel : struct, IPixel { return Kodachrome(source, source.Bounds); } @@ -30,16 +30,16 @@ namespace ImageSharp /// /// Alters the colors of the image recreating an old Kodachrome camera effect. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// /// The structure that specifies the portion of the image object to alter. /// - /// The . - public static Image Kodachrome(this Image source, Rectangle rectangle) - where TColor : struct, IPixel + /// The . + public static Image Kodachrome(this Image source, Rectangle rectangle) + where TPixel : struct, IPixel { - source.ApplyProcessor(new KodachromeProcessor(), rectangle); + source.ApplyProcessor(new KodachromeProcessor(), rectangle); return source; } } diff --git a/src/ImageSharp/Processing/ColorMatrix/Lomograph.cs b/src/ImageSharp/Processing/ColorMatrix/Lomograph.cs index ef6b23d5d..1e486ce30 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Lomograph.cs +++ b/src/ImageSharp/Processing/ColorMatrix/Lomograph.cs @@ -11,18 +11,18 @@ namespace ImageSharp using Processing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Alters the colors of the image recreating an old Lomograph camera effect. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. - /// The . - public static Image Lomograph(this Image source) - where TColor : struct, IPixel + /// The . + public static Image Lomograph(this Image source) + where TPixel : struct, IPixel { return Lomograph(source, source.Bounds); } @@ -30,16 +30,16 @@ namespace ImageSharp /// /// Alters the colors of the image recreating an old Lomograph camera effect. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// /// The structure that specifies the portion of the image object to alter. /// - /// The . - public static Image Lomograph(this Image source, Rectangle rectangle) - where TColor : struct, IPixel + /// The . + public static Image Lomograph(this Image source, Rectangle rectangle) + where TPixel : struct, IPixel { - source.ApplyProcessor(new LomographProcessor(), rectangle); + source.ApplyProcessor(new LomographProcessor(), rectangle); return source; } } diff --git a/src/ImageSharp/Processing/ColorMatrix/Polaroid.cs b/src/ImageSharp/Processing/ColorMatrix/Polaroid.cs index 68b10173c..798a2ab3f 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Polaroid.cs +++ b/src/ImageSharp/Processing/ColorMatrix/Polaroid.cs @@ -11,18 +11,18 @@ namespace ImageSharp using Processing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Alters the colors of the image recreating an old Polaroid camera effect. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. - /// The . - public static Image Polaroid(this Image source) - where TColor : struct, IPixel + /// The . + public static Image Polaroid(this Image source) + where TPixel : struct, IPixel { return Polaroid(source, source.Bounds); } @@ -30,16 +30,16 @@ namespace ImageSharp /// /// Alters the colors of the image recreating an old Polaroid camera effect. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// /// The structure that specifies the portion of the image object to alter. /// - /// The . - public static Image Polaroid(this Image source, Rectangle rectangle) - where TColor : struct, IPixel + /// The . + public static Image Polaroid(this Image source, Rectangle rectangle) + where TPixel : struct, IPixel { - source.ApplyProcessor(new PolaroidProcessor(), rectangle); + source.ApplyProcessor(new PolaroidProcessor(), rectangle); return source; } } diff --git a/src/ImageSharp/Processing/ColorMatrix/Saturation.cs b/src/ImageSharp/Processing/ColorMatrix/Saturation.cs index 7a6359744..faca73fc6 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Saturation.cs +++ b/src/ImageSharp/Processing/ColorMatrix/Saturation.cs @@ -11,19 +11,19 @@ namespace ImageSharp using Processing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Alters the saturation component of the image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The new saturation of the image. Must be between -100 and 100. - /// The . - public static Image Saturation(this Image source, int amount) - where TColor : struct, IPixel + /// The . + public static Image Saturation(this Image source, int amount) + where TPixel : struct, IPixel { return Saturation(source, amount, source.Bounds); } @@ -31,17 +31,17 @@ namespace ImageSharp /// /// Alters the saturation component of the image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The new saturation of the image. Must be between -100 and 100. /// /// The structure that specifies the portion of the image object to alter. /// - /// The . - public static Image Saturation(this Image source, int amount, Rectangle rectangle) - where TColor : struct, IPixel + /// The . + public static Image Saturation(this Image source, int amount, Rectangle rectangle) + where TPixel : struct, IPixel { - source.ApplyProcessor(new SaturationProcessor(amount), rectangle); + source.ApplyProcessor(new SaturationProcessor(amount), rectangle); return source; } } diff --git a/src/ImageSharp/Processing/ColorMatrix/Sepia.cs b/src/ImageSharp/Processing/ColorMatrix/Sepia.cs index 4943635e0..96c82c259 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Sepia.cs +++ b/src/ImageSharp/Processing/ColorMatrix/Sepia.cs @@ -11,18 +11,18 @@ namespace ImageSharp using Processing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Applies sepia toning to the image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The . - public static Image Sepia(this Image source) - where TColor : struct, IPixel + public static Image Sepia(this Image source) + where TPixel : struct, IPixel { return Sepia(source, source.Bounds); } @@ -30,16 +30,16 @@ namespace ImageSharp /// /// Applies sepia toning to the image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// /// The structure that specifies the portion of the image object to alter. /// /// The . - public static Image Sepia(this Image source, Rectangle rectangle) - where TColor : struct, IPixel + public static Image Sepia(this Image source, Rectangle rectangle) + where TPixel : struct, IPixel { - source.ApplyProcessor(new SepiaProcessor(), rectangle); + source.ApplyProcessor(new SepiaProcessor(), rectangle); return source; } } diff --git a/src/ImageSharp/Processing/Convolution/BoxBlur.cs b/src/ImageSharp/Processing/Convolution/BoxBlur.cs index 428142ffa..6912d4885 100644 --- a/src/ImageSharp/Processing/Convolution/BoxBlur.cs +++ b/src/ImageSharp/Processing/Convolution/BoxBlur.cs @@ -10,19 +10,19 @@ namespace ImageSharp using Processing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Applies a box blur to the image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The 'radius' value representing the size of the area to sample. - /// The . - public static Image BoxBlur(this Image source, int radius = 7) - where TColor : struct, IPixel + /// The . + public static Image BoxBlur(this Image source, int radius = 7) + where TPixel : struct, IPixel { return BoxBlur(source, radius, source.Bounds); } @@ -30,17 +30,17 @@ namespace ImageSharp /// /// Applies a box blur to the image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The 'radius' value representing the size of the area to sample. /// /// The structure that specifies the portion of the image object to alter. /// - /// The . - public static Image BoxBlur(this Image source, int radius, Rectangle rectangle) - where TColor : struct, IPixel + /// The . + public static Image BoxBlur(this Image source, int radius, Rectangle rectangle) + where TPixel : struct, IPixel { - source.ApplyProcessor(new BoxBlurProcessor(radius), rectangle); + source.ApplyProcessor(new BoxBlurProcessor(radius), rectangle); return source; } } diff --git a/src/ImageSharp/Processing/Convolution/DetectEdges.cs b/src/ImageSharp/Processing/Convolution/DetectEdges.cs index dba062b56..6ffeaa63d 100644 --- a/src/ImageSharp/Processing/Convolution/DetectEdges.cs +++ b/src/ImageSharp/Processing/Convolution/DetectEdges.cs @@ -11,49 +11,49 @@ namespace ImageSharp using Processing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// - /// Detects any edges within the image. Uses the filter + /// Detects any edges within the image. Uses the filter /// operating in Grayscale mode. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. - /// The . - public static Image DetectEdges(this Image source) - where TColor : struct, IPixel + /// The . + public static Image DetectEdges(this Image source) + where TPixel : struct, IPixel { - return DetectEdges(source, source.Bounds, new SobelProcessor { Grayscale = true }); + return DetectEdges(source, source.Bounds, new SobelProcessor { Grayscale = true }); } /// - /// Detects any edges within the image. Uses the filter + /// Detects any edges within the image. Uses the filter /// operating in Grayscale mode. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// /// The structure that specifies the portion of the image object to alter. /// - /// The . - public static Image DetectEdges(this Image source, Rectangle rectangle) - where TColor : struct, IPixel + /// The . + public static Image DetectEdges(this Image source, Rectangle rectangle) + where TPixel : struct, IPixel { - return DetectEdges(source, rectangle, new SobelProcessor { Grayscale = true }); + return DetectEdges(source, rectangle, new SobelProcessor { Grayscale = true }); } /// /// Detects any edges within the image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The filter for detecting edges. /// Whether to convert the image to Grayscale first. Defaults to true. - /// The . - public static Image DetectEdges(this Image source, EdgeDetection filter, bool grayscale = true) - where TColor : struct, IPixel + /// The . + public static Image DetectEdges(this Image source, EdgeDetection filter, bool grayscale = true) + where TPixel : struct, IPixel { return DetectEdges(source, filter, source.Bounds, grayscale); } @@ -61,59 +61,59 @@ namespace ImageSharp /// /// Detects any edges within the image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The filter for detecting edges. /// /// The structure that specifies the portion of the image object to alter. /// /// Whether to convert the image to Grayscale first. Defaults to true. - /// The . - public static Image DetectEdges(this Image source, EdgeDetection filter, Rectangle rectangle, bool grayscale = true) - where TColor : struct, IPixel + /// The . + public static Image DetectEdges(this Image source, EdgeDetection filter, Rectangle rectangle, bool grayscale = true) + where TPixel : struct, IPixel { - IEdgeDetectorProcessor processor; + IEdgeDetectorProcessor processor; switch (filter) { case EdgeDetection.Kayyali: - processor = new KayyaliProcessor { Grayscale = grayscale }; + processor = new KayyaliProcessor { Grayscale = grayscale }; break; case EdgeDetection.Kirsch: - processor = new KirschProcessor { Grayscale = grayscale }; + processor = new KirschProcessor { Grayscale = grayscale }; break; case EdgeDetection.Lapacian3X3: - processor = new Laplacian3X3Processor { Grayscale = grayscale }; + processor = new Laplacian3X3Processor { Grayscale = grayscale }; break; case EdgeDetection.Lapacian5X5: - processor = new Laplacian5X5Processor { Grayscale = grayscale }; + processor = new Laplacian5X5Processor { Grayscale = grayscale }; break; case EdgeDetection.LaplacianOfGaussian: - processor = new LaplacianOfGaussianProcessor { Grayscale = grayscale }; + processor = new LaplacianOfGaussianProcessor { Grayscale = grayscale }; break; case EdgeDetection.Prewitt: - processor = new PrewittProcessor { Grayscale = grayscale }; + processor = new PrewittProcessor { Grayscale = grayscale }; break; case EdgeDetection.RobertsCross: - processor = new RobertsCrossProcessor { Grayscale = grayscale }; + processor = new RobertsCrossProcessor { Grayscale = grayscale }; break; case EdgeDetection.Robinson: - processor = new RobinsonProcessor { Grayscale = grayscale }; + processor = new RobinsonProcessor { Grayscale = grayscale }; break; case EdgeDetection.Scharr: - processor = new ScharrProcessor { Grayscale = grayscale }; + processor = new ScharrProcessor { Grayscale = grayscale }; break; default: - processor = new SobelProcessor { Grayscale = grayscale }; + processor = new SobelProcessor { Grayscale = grayscale }; break; } @@ -123,12 +123,12 @@ namespace ImageSharp /// /// Detects any edges within the image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The filter for detecting edges. - /// The . - public static Image DetectEdges(this Image source, IEdgeDetectorProcessor filter) - where TColor : struct, IPixel + /// The . + public static Image DetectEdges(this Image source, IEdgeDetectorProcessor filter) + where TPixel : struct, IPixel { return DetectEdges(source, source.Bounds, filter); } @@ -136,15 +136,15 @@ namespace ImageSharp /// /// Detects any edges within the image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// /// The structure that specifies the portion of the image object to alter. /// /// The filter for detecting edges. - /// The . - public static Image DetectEdges(this Image source, Rectangle rectangle, IEdgeDetectorProcessor filter) - where TColor : struct, IPixel + /// The . + public static Image DetectEdges(this Image source, Rectangle rectangle, IEdgeDetectorProcessor filter) + where TPixel : struct, IPixel { source.ApplyProcessor(filter, rectangle); return source; diff --git a/src/ImageSharp/Processing/Convolution/GaussianBlur.cs b/src/ImageSharp/Processing/Convolution/GaussianBlur.cs index 81f854638..3472ceadb 100644 --- a/src/ImageSharp/Processing/Convolution/GaussianBlur.cs +++ b/src/ImageSharp/Processing/Convolution/GaussianBlur.cs @@ -11,19 +11,19 @@ namespace ImageSharp using Processing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Applies a Gaussian blur to the image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The 'sigma' value representing the weight of the blur. - /// The . - public static Image GaussianBlur(this Image source, float sigma = 3f) - where TColor : struct, IPixel + /// The . + public static Image GaussianBlur(this Image source, float sigma = 3f) + where TPixel : struct, IPixel { return GaussianBlur(source, sigma, source.Bounds); } @@ -31,17 +31,17 @@ namespace ImageSharp /// /// Applies a Gaussian blur to the image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The 'sigma' value representing the weight of the blur. /// /// The structure that specifies the portion of the image object to alter. /// - /// The . - public static Image GaussianBlur(this Image source, float sigma, Rectangle rectangle) - where TColor : struct, IPixel + /// The . + public static Image GaussianBlur(this Image source, float sigma, Rectangle rectangle) + where TPixel : struct, IPixel { - source.ApplyProcessor(new GaussianBlurProcessor(sigma), rectangle); + source.ApplyProcessor(new GaussianBlurProcessor(sigma), rectangle); return source; } } diff --git a/src/ImageSharp/Processing/Convolution/GaussianSharpen.cs b/src/ImageSharp/Processing/Convolution/GaussianSharpen.cs index 61816198a..196bda837 100644 --- a/src/ImageSharp/Processing/Convolution/GaussianSharpen.cs +++ b/src/ImageSharp/Processing/Convolution/GaussianSharpen.cs @@ -11,19 +11,19 @@ namespace ImageSharp using Processing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Applies a Gaussian sharpening filter to the image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The 'sigma' value representing the weight of the blur. - /// The . - public static Image GaussianSharpen(this Image source, float sigma = 3f) - where TColor : struct, IPixel + /// The . + public static Image GaussianSharpen(this Image source, float sigma = 3f) + where TPixel : struct, IPixel { return GaussianSharpen(source, sigma, source.Bounds); } @@ -31,17 +31,17 @@ namespace ImageSharp /// /// Applies a Gaussian sharpening filter to the image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The 'sigma' value representing the weight of the blur. /// /// The structure that specifies the portion of the image object to alter. /// - /// The . - public static Image GaussianSharpen(this Image source, float sigma, Rectangle rectangle) - where TColor : struct, IPixel + /// The . + public static Image GaussianSharpen(this Image source, float sigma, Rectangle rectangle) + where TPixel : struct, IPixel { - source.ApplyProcessor(new GaussianSharpenProcessor(sigma), rectangle); + source.ApplyProcessor(new GaussianSharpenProcessor(sigma), rectangle); return source; } } diff --git a/src/ImageSharp/Processing/Effects/Alpha.cs b/src/ImageSharp/Processing/Effects/Alpha.cs index 39849d4d4..f38953e38 100644 --- a/src/ImageSharp/Processing/Effects/Alpha.cs +++ b/src/ImageSharp/Processing/Effects/Alpha.cs @@ -17,12 +17,12 @@ namespace ImageSharp /// /// Alters the alpha component of the image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The new opacity of the image. Must be between 0 and 100. - /// The . - public static Image Alpha(this Image source, int percent) - where TColor : struct, IPixel + /// The . + public static Image Alpha(this Image source, int percent) + where TPixel : struct, IPixel { return Alpha(source, percent, source.Bounds); } @@ -30,17 +30,17 @@ namespace ImageSharp /// /// Alters the alpha component of the image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The new opacity of the image. Must be between 0 and 100. /// /// The structure that specifies the portion of the image object to alter. /// /// The . - public static Image Alpha(this Image source, int percent, Rectangle rectangle) - where TColor : struct, IPixel + public static Image Alpha(this Image source, int percent, Rectangle rectangle) + where TPixel : struct, IPixel { - source.ApplyProcessor(new AlphaProcessor(percent), rectangle); + source.ApplyProcessor(new AlphaProcessor(percent), rectangle); return source; } } diff --git a/src/ImageSharp/Processing/Effects/BackgroundColor.cs b/src/ImageSharp/Processing/Effects/BackgroundColor.cs index 2e621172e..e1107258f 100644 --- a/src/ImageSharp/Processing/Effects/BackgroundColor.cs +++ b/src/ImageSharp/Processing/Effects/BackgroundColor.cs @@ -10,21 +10,21 @@ namespace ImageSharp using Processing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Replaces the background color of image with the given one. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The color to set as the background. - /// The . - public static Image BackgroundColor(this Image source, TColor color) - where TColor : struct, IPixel + /// The . + public static Image BackgroundColor(this Image source, TPixel color) + where TPixel : struct, IPixel { - source.ApplyProcessor(new BackgroundColorProcessor(color), source.Bounds); + source.ApplyProcessor(new BackgroundColorProcessor(color), source.Bounds); return source; } } diff --git a/src/ImageSharp/Processing/Effects/Brightness.cs b/src/ImageSharp/Processing/Effects/Brightness.cs index 8ba702c4f..585db7346 100644 --- a/src/ImageSharp/Processing/Effects/Brightness.cs +++ b/src/ImageSharp/Processing/Effects/Brightness.cs @@ -10,19 +10,19 @@ namespace ImageSharp using Processing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Alters the brightness component of the image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The new brightness of the image. Must be between -100 and 100. - /// The . - public static Image Brightness(this Image source, int amount) - where TColor : struct, IPixel + /// The . + public static Image Brightness(this Image source, int amount) + where TPixel : struct, IPixel { return Brightness(source, amount, source.Bounds); } @@ -30,17 +30,17 @@ namespace ImageSharp /// /// Alters the brightness component of the image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The new brightness of the image. Must be between -100 and 100. /// /// The structure that specifies the portion of the image object to alter. /// - /// The . - public static Image Brightness(this Image source, int amount, Rectangle rectangle) - where TColor : struct, IPixel + /// The . + public static Image Brightness(this Image source, int amount, Rectangle rectangle) + where TPixel : struct, IPixel { - source.ApplyProcessor(new BrightnessProcessor(amount), rectangle); + source.ApplyProcessor(new BrightnessProcessor(amount), rectangle); return source; } } diff --git a/src/ImageSharp/Processing/Effects/Contrast.cs b/src/ImageSharp/Processing/Effects/Contrast.cs index 0228f4fe3..99a90455f 100644 --- a/src/ImageSharp/Processing/Effects/Contrast.cs +++ b/src/ImageSharp/Processing/Effects/Contrast.cs @@ -10,19 +10,19 @@ namespace ImageSharp using Processing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Alters the contrast component of the image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The new contrast of the image. Must be between -100 and 100. - /// The . - public static Image Contrast(this Image source, int amount) - where TColor : struct, IPixel + /// The . + public static Image Contrast(this Image source, int amount) + where TPixel : struct, IPixel { return Contrast(source, amount, source.Bounds); } @@ -30,17 +30,17 @@ namespace ImageSharp /// /// Alters the contrast component of the image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The new contrast of the image. Must be between -100 and 100. /// /// The structure that specifies the portion of the image object to alter. /// - /// The . - public static Image Contrast(this Image source, int amount, Rectangle rectangle) - where TColor : struct, IPixel + /// The . + public static Image Contrast(this Image source, int amount, Rectangle rectangle) + where TPixel : struct, IPixel { - source.ApplyProcessor(new ContrastProcessor(amount), rectangle); + source.ApplyProcessor(new ContrastProcessor(amount), rectangle); return source; } } diff --git a/src/ImageSharp/Processing/Effects/Invert.cs b/src/ImageSharp/Processing/Effects/Invert.cs index 6c51ad3eb..3bb1124ce 100644 --- a/src/ImageSharp/Processing/Effects/Invert.cs +++ b/src/ImageSharp/Processing/Effects/Invert.cs @@ -10,18 +10,18 @@ namespace ImageSharp using Processing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Inverts the colors of the image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The . - public static Image Invert(this Image source) - where TColor : struct, IPixel + public static Image Invert(this Image source) + where TPixel : struct, IPixel { return Invert(source, source.Bounds); } @@ -29,16 +29,16 @@ namespace ImageSharp /// /// Inverts the colors of the image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// /// The structure that specifies the portion of the image object to alter. /// /// The . - public static Image Invert(this Image source, Rectangle rectangle) - where TColor : struct, IPixel + public static Image Invert(this Image source, Rectangle rectangle) + where TPixel : struct, IPixel { - source.ApplyProcessor(new InvertProcessor(), rectangle); + source.ApplyProcessor(new InvertProcessor(), rectangle); return source; } } diff --git a/src/ImageSharp/Processing/Effects/OilPainting.cs b/src/ImageSharp/Processing/Effects/OilPainting.cs index d7d8444c0..62e6aeda7 100644 --- a/src/ImageSharp/Processing/Effects/OilPainting.cs +++ b/src/ImageSharp/Processing/Effects/OilPainting.cs @@ -10,20 +10,20 @@ namespace ImageSharp using Processing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Alters the colors of the image recreating an oil painting effect. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The number of intensity levels. Higher values result in a broader range of color intensities forming part of the result image. /// The number of neighboring pixels used in calculating each individual pixel value. - /// The . - public static Image OilPaint(this Image source, int levels = 10, int brushSize = 15) - where TColor : struct, IPixel + /// The . + public static Image OilPaint(this Image source, int levels = 10, int brushSize = 15) + where TPixel : struct, IPixel { return OilPaint(source, levels, brushSize, source.Bounds); } @@ -31,16 +31,16 @@ namespace ImageSharp /// /// Alters the colors of the image recreating an oil painting effect. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The number of intensity levels. Higher values result in a broader range of color intensities forming part of the result image. /// The number of neighboring pixels used in calculating each individual pixel value. /// /// The structure that specifies the portion of the image object to alter. /// - /// The . - public static Image OilPaint(this Image source, int levels, int brushSize, Rectangle rectangle) - where TColor : struct, IPixel + /// The . + public static Image OilPaint(this Image source, int levels, int brushSize, Rectangle rectangle) + where TPixel : struct, IPixel { Guard.MustBeGreaterThan(levels, 0, nameof(levels)); @@ -49,7 +49,7 @@ namespace ImageSharp throw new ArgumentOutOfRangeException(nameof(brushSize)); } - source.ApplyProcessor(new OilPaintingProcessor(levels, brushSize), rectangle); + source.ApplyProcessor(new OilPaintingProcessor(levels, brushSize), rectangle); return source; } } diff --git a/src/ImageSharp/Processing/Effects/Pixelate.cs b/src/ImageSharp/Processing/Effects/Pixelate.cs index 721dd930b..a57f30c96 100644 --- a/src/ImageSharp/Processing/Effects/Pixelate.cs +++ b/src/ImageSharp/Processing/Effects/Pixelate.cs @@ -10,19 +10,19 @@ namespace ImageSharp using Processing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Pixelates an image with the given pixel size. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The size of the pixels. - /// The . - public static Image Pixelate(this Image source, int size = 4) - where TColor : struct, IPixel + /// The . + public static Image Pixelate(this Image source, int size = 4) + where TPixel : struct, IPixel { return Pixelate(source, size, source.Bounds); } @@ -30,22 +30,22 @@ namespace ImageSharp /// /// Pixelates an image with the given pixel size. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The size of the pixels. /// /// The structure that specifies the portion of the image object to alter. /// - /// The . - public static Image Pixelate(this Image source, int size, Rectangle rectangle) - where TColor : struct, IPixel + /// The . + public static Image Pixelate(this Image source, int size, Rectangle rectangle) + where TPixel : struct, IPixel { if (size <= 0 || size > source.Height || size > source.Width) { throw new ArgumentOutOfRangeException(nameof(size)); } - source.ApplyProcessor(new PixelateProcessor(size), rectangle); + source.ApplyProcessor(new PixelateProcessor(size), rectangle); return source; } } diff --git a/src/ImageSharp/Processing/Overlays/Glow.cs b/src/ImageSharp/Processing/Overlays/Glow.cs index e8dfbdf0e..562012f97 100644 --- a/src/ImageSharp/Processing/Overlays/Glow.cs +++ b/src/ImageSharp/Processing/Overlays/Glow.cs @@ -10,31 +10,31 @@ namespace ImageSharp using Processing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Applies a radial glow effect to an image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. - /// The . - public static Image Glow(this Image source) - where TColor : struct, IPixel + /// The . + public static Image Glow(this Image source) + where TPixel : struct, IPixel { - return Glow(source, NamedColors.Black, source.Bounds.Width * .5F, source.Bounds); + return Glow(source, NamedColors.Black, source.Bounds.Width * .5F, source.Bounds); } /// /// Applies a radial glow effect to an image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The color to set as the glow. - /// The . - public static Image Glow(this Image source, TColor color) - where TColor : struct, IPixel + /// The . + public static Image Glow(this Image source, TPixel color) + where TPixel : struct, IPixel { return Glow(source, color, source.Bounds.Width * .5F, source.Bounds); } @@ -42,46 +42,46 @@ namespace ImageSharp /// /// Applies a radial glow effect to an image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The the radius. - /// The . - public static Image Glow(this Image source, float radius) - where TColor : struct, IPixel + /// The . + public static Image Glow(this Image source, float radius) + where TPixel : struct, IPixel { - return Glow(source, NamedColors.Black, radius, source.Bounds); + return Glow(source, NamedColors.Black, radius, source.Bounds); } /// /// Applies a radial glow effect to an image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// /// The structure that specifies the portion of the image object to alter. /// - /// The . - public static Image Glow(this Image source, Rectangle rectangle) - where TColor : struct, IPixel + /// The . + public static Image Glow(this Image source, Rectangle rectangle) + where TPixel : struct, IPixel { - return Glow(source, NamedColors.Black, 0, rectangle); + return Glow(source, NamedColors.Black, 0, rectangle); } /// /// Applies a radial glow effect to an image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The color to set as the glow. /// The the radius. /// /// The structure that specifies the portion of the image object to alter. /// - /// The . - public static Image Glow(this Image source, TColor color, float radius, Rectangle rectangle) - where TColor : struct, IPixel + /// The . + public static Image Glow(this Image source, TPixel color, float radius, Rectangle rectangle) + where TPixel : struct, IPixel { - GlowProcessor processor = new GlowProcessor(color) { Radius = radius, }; + GlowProcessor processor = new GlowProcessor(color) { Radius = radius, }; source.ApplyProcessor(processor, rectangle); return source; } diff --git a/src/ImageSharp/Processing/Overlays/Vignette.cs b/src/ImageSharp/Processing/Overlays/Vignette.cs index e42ead8d3..424200fdd 100644 --- a/src/ImageSharp/Processing/Overlays/Vignette.cs +++ b/src/ImageSharp/Processing/Overlays/Vignette.cs @@ -10,31 +10,31 @@ namespace ImageSharp using Processing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Applies a radial vignette effect to an image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. - /// The . - public static Image Vignette(this Image source) - where TColor : struct, IPixel + /// The . + public static Image Vignette(this Image source) + where TPixel : struct, IPixel { - return Vignette(source, NamedColors.Black, source.Bounds.Width * .5F, source.Bounds.Height * .5F, source.Bounds); + return Vignette(source, NamedColors.Black, source.Bounds.Width * .5F, source.Bounds.Height * .5F, source.Bounds); } /// /// Applies a radial vignette effect to an image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The color to set as the vignette. - /// The . - public static Image Vignette(this Image source, TColor color) - where TColor : struct, IPixel + /// The . + public static Image Vignette(this Image source, TPixel color) + where TPixel : struct, IPixel { return Vignette(source, color, source.Bounds.Width * .5F, source.Bounds.Height * .5F, source.Bounds); } @@ -42,36 +42,36 @@ namespace ImageSharp /// /// Applies a radial vignette effect to an image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The the x-radius. /// The the y-radius. - /// The . - public static Image Vignette(this Image source, float radiusX, float radiusY) - where TColor : struct, IPixel + /// The . + public static Image Vignette(this Image source, float radiusX, float radiusY) + where TPixel : struct, IPixel { - return Vignette(source, NamedColors.Black, radiusX, radiusY, source.Bounds); + return Vignette(source, NamedColors.Black, radiusX, radiusY, source.Bounds); } /// /// Applies a radial vignette effect to an image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// /// The structure that specifies the portion of the image object to alter. /// - /// The . - public static Image Vignette(this Image source, Rectangle rectangle) - where TColor : struct, IPixel + /// The . + public static Image Vignette(this Image source, Rectangle rectangle) + where TPixel : struct, IPixel { - return Vignette(source, NamedColors.Black, 0, 0, rectangle); + return Vignette(source, NamedColors.Black, 0, 0, rectangle); } /// /// Applies a radial vignette effect to an image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The color to set as the vignette. /// The the x-radius. @@ -79,11 +79,11 @@ namespace ImageSharp /// /// The structure that specifies the portion of the image object to alter. /// - /// The . - public static Image Vignette(this Image source, TColor color, float radiusX, float radiusY, Rectangle rectangle) - where TColor : struct, IPixel + /// The . + public static Image Vignette(this Image source, TPixel color, float radiusX, float radiusY, Rectangle rectangle) + where TPixel : struct, IPixel { - VignetteProcessor processor = new VignetteProcessor(color) { RadiusX = radiusX, RadiusY = radiusY }; + VignetteProcessor processor = new VignetteProcessor(color) { RadiusX = radiusX, RadiusY = radiusY }; source.ApplyProcessor(processor, rectangle); return source; } diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs index 555546341..f187cfcff 100644 --- a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs @@ -9,15 +9,15 @@ namespace ImageSharp.Processing.Processors using System.Threading.Tasks; /// - /// An to perform binary threshold filtering against an + /// An to perform binary threshold filtering against an /// . The image will be converted to grayscale before thresholding occurs. /// - /// The pixel format. - internal class BinaryThresholdProcessor : ImageProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class BinaryThresholdProcessor : ImageProcessor + where TPixel : struct, IPixel { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The threshold to split the image. Must be between 0 and 1. public BinaryThresholdProcessor(float threshold) @@ -27,8 +27,8 @@ namespace ImageSharp.Processing.Processors this.Threshold = threshold; // Default to white/black for upper/lower. - this.UpperColor = NamedColors.White; - this.LowerColor = NamedColors.Black; + this.UpperColor = NamedColors.White; + this.LowerColor = NamedColors.Black; } /// @@ -39,25 +39,25 @@ namespace ImageSharp.Processing.Processors /// /// Gets or sets the color to use for pixels that are above the threshold. /// - public TColor UpperColor { get; set; } + public TPixel UpperColor { get; set; } /// /// Gets or sets the color to use for pixels that fall below the threshold. /// - public TColor LowerColor { get; set; } + public TPixel LowerColor { get; set; } /// - protected override void BeforeApply(ImageBase source, Rectangle sourceRectangle) + protected override void BeforeApply(ImageBase source, Rectangle sourceRectangle) { - new GrayscaleBt709Processor().Apply(source, sourceRectangle); + new GrayscaleBt709Processor().Apply(source, sourceRectangle); } /// - protected override void OnApply(ImageBase source, Rectangle sourceRectangle) + protected override void OnApply(ImageBase source, Rectangle sourceRectangle) { float threshold = this.Threshold; - TColor upper = this.UpperColor; - TColor lower = this.LowerColor; + TPixel upper = this.UpperColor; + TPixel lower = this.LowerColor; int startY = sourceRectangle.Y; int endY = sourceRectangle.Bottom; @@ -81,7 +81,7 @@ namespace ImageSharp.Processing.Processors startY = 0; } - using (PixelAccessor sourcePixels = source.Lock()) + using (PixelAccessor sourcePixels = source.Lock()) { Parallel.For( minY, @@ -93,7 +93,7 @@ namespace ImageSharp.Processing.Processors for (int x = minX; x < maxX; x++) { int offsetX = x - startX; - TColor color = sourcePixels[offsetX, offsetY]; + TPixel color = sourcePixels[offsetX, offsetY]; // Any channel will do since it's Grayscale. sourcePixels[offsetX, offsetY] = color.ToVector4().X >= threshold ? upper : lower; diff --git a/src/ImageSharp/Processing/Processors/Binarization/ErrorDiffusionDitherProcessor.cs b/src/ImageSharp/Processing/Processors/Binarization/ErrorDiffusionDitherProcessor.cs index 50f042bd6..0fd73a84a 100644 --- a/src/ImageSharp/Processing/Processors/Binarization/ErrorDiffusionDitherProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Binarization/ErrorDiffusionDitherProcessor.cs @@ -10,14 +10,14 @@ namespace ImageSharp.Processing.Processors using ImageSharp.Dithering; /// - /// An that dithers an image using error diffusion. + /// An that dithers an image using error diffusion. /// - /// The pixel format. - internal class ErrorDiffusionDitherProcessor : ImageProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class ErrorDiffusionDitherProcessor : ImageProcessor + where TPixel : struct, IPixel { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The error diffuser /// The threshold to split the image. Must be between 0 and 1. @@ -29,8 +29,8 @@ namespace ImageSharp.Processing.Processors this.Threshold = threshold; // Default to white/black for upper/lower. - this.UpperColor = NamedColors.White; - this.LowerColor = NamedColors.Black; + this.UpperColor = NamedColors.White; + this.LowerColor = NamedColors.Black; } /// @@ -46,21 +46,21 @@ namespace ImageSharp.Processing.Processors /// /// Gets or sets the color to use for pixels that are above the threshold. /// - public TColor UpperColor { get; set; } + public TPixel UpperColor { get; set; } /// /// Gets or sets the color to use for pixels that fall below the threshold. /// - public TColor LowerColor { get; set; } + public TPixel LowerColor { get; set; } /// - protected override void BeforeApply(ImageBase source, Rectangle sourceRectangle) + protected override void BeforeApply(ImageBase source, Rectangle sourceRectangle) { - new GrayscaleBt709Processor().Apply(source, sourceRectangle); + new GrayscaleBt709Processor().Apply(source, sourceRectangle); } /// - protected override void OnApply(ImageBase source, Rectangle sourceRectangle) + protected override void OnApply(ImageBase source, Rectangle sourceRectangle) { int startY = sourceRectangle.Y; int endY = sourceRectangle.Bottom; @@ -84,7 +84,7 @@ namespace ImageSharp.Processing.Processors startY = 0; } - using (PixelAccessor sourcePixels = source.Lock()) + using (PixelAccessor sourcePixels = source.Lock()) { for (int y = minY; y < maxY; y++) { @@ -92,8 +92,8 @@ namespace ImageSharp.Processing.Processors for (int x = minX; x < maxX; x++) { int offsetX = x - startX; - TColor sourceColor = sourcePixels[offsetX, offsetY]; - TColor transformedColor = sourceColor.ToVector4().X >= this.Threshold ? this.UpperColor : this.LowerColor; + TPixel sourceColor = sourcePixels[offsetX, offsetY]; + TPixel transformedColor = sourceColor.ToVector4().X >= this.Threshold ? this.UpperColor : this.LowerColor; this.Diffuser.Dither(sourcePixels, sourceColor, transformedColor, offsetX, offsetY, maxX, maxY); } } diff --git a/src/ImageSharp/Processing/Processors/Binarization/OrderedDitherProcessor.cs b/src/ImageSharp/Processing/Processors/Binarization/OrderedDitherProcessor.cs index c7f4d20ac..08f653271 100644 --- a/src/ImageSharp/Processing/Processors/Binarization/OrderedDitherProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Binarization/OrderedDitherProcessor.cs @@ -11,14 +11,14 @@ namespace ImageSharp.Processing.Processors using ImageSharp.Dithering; /// - /// An that dithers an image using error diffusion. + /// An that dithers an image using error diffusion. /// - /// The pixel format. - internal class OrderedDitherProcessor : ImageProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class OrderedDitherProcessor : ImageProcessor + where TPixel : struct, IPixel { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The ordered ditherer. /// The component index to test the threshold against. Must range from 0 to 3. @@ -28,7 +28,7 @@ namespace ImageSharp.Processing.Processors Guard.MustBeBetweenOrEqualTo(index, 0, 3, nameof(index)); // Alpha8 only stores the pixel data in the alpha channel. - if (typeof(TColor) == typeof(Alpha8)) + if (typeof(TPixel) == typeof(Alpha8)) { index = 3; } @@ -37,8 +37,8 @@ namespace ImageSharp.Processing.Processors this.Index = index; // Default to white/black for upper/lower. - this.UpperColor = NamedColors.White; - this.LowerColor = NamedColors.Black; + this.UpperColor = NamedColors.White; + this.LowerColor = NamedColors.Black; } /// @@ -54,21 +54,21 @@ namespace ImageSharp.Processing.Processors /// /// Gets or sets the color to use for pixels that are above the threshold. /// - public TColor UpperColor { get; set; } + public TPixel UpperColor { get; set; } /// /// Gets or sets the color to use for pixels that fall below the threshold. /// - public TColor LowerColor { get; set; } + public TPixel LowerColor { get; set; } /// - protected override void BeforeApply(ImageBase source, Rectangle sourceRectangle) + protected override void BeforeApply(ImageBase source, Rectangle sourceRectangle) { - new GrayscaleBt709Processor().Apply(source, sourceRectangle); + new GrayscaleBt709Processor().Apply(source, sourceRectangle); } /// - protected override void OnApply(ImageBase source, Rectangle sourceRectangle) + protected override void OnApply(ImageBase source, Rectangle sourceRectangle) { int startY = sourceRectangle.Y; int endY = sourceRectangle.Bottom; @@ -92,7 +92,7 @@ namespace ImageSharp.Processing.Processors startY = 0; } - using (PixelAccessor sourcePixels = source.Lock()) + using (PixelAccessor sourcePixels = source.Lock()) { for (int y = minY; y < maxY; y++) { @@ -102,7 +102,7 @@ namespace ImageSharp.Processing.Processors for (int x = minX; x < maxX; x++) { int offsetX = x - startX; - TColor sourceColor = sourcePixels[offsetX, offsetY]; + TPixel sourceColor = sourcePixels[offsetX, offsetY]; this.Dither.Dither(sourcePixels, sourceColor, this.UpperColor, this.LowerColor, bytes, this.Index, offsetX, offsetY, maxX, maxY); } diff --git a/src/ImageSharp/Processing/Processors/ColorMatrix/BlackWhiteProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/BlackWhiteProcessor.cs index 0214af72d..6676d89ba 100644 --- a/src/ImageSharp/Processing/Processors/ColorMatrix/BlackWhiteProcessor.cs +++ b/src/ImageSharp/Processing/Processors/ColorMatrix/BlackWhiteProcessor.cs @@ -11,9 +11,9 @@ namespace ImageSharp.Processing.Processors /// /// Converts the colors of the image to their black and white equivalent. /// - /// The pixel format. - internal class BlackWhiteProcessor : ColorMatrixProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class BlackWhiteProcessor : ColorMatrixProcessor + where TPixel : struct, IPixel { /// public override Matrix4x4 Matrix => new Matrix4x4() diff --git a/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/AchromatomalyProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/AchromatomalyProcessor.cs index d1e986a9d..3bad624ba 100644 --- a/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/AchromatomalyProcessor.cs +++ b/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/AchromatomalyProcessor.cs @@ -11,9 +11,9 @@ namespace ImageSharp.Processing.Processors /// /// Converts the colors of the image recreating Achromatomaly (Color desensitivity) color blindness. /// - /// The pixel format. - internal class AchromatomalyProcessor : ColorMatrixProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class AchromatomalyProcessor : ColorMatrixProcessor + where TPixel : struct, IPixel { /// public override Matrix4x4 Matrix => new Matrix4x4() diff --git a/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/AchromatopsiaProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/AchromatopsiaProcessor.cs index d17e28dca..246a57481 100644 --- a/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/AchromatopsiaProcessor.cs +++ b/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/AchromatopsiaProcessor.cs @@ -11,9 +11,9 @@ namespace ImageSharp.Processing.Processors /// /// Converts the colors of the image recreating Achromatopsia (Monochrome) color blindness. /// - /// The pixel format. - internal class AchromatopsiaProcessor : ColorMatrixProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class AchromatopsiaProcessor : ColorMatrixProcessor + where TPixel : struct, IPixel { /// public override Matrix4x4 Matrix => new Matrix4x4() diff --git a/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/DeuteranomalyProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/DeuteranomalyProcessor.cs index 7f4529ba4..a79716859 100644 --- a/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/DeuteranomalyProcessor.cs +++ b/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/DeuteranomalyProcessor.cs @@ -11,9 +11,9 @@ namespace ImageSharp.Processing.Processors /// /// Converts the colors of the image recreating Deuteranomaly (Green-Weak) color blindness. /// - /// The pixel format. - internal class DeuteranomalyProcessor : ColorMatrixProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class DeuteranomalyProcessor : ColorMatrixProcessor + where TPixel : struct, IPixel { /// public override Matrix4x4 Matrix => new Matrix4x4() diff --git a/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/DeuteranopiaProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/DeuteranopiaProcessor.cs index 493ed2cae..c8cc1a962 100644 --- a/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/DeuteranopiaProcessor.cs +++ b/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/DeuteranopiaProcessor.cs @@ -11,9 +11,9 @@ namespace ImageSharp.Processing.Processors /// /// Converts the colors of the image recreating Deuteranopia (Green-Blind) color blindness. /// - /// The pixel format. - internal class DeuteranopiaProcessor : ColorMatrixProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class DeuteranopiaProcessor : ColorMatrixProcessor + where TPixel : struct, IPixel { /// public override Matrix4x4 Matrix => new Matrix4x4() diff --git a/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/ProtanomalyProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/ProtanomalyProcessor.cs index ddea24be0..618c6deae 100644 --- a/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/ProtanomalyProcessor.cs +++ b/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/ProtanomalyProcessor.cs @@ -11,9 +11,9 @@ namespace ImageSharp.Processing.Processors /// /// Converts the colors of the image recreating Protanopia (Red-Weak) color blindness. /// - /// The pixel format. - internal class ProtanomalyProcessor : ColorMatrixProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class ProtanomalyProcessor : ColorMatrixProcessor + where TPixel : struct, IPixel { /// public override Matrix4x4 Matrix => new Matrix4x4() diff --git a/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/ProtanopiaProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/ProtanopiaProcessor.cs index c5446dbe1..de87ede0c 100644 --- a/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/ProtanopiaProcessor.cs +++ b/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/ProtanopiaProcessor.cs @@ -11,9 +11,9 @@ namespace ImageSharp.Processing.Processors /// /// Converts the colors of the image recreating Protanopia (Red-Blind) color blindness. /// - /// The pixel format. - internal class ProtanopiaProcessor : ColorMatrixProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class ProtanopiaProcessor : ColorMatrixProcessor + where TPixel : struct, IPixel { /// public override Matrix4x4 Matrix => new Matrix4x4() diff --git a/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/TritanomalyProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/TritanomalyProcessor.cs index 846e9c61a..dd2a6067c 100644 --- a/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/TritanomalyProcessor.cs +++ b/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/TritanomalyProcessor.cs @@ -11,9 +11,9 @@ namespace ImageSharp.Processing.Processors /// /// Converts the colors of the image recreating Tritanomaly (Blue-Weak) color blindness. /// - /// The pixel format. - internal class TritanomalyProcessor : ColorMatrixProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class TritanomalyProcessor : ColorMatrixProcessor + where TPixel : struct, IPixel { /// public override Matrix4x4 Matrix => new Matrix4x4() diff --git a/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/TritanopiaProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/TritanopiaProcessor.cs index a0094f71f..5d8098c62 100644 --- a/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/TritanopiaProcessor.cs +++ b/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/TritanopiaProcessor.cs @@ -11,9 +11,9 @@ namespace ImageSharp.Processing.Processors /// /// Converts the colors of the image recreating Tritanopia (Blue-Blind) color blindness. /// - /// The pixel format. - internal class TritanopiaProcessor : ColorMatrixProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class TritanopiaProcessor : ColorMatrixProcessor + where TPixel : struct, IPixel { /// public override Matrix4x4 Matrix => new Matrix4x4() diff --git a/src/ImageSharp/Processing/Processors/ColorMatrix/ColorMatrixProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/ColorMatrixProcessor.cs index 55ea50869..7f5d4465a 100644 --- a/src/ImageSharp/Processing/Processors/ColorMatrix/ColorMatrixProcessor.cs +++ b/src/ImageSharp/Processing/Processors/ColorMatrix/ColorMatrixProcessor.cs @@ -12,9 +12,9 @@ namespace ImageSharp.Processing.Processors /// /// The color matrix filter. Inherit from this class to perform operation involving color matrices. /// - /// The pixel format. - internal abstract class ColorMatrixProcessor : ImageProcessor, IColorMatrixFilter - where TColor : struct, IPixel + /// The pixel format. + internal abstract class ColorMatrixProcessor : ImageProcessor, IColorMatrixFilter + where TPixel : struct, IPixel { /// public abstract Matrix4x4 Matrix { get; } @@ -23,7 +23,7 @@ namespace ImageSharp.Processing.Processors public override bool Compand { get; set; } = true; /// - protected override void OnApply(ImageBase source, Rectangle sourceRectangle) + protected override void OnApply(ImageBase source, Rectangle sourceRectangle) { int startY = sourceRectangle.Y; int endY = sourceRectangle.Bottom; @@ -50,7 +50,7 @@ namespace ImageSharp.Processing.Processors Matrix4x4 matrix = this.Matrix; bool compand = this.Compand; - using (PixelAccessor sourcePixels = source.Lock()) + using (PixelAccessor sourcePixels = source.Lock()) { Parallel.For( minY, @@ -77,7 +77,7 @@ namespace ImageSharp.Processing.Processors /// /// The . /// - private TColor ApplyMatrix(TColor color, Matrix4x4 matrix, bool compand) + private TPixel ApplyMatrix(TPixel color, Matrix4x4 matrix, bool compand) { Vector4 vector = color.ToVector4(); @@ -87,7 +87,7 @@ namespace ImageSharp.Processing.Processors } vector = Vector4.Transform(vector, matrix); - TColor packed = default(TColor); + TPixel packed = default(TPixel); packed.PackFromVector4(compand ? vector.Compress() : vector); return packed; } diff --git a/src/ImageSharp/Processing/Processors/ColorMatrix/GrayscaleBt601Processor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/GrayscaleBt601Processor.cs index 1f5a0fa7e..add3e266b 100644 --- a/src/ImageSharp/Processing/Processors/ColorMatrix/GrayscaleBt601Processor.cs +++ b/src/ImageSharp/Processing/Processors/ColorMatrix/GrayscaleBt601Processor.cs @@ -12,9 +12,9 @@ namespace ImageSharp.Processing.Processors /// Converts the colors of the image to Grayscale applying the formula as specified by ITU-R Recommendation BT.601 /// . /// - /// The pixel format. - internal class GrayscaleBt601Processor : ColorMatrixProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class GrayscaleBt601Processor : ColorMatrixProcessor + where TPixel : struct, IPixel { /// public override Matrix4x4 Matrix => new Matrix4x4() diff --git a/src/ImageSharp/Processing/Processors/ColorMatrix/GrayscaleBt709Processor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/GrayscaleBt709Processor.cs index 048462696..8e7956e5d 100644 --- a/src/ImageSharp/Processing/Processors/ColorMatrix/GrayscaleBt709Processor.cs +++ b/src/ImageSharp/Processing/Processors/ColorMatrix/GrayscaleBt709Processor.cs @@ -12,9 +12,9 @@ namespace ImageSharp.Processing.Processors /// Converts the colors of the image to Grayscale applying the formula as specified by ITU-R Recommendation BT.709 /// . /// - /// The pixel format. - internal class GrayscaleBt709Processor : ColorMatrixProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class GrayscaleBt709Processor : ColorMatrixProcessor + where TPixel : struct, IPixel { /// public override Matrix4x4 Matrix => new Matrix4x4() diff --git a/src/ImageSharp/Processing/Processors/ColorMatrix/HueProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/HueProcessor.cs index 0d06c5868..e5fd0318c 100644 --- a/src/ImageSharp/Processing/Processors/ColorMatrix/HueProcessor.cs +++ b/src/ImageSharp/Processing/Processors/ColorMatrix/HueProcessor.cs @@ -9,14 +9,14 @@ namespace ImageSharp.Processing.Processors using System.Numerics; /// - /// An to change the hue of an . + /// An to change the hue of an . /// - /// The pixel format. - internal class HueProcessor : ColorMatrixProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class HueProcessor : ColorMatrixProcessor + where TPixel : struct, IPixel { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The new brightness of the image. Must be between -100 and 100. public HueProcessor(float angle) diff --git a/src/ImageSharp/Processing/Processors/ColorMatrix/IColorMatrixFilter.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/IColorMatrixFilter.cs index 57296a0c3..ca57f6633 100644 --- a/src/ImageSharp/Processing/Processors/ColorMatrix/IColorMatrixFilter.cs +++ b/src/ImageSharp/Processing/Processors/ColorMatrix/IColorMatrixFilter.cs @@ -12,9 +12,9 @@ namespace ImageSharp.Processing.Processors /// Encapsulates properties and methods for creating processors that utilize a matrix to /// alter the image pixels. /// - /// The pixel format. - internal interface IColorMatrixFilter : IImageProcessor - where TColor : struct, IPixel + /// The pixel format. + internal interface IColorMatrixFilter : IImageProcessor + where TPixel : struct, IPixel { /// /// Gets the used to alter the image. diff --git a/src/ImageSharp/Processing/Processors/ColorMatrix/KodachromeProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/KodachromeProcessor.cs index 8df8efcd1..fe6b07c03 100644 --- a/src/ImageSharp/Processing/Processors/ColorMatrix/KodachromeProcessor.cs +++ b/src/ImageSharp/Processing/Processors/ColorMatrix/KodachromeProcessor.cs @@ -11,9 +11,9 @@ namespace ImageSharp.Processing.Processors /// /// Converts the colors of the image recreating an old Kodachrome camera effect. /// - /// The pixel format. - internal class KodachromeProcessor : ColorMatrixProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class KodachromeProcessor : ColorMatrixProcessor + where TPixel : struct, IPixel { /// public override Matrix4x4 Matrix => new Matrix4x4() diff --git a/src/ImageSharp/Processing/Processors/ColorMatrix/LomographProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/LomographProcessor.cs index b89caec86..2071fc7bb 100644 --- a/src/ImageSharp/Processing/Processors/ColorMatrix/LomographProcessor.cs +++ b/src/ImageSharp/Processing/Processors/ColorMatrix/LomographProcessor.cs @@ -11,11 +11,11 @@ namespace ImageSharp.Processing.Processors /// /// Converts the colors of the image recreating an old Lomograph effect. /// - /// The pixel format. - internal class LomographProcessor : ColorMatrixProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class LomographProcessor : ColorMatrixProcessor + where TPixel : struct, IPixel { - private static readonly TColor VeryDarkGreen = ColorBuilder.FromRGBA(0, 10, 0, 255); + private static readonly TPixel VeryDarkGreen = ColorBuilder.FromRGBA(0, 10, 0, 255); /// public override Matrix4x4 Matrix => new Matrix4x4() @@ -30,9 +30,9 @@ namespace ImageSharp.Processing.Processors }; /// - protected override void AfterApply(ImageBase source, Rectangle sourceRectangle) + protected override void AfterApply(ImageBase source, Rectangle sourceRectangle) { - new VignetteProcessor(VeryDarkGreen).Apply(source, sourceRectangle); + new VignetteProcessor(VeryDarkGreen).Apply(source, sourceRectangle); } } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Processors/ColorMatrix/PolaroidProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/PolaroidProcessor.cs index b5a23f855..d625b641d 100644 --- a/src/ImageSharp/Processing/Processors/ColorMatrix/PolaroidProcessor.cs +++ b/src/ImageSharp/Processing/Processors/ColorMatrix/PolaroidProcessor.cs @@ -11,12 +11,12 @@ namespace ImageSharp.Processing.Processors /// /// Converts the colors of the image recreating an old Polaroid effect. /// - /// The pixel format. - internal class PolaroidProcessor : ColorMatrixProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class PolaroidProcessor : ColorMatrixProcessor + where TPixel : struct, IPixel { - private static TColor veryDarkOrange = ColorBuilder.FromRGB(102, 34, 0); - private static TColor lightOrange = ColorBuilder.FromRGBA(255, 153, 102, 178); + private static TPixel veryDarkOrange = ColorBuilder.FromRGB(102, 34, 0); + private static TPixel lightOrange = ColorBuilder.FromRGBA(255, 153, 102, 178); /// public override Matrix4x4 Matrix => new Matrix4x4() @@ -37,10 +37,10 @@ namespace ImageSharp.Processing.Processors }; /// - protected override void AfterApply(ImageBase source, Rectangle sourceRectangle) + protected override void AfterApply(ImageBase source, Rectangle sourceRectangle) { - new VignetteProcessor(veryDarkOrange).Apply(source, sourceRectangle); - new GlowProcessor(lightOrange) { Radius = source.Width / 4F }.Apply(source, sourceRectangle); + new VignetteProcessor(veryDarkOrange).Apply(source, sourceRectangle); + new GlowProcessor(lightOrange) { Radius = source.Width / 4F }.Apply(source, sourceRectangle); } } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Processors/ColorMatrix/SaturationProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/SaturationProcessor.cs index 371294dd5..cd8947d05 100644 --- a/src/ImageSharp/Processing/Processors/ColorMatrix/SaturationProcessor.cs +++ b/src/ImageSharp/Processing/Processors/ColorMatrix/SaturationProcessor.cs @@ -9,14 +9,14 @@ namespace ImageSharp.Processing.Processors using System.Numerics; /// - /// An to change the saturation of an . + /// An to change the saturation of an . /// - /// The pixel format. - internal class SaturationProcessor : ColorMatrixProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class SaturationProcessor : ColorMatrixProcessor + where TPixel : struct, IPixel { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The new saturation of the image. Must be between -100 and 100. /// diff --git a/src/ImageSharp/Processing/Processors/ColorMatrix/SepiaProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/SepiaProcessor.cs index 49a071bd9..8d9ef17d0 100644 --- a/src/ImageSharp/Processing/Processors/ColorMatrix/SepiaProcessor.cs +++ b/src/ImageSharp/Processing/Processors/ColorMatrix/SepiaProcessor.cs @@ -12,9 +12,9 @@ namespace ImageSharp.Processing.Processors /// Converts the colors of the image to their sepia equivalent. /// The formula used matches the svg specification. /// - /// The pixel format. - internal class SepiaProcessor : ColorMatrixProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class SepiaProcessor : ColorMatrixProcessor + where TPixel : struct, IPixel { /// public override Matrix4x4 Matrix => new Matrix4x4 diff --git a/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor.cs index 7ffca534c..26a531d0c 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor.cs @@ -10,9 +10,9 @@ namespace ImageSharp.Processing.Processors /// /// Applies a Box blur sampler to the image. /// - /// The pixel format. - internal class BoxBlurProcessor : ImageProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class BoxBlurProcessor : ImageProcessor + where TPixel : struct, IPixel { /// /// The maximum size of the kernel in either direction. @@ -20,7 +20,7 @@ namespace ImageSharp.Processing.Processors private readonly int kernelSize; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// /// The 'radius' value representing the size of the area to sample. @@ -43,9 +43,9 @@ namespace ImageSharp.Processing.Processors public Fast2DArray KernelY { get; } /// - protected override void OnApply(ImageBase source, Rectangle sourceRectangle) + protected override void OnApply(ImageBase source, Rectangle sourceRectangle) { - new Convolution2PassProcessor(this.KernelX, this.KernelY).Apply(source, sourceRectangle); + new Convolution2PassProcessor(this.KernelX, this.KernelY).Apply(source, sourceRectangle); } /// diff --git a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor.cs index fa06a863e..8ca06b359 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor.cs @@ -12,12 +12,12 @@ namespace ImageSharp.Processing.Processors /// /// Defines a sampler that uses two one-dimensional matrices to perform convolution against an image. /// - /// The pixel format. - internal class Convolution2DProcessor : ImageProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class Convolution2DProcessor : ImageProcessor + where TPixel : struct, IPixel { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The horizontal gradient operator. /// The vertical gradient operator. @@ -38,7 +38,7 @@ namespace ImageSharp.Processing.Processors public Fast2DArray KernelY { get; } /// - protected override void OnApply(ImageBase source, Rectangle sourceRectangle) + protected override void OnApply(ImageBase source, Rectangle sourceRectangle) { int kernelYHeight = this.KernelY.Height; int kernelYWidth = this.KernelY.Width; @@ -54,9 +54,9 @@ namespace ImageSharp.Processing.Processors int maxY = endY - 1; int maxX = endX - 1; - using (PixelAccessor targetPixels = new PixelAccessor(source.Width, source.Height)) + using (PixelAccessor targetPixels = new PixelAccessor(source.Width, source.Height)) { - using (PixelAccessor sourcePixels = source.Lock()) + using (PixelAccessor sourcePixels = source.Lock()) { Parallel.For( startY, @@ -112,7 +112,7 @@ namespace ImageSharp.Processing.Processors float green = MathF.Sqrt((gX * gX) + (gY * gY)); float blue = MathF.Sqrt((bX * bX) + (bY * bY)); - TColor packed = default(TColor); + TPixel packed = default(TPixel); packed.PackFromVector4(new Vector4(red, green, blue, sourcePixels[x, y].ToVector4().W)); targetPixels[x, y] = packed; } diff --git a/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor.cs index 45906a46f..ca114b10a 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor.cs @@ -12,12 +12,12 @@ namespace ImageSharp.Processing.Processors /// /// Defines a sampler that uses two one-dimensional matrices to perform two-pass convolution against an image. /// - /// The pixel format. - internal class Convolution2PassProcessor : ImageProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class Convolution2PassProcessor : ImageProcessor + where TPixel : struct, IPixel { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The horizontal gradient operator. /// The vertical gradient operator. @@ -38,15 +38,15 @@ namespace ImageSharp.Processing.Processors public Fast2DArray KernelY { get; } /// - protected override void OnApply(ImageBase source, Rectangle sourceRectangle) + protected override void OnApply(ImageBase source, Rectangle sourceRectangle) { int width = source.Width; int height = source.Height; - using (PixelAccessor targetPixels = new PixelAccessor(width, height)) + using (PixelAccessor targetPixels = new PixelAccessor(width, height)) { - using (PixelAccessor firstPassPixels = new PixelAccessor(width, height)) - using (PixelAccessor sourcePixels = source.Lock()) + using (PixelAccessor firstPassPixels = new PixelAccessor(width, height)) + using (PixelAccessor sourcePixels = source.Lock()) { this.ApplyConvolution(firstPassPixels, sourcePixels, sourceRectangle, this.KernelX); this.ApplyConvolution(targetPixels, firstPassPixels, sourceRectangle, this.KernelY); @@ -57,7 +57,7 @@ namespace ImageSharp.Processing.Processors } /// - /// Applies the process to the specified portion of the specified at the specified location + /// Applies the process to the specified portion of the specified at the specified location /// and with the specified size. /// /// The target pixels to apply the process to. @@ -66,7 +66,7 @@ namespace ImageSharp.Processing.Processors /// The structure that specifies the portion of the image object to draw. /// /// The kernel operator. - private void ApplyConvolution(PixelAccessor targetPixels, PixelAccessor sourcePixels, Rectangle sourceRectangle, Fast2DArray kernel) + private void ApplyConvolution(PixelAccessor targetPixels, PixelAccessor sourcePixels, Rectangle sourceRectangle, Fast2DArray kernel) { int kernelHeight = kernel.Height; int kernelWidth = kernel.Width; @@ -110,7 +110,7 @@ namespace ImageSharp.Processing.Processors } } - TColor packed = default(TColor); + TPixel packed = default(TPixel); packed.PackFromVector4(destination); targetPixels[x, y] = packed; } diff --git a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor.cs index 3ab95c4ce..d3b11d781 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor.cs @@ -12,12 +12,12 @@ namespace ImageSharp.Processing.Processors /// /// Defines a sampler that uses a 2 dimensional matrix to perform convolution against an image. /// - /// The pixel format. - internal class ConvolutionProcessor : ImageProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class ConvolutionProcessor : ImageProcessor + where TPixel : struct, IPixel { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The 2d gradient operator. public ConvolutionProcessor(Fast2DArray kernelXY) @@ -31,7 +31,7 @@ namespace ImageSharp.Processing.Processors public Fast2DArray KernelXY { get; } /// - protected override void OnApply(ImageBase source, Rectangle sourceRectangle) + protected override void OnApply(ImageBase source, Rectangle sourceRectangle) { int kernelLength = this.KernelXY.Height; int radius = kernelLength >> 1; @@ -43,9 +43,9 @@ namespace ImageSharp.Processing.Processors int maxY = endY - 1; int maxX = endX - 1; - using (PixelAccessor targetPixels = new PixelAccessor(source.Width, source.Height)) + using (PixelAccessor targetPixels = new PixelAccessor(source.Width, source.Height)) { - using (PixelAccessor sourcePixels = source.Lock()) + using (PixelAccessor sourcePixels = source.Lock()) { Parallel.For( startY, @@ -83,7 +83,7 @@ namespace ImageSharp.Processing.Processors } } - TColor packed = default(TColor); + TPixel packed = default(TPixel); packed.PackFromVector4(new Vector4(red, green, blue, sourcePixels[x, y].ToVector4().W)); targetPixels[x, y] = packed; } diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetector2DProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetector2DProcessor.cs index b5c681656..855820f18 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetector2DProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetector2DProcessor.cs @@ -10,12 +10,12 @@ namespace ImageSharp.Processing.Processors /// /// Defines a sampler that detects edges within an image using two one-dimensional matrices. /// - /// The pixel format. - internal abstract class EdgeDetector2DProcessor : ImageProcessor, IEdgeDetectorProcessor - where TColor : struct, IPixel + /// The pixel format. + internal abstract class EdgeDetector2DProcessor : ImageProcessor, IEdgeDetectorProcessor + where TPixel : struct, IPixel { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The horizontal gradient operator. /// The vertical gradient operator. @@ -39,17 +39,17 @@ namespace ImageSharp.Processing.Processors public bool Grayscale { get; set; } /// - protected override void OnApply(ImageBase source, Rectangle sourceRectangle) + protected override void OnApply(ImageBase source, Rectangle sourceRectangle) { - new Convolution2DProcessor(this.KernelX, this.KernelY).Apply(source, sourceRectangle); + new Convolution2DProcessor(this.KernelX, this.KernelY).Apply(source, sourceRectangle); } /// - protected override void BeforeApply(ImageBase source, Rectangle sourceRectangle) + protected override void BeforeApply(ImageBase source, Rectangle sourceRectangle) { if (this.Grayscale) { - new GrayscaleBt709Processor().Apply(source, sourceRectangle); + new GrayscaleBt709Processor().Apply(source, sourceRectangle); } } } diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorCompassProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorCompassProcessor.cs index e92c2d109..43a0942b8 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorCompassProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorCompassProcessor.cs @@ -12,9 +12,9 @@ namespace ImageSharp.Processing.Processors /// /// Defines a sampler that detects edges within an image using a eight two dimensional matrices. /// - /// The pixel format. - internal abstract class EdgeDetectorCompassProcessor : ImageProcessor, IEdgeDetectorProcessor - where TColor : struct, IPixel + /// The pixel format. + internal abstract class EdgeDetectorCompassProcessor : ImageProcessor, IEdgeDetectorProcessor + where TPixel : struct, IPixel { /// /// Gets the North gradient operator @@ -60,16 +60,16 @@ namespace ImageSharp.Processing.Processors public bool Grayscale { get; set; } /// - protected override void BeforeApply(ImageBase source, Rectangle sourceRectangle) + protected override void BeforeApply(ImageBase source, Rectangle sourceRectangle) { if (this.Grayscale) { - new GrayscaleBt709Processor().Apply(source, sourceRectangle); + new GrayscaleBt709Processor().Apply(source, sourceRectangle); } } /// - protected override void OnApply(ImageBase source, Rectangle sourceRectangle) + protected override void OnApply(ImageBase source, Rectangle sourceRectangle) { Fast2DArray[] kernels = { this.North, this.NorthWest, this.West, this.SouthWest, this.South, this.SouthEast, this.East, this.NorthEast }; @@ -85,9 +85,9 @@ namespace ImageSharp.Processing.Processors int maxY = Math.Min(source.Height, endY); // we need a clean copy for each pass to start from - using (ImageBase cleanCopy = new Image(source)) + using (ImageBase cleanCopy = new Image(source)) { - new ConvolutionProcessor(kernels[0]).Apply(source, sourceRectangle); + new ConvolutionProcessor(kernels[0]).Apply(source, sourceRectangle); if (kernels.Length == 1) { @@ -112,12 +112,12 @@ namespace ImageSharp.Processing.Processors // ReSharper disable once ForCanBeConvertedToForeach for (int i = 1; i < kernels.Length; i++) { - using (ImageBase pass = new Image(cleanCopy)) + using (ImageBase pass = new Image(cleanCopy)) { - new ConvolutionProcessor(kernels[i]).Apply(pass, sourceRectangle); + new ConvolutionProcessor(kernels[i]).Apply(pass, sourceRectangle); - using (PixelAccessor passPixels = pass.Lock()) - using (PixelAccessor targetPixels = source.Lock()) + using (PixelAccessor passPixels = pass.Lock()) + using (PixelAccessor targetPixels = source.Lock()) { Parallel.For( minY, @@ -131,7 +131,7 @@ namespace ImageSharp.Processing.Processors int offsetX = x - shiftX; // Grab the max components of the two pixels - TColor packed = default(TColor); + TPixel packed = default(TPixel); packed.PackFromVector4(Vector4.Max(passPixels[offsetX, offsetY].ToVector4(), targetPixels[offsetX, offsetY].ToVector4())); targetPixels[offsetX, offsetY] = packed; } diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorProcessor.cs index d8b491faf..8fbf2fe0b 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorProcessor.cs @@ -10,12 +10,12 @@ namespace ImageSharp.Processing.Processors /// /// Defines a sampler that detects edges within an image using a single two dimensional matrix. /// - /// The pixel format. - internal abstract class EdgeDetectorProcessor : ImageProcessor, IEdgeDetectorProcessor - where TColor : struct, IPixel + /// The pixel format. + internal abstract class EdgeDetectorProcessor : ImageProcessor, IEdgeDetectorProcessor + where TPixel : struct, IPixel { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The 2d gradient operator. protected EdgeDetectorProcessor(Fast2DArray kernelXY) @@ -32,18 +32,18 @@ namespace ImageSharp.Processing.Processors public Fast2DArray KernelXY { get; } /// - protected override void BeforeApply(ImageBase source, Rectangle sourceRectangle) + protected override void BeforeApply(ImageBase source, Rectangle sourceRectangle) { if (this.Grayscale) { - new GrayscaleBt709Processor().Apply(source, sourceRectangle); + new GrayscaleBt709Processor().Apply(source, sourceRectangle); } } /// - protected override void OnApply(ImageBase source, Rectangle sourceRectangle) + protected override void OnApply(ImageBase source, Rectangle sourceRectangle) { - new ConvolutionProcessor(this.KernelXY).Apply(source, sourceRectangle); + new ConvolutionProcessor(this.KernelXY).Apply(source, sourceRectangle); } } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/IEdgeDetectorProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/IEdgeDetectorProcessor.cs index 7c0923bbb..39d11a485 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/IEdgeDetectorProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/IEdgeDetectorProcessor.cs @@ -10,9 +10,9 @@ namespace ImageSharp.Processing.Processors /// /// Provides properties and methods allowing the detection of edges within an image. /// - /// The pixel format. - public interface IEdgeDetectorProcessor : IImageProcessor, IEdgeDetectorProcessor - where TColor : struct, IPixel + /// The pixel format. + public interface IEdgeDetectorProcessor : IImageProcessor, IEdgeDetectorProcessor + where TPixel : struct, IPixel { } diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/KayyaliProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/KayyaliProcessor.cs index 20e7b1b17..56d5ac01d 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/KayyaliProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/KayyaliProcessor.cs @@ -12,10 +12,10 @@ namespace ImageSharp.Processing.Processors /// The Kayyali operator filter. /// /// - /// The pixel format. + /// The pixel format. [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] - internal class KayyaliProcessor : EdgeDetector2DProcessor - where TColor : struct, IPixel + internal class KayyaliProcessor : EdgeDetector2DProcessor + where TPixel : struct, IPixel { /// /// The horizontal gradient operator. @@ -40,7 +40,7 @@ namespace ImageSharp.Processing.Processors }; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// public KayyaliProcessor() : base(KayyaliX, KayyaliY) diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/KirschProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/KirschProcessor.cs index 1b88a2200..f1f504f26 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/KirschProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/KirschProcessor.cs @@ -12,10 +12,10 @@ namespace ImageSharp.Processing.Processors /// The Kirsch operator filter. /// /// - /// The pixel format. + /// The pixel format. [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] - internal class KirschProcessor : EdgeDetectorCompassProcessor - where TColor : struct, IPixel + internal class KirschProcessor : EdgeDetectorCompassProcessor + where TPixel : struct, IPixel { /// /// The North gradient operator diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/Laplacian3X3Processor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/Laplacian3X3Processor.cs index ec6963b1e..61a8858b7 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/Laplacian3X3Processor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/Laplacian3X3Processor.cs @@ -12,10 +12,10 @@ namespace ImageSharp.Processing.Processors /// The Laplacian 3 x 3 operator filter. /// /// - /// The pixel format. + /// The pixel format. [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] - internal class Laplacian3X3Processor : EdgeDetectorProcessor - where TColor : struct, IPixel + internal class Laplacian3X3Processor : EdgeDetectorProcessor + where TPixel : struct, IPixel { /// /// The 2d gradient operator. @@ -29,7 +29,7 @@ namespace ImageSharp.Processing.Processors }; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// public Laplacian3X3Processor() : base(Laplacian3X3XY) diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/Laplacian5X5Processor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/Laplacian5X5Processor.cs index cc68c4fb7..2c3929712 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/Laplacian5X5Processor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/Laplacian5X5Processor.cs @@ -12,10 +12,10 @@ namespace ImageSharp.Processing.Processors /// The Laplacian 5 x 5 operator filter. /// /// - /// The pixel format. + /// The pixel format. [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] - internal class Laplacian5X5Processor : EdgeDetectorProcessor - where TColor : struct, IPixel + internal class Laplacian5X5Processor : EdgeDetectorProcessor + where TPixel : struct, IPixel { /// /// The 2d gradient operator. @@ -31,7 +31,7 @@ namespace ImageSharp.Processing.Processors }; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// public Laplacian5X5Processor() : base(Laplacian5X5XY) diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/LaplacianOfGaussianProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/LaplacianOfGaussianProcessor.cs index f0944e681..aa9b4b9f2 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/LaplacianOfGaussianProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/LaplacianOfGaussianProcessor.cs @@ -12,10 +12,10 @@ namespace ImageSharp.Processing.Processors /// The Laplacian of Gaussian operator filter. /// /// - /// The pixel format. + /// The pixel format. [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] - internal class LaplacianOfGaussianProcessor : EdgeDetectorProcessor - where TColor : struct, IPixel + internal class LaplacianOfGaussianProcessor : EdgeDetectorProcessor + where TPixel : struct, IPixel { /// /// The 2d gradient operator. @@ -31,7 +31,7 @@ namespace ImageSharp.Processing.Processors }; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// public LaplacianOfGaussianProcessor() : base(LaplacianOfGaussianXY) diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/PrewittProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/PrewittProcessor.cs index fdb63d837..24faf20d0 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/PrewittProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/PrewittProcessor.cs @@ -12,10 +12,10 @@ namespace ImageSharp.Processing.Processors /// The Prewitt operator filter. /// /// - /// The pixel format. + /// The pixel format. [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] - internal class PrewittProcessor : EdgeDetector2DProcessor - where TColor : struct, IPixel + internal class PrewittProcessor : EdgeDetector2DProcessor + where TPixel : struct, IPixel { /// /// The horizontal gradient operator. @@ -40,7 +40,7 @@ namespace ImageSharp.Processing.Processors }; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// public PrewittProcessor() : base(PrewittX, PrewittY) diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/RobertsCrossProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/RobertsCrossProcessor.cs index d9c5f5d21..efbdc7ffa 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/RobertsCrossProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/RobertsCrossProcessor.cs @@ -12,10 +12,10 @@ namespace ImageSharp.Processing.Processors /// The Roberts Cross operator filter. /// /// - /// The pixel format. + /// The pixel format. [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] - internal class RobertsCrossProcessor : EdgeDetector2DProcessor - where TColor : struct, IPixel + internal class RobertsCrossProcessor : EdgeDetector2DProcessor + where TPixel : struct, IPixel { /// /// The horizontal gradient operator. @@ -38,7 +38,7 @@ namespace ImageSharp.Processing.Processors }; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// public RobertsCrossProcessor() : base(RobertsCrossX, RobertsCrossY) diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/RobinsonProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/RobinsonProcessor.cs index 681d983c4..f6ab60fd3 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/RobinsonProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/RobinsonProcessor.cs @@ -12,10 +12,10 @@ namespace ImageSharp.Processing.Processors /// The Kirsch operator filter. /// /// - /// The pixel format. + /// The pixel format. [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] - internal class RobinsonProcessor : EdgeDetectorCompassProcessor - where TColor : struct, IPixel + internal class RobinsonProcessor : EdgeDetectorCompassProcessor + where TPixel : struct, IPixel { /// /// The North gradient operator diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/ScharrProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/ScharrProcessor.cs index c1e83b7f9..41e3d16f4 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/ScharrProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/ScharrProcessor.cs @@ -12,10 +12,10 @@ namespace ImageSharp.Processing.Processors /// The Scharr operator filter. /// /// - /// The pixel format. + /// The pixel format. [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] - internal class ScharrProcessor : EdgeDetector2DProcessor - where TColor : struct, IPixel + internal class ScharrProcessor : EdgeDetector2DProcessor + where TPixel : struct, IPixel { /// /// The horizontal gradient operator. @@ -40,7 +40,7 @@ namespace ImageSharp.Processing.Processors }; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// public ScharrProcessor() : base(ScharrX, ScharrY) diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/SobelProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/SobelProcessor.cs index 0c13fa3d2..245df5afd 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/SobelProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/SobelProcessor.cs @@ -12,10 +12,10 @@ namespace ImageSharp.Processing.Processors /// The Sobel operator filter. /// /// - /// The pixel format. + /// The pixel format. [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] - internal class SobelProcessor : EdgeDetector2DProcessor - where TColor : struct, IPixel + internal class SobelProcessor : EdgeDetector2DProcessor + where TPixel : struct, IPixel { /// /// The horizontal gradient operator. @@ -40,7 +40,7 @@ namespace ImageSharp.Processing.Processors }; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// public SobelProcessor() : base(SobelX, SobelY) diff --git a/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor.cs index 65a137e35..c0f025630 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor.cs @@ -10,9 +10,9 @@ namespace ImageSharp.Processing.Processors /// /// Applies a Gaussian blur sampler to the image. /// - /// The pixel format. - internal class GaussianBlurProcessor : ImageProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class GaussianBlurProcessor : ImageProcessor + where TPixel : struct, IPixel { /// /// The maximum size of the kernel in either direction. @@ -25,7 +25,7 @@ namespace ImageSharp.Processing.Processors private readonly float sigma; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The 'sigma' value representing the weight of the blur. public GaussianBlurProcessor(float sigma = 3f) @@ -37,7 +37,7 @@ namespace ImageSharp.Processing.Processors } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// /// The 'radius' value representing the size of the area to sample. @@ -51,7 +51,7 @@ namespace ImageSharp.Processing.Processors } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// /// The 'sigma' value representing the weight of the blur. @@ -79,9 +79,9 @@ namespace ImageSharp.Processing.Processors public Fast2DArray KernelY { get; } /// - protected override void OnApply(ImageBase source, Rectangle sourceRectangle) + protected override void OnApply(ImageBase source, Rectangle sourceRectangle) { - new Convolution2PassProcessor(this.KernelX, this.KernelY).Apply(source, sourceRectangle); + new Convolution2PassProcessor(this.KernelX, this.KernelY).Apply(source, sourceRectangle); } /// diff --git a/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor.cs index bb3dc6f99..353763843 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor.cs @@ -10,9 +10,9 @@ namespace ImageSharp.Processing.Processors /// /// Applies a Gaussian sharpening sampler to the image. /// - /// The pixel format. - internal class GaussianSharpenProcessor : ImageProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class GaussianSharpenProcessor : ImageProcessor + where TPixel : struct, IPixel { /// /// The maximum size of the kernel in either direction. @@ -25,7 +25,7 @@ namespace ImageSharp.Processing.Processors private readonly float sigma; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// /// The 'sigma' value representing the weight of the sharpening. @@ -39,7 +39,7 @@ namespace ImageSharp.Processing.Processors } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// /// The 'radius' value representing the size of the area to sample. @@ -53,7 +53,7 @@ namespace ImageSharp.Processing.Processors } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// /// The 'sigma' value representing the weight of the sharpen. @@ -81,9 +81,9 @@ namespace ImageSharp.Processing.Processors public Fast2DArray KernelY { get; } /// - protected override void OnApply(ImageBase source, Rectangle sourceRectangle) + protected override void OnApply(ImageBase source, Rectangle sourceRectangle) { - new Convolution2PassProcessor(this.KernelX, this.KernelY).Apply(source, sourceRectangle); + new Convolution2PassProcessor(this.KernelX, this.KernelY).Apply(source, sourceRectangle); } /// diff --git a/src/ImageSharp/Processing/Processors/Effects/AlphaProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/AlphaProcessor.cs index ce48aea1a..48b8a64b2 100644 --- a/src/ImageSharp/Processing/Processors/Effects/AlphaProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Effects/AlphaProcessor.cs @@ -10,14 +10,14 @@ namespace ImageSharp.Processing.Processors using System.Threading.Tasks; /// - /// An to change the alpha component of an . + /// An to change the alpha component of an . /// - /// The pixel format. - internal class AlphaProcessor : ImageProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class AlphaProcessor : ImageProcessor + where TPixel : struct, IPixel { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The percentage to adjust the opacity of the image. Must be between 0 and 100. /// @@ -35,7 +35,7 @@ namespace ImageSharp.Processing.Processors public int Value { get; } /// - protected override void OnApply(ImageBase source, Rectangle sourceRectangle) + protected override void OnApply(ImageBase source, Rectangle sourceRectangle) { float alpha = this.Value / 100F; @@ -63,7 +63,7 @@ namespace ImageSharp.Processing.Processors Vector4 alphaVector = new Vector4(1, 1, 1, alpha); - using (PixelAccessor sourcePixels = source.Lock()) + using (PixelAccessor sourcePixels = source.Lock()) { Parallel.For( minY, @@ -75,7 +75,7 @@ namespace ImageSharp.Processing.Processors for (int x = minX; x < maxX; x++) { int offsetX = x - startX; - TColor packed = default(TColor); + TPixel packed = default(TPixel); packed.PackFromVector4(sourcePixels[offsetX, offsetY].ToVector4() * alphaVector); sourcePixels[offsetX, offsetY] = packed; } diff --git a/src/ImageSharp/Processing/Processors/Effects/BackgroundColorProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/BackgroundColorProcessor.cs index d928eb1a4..368986b5d 100644 --- a/src/ImageSharp/Processing/Processors/Effects/BackgroundColorProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Effects/BackgroundColorProcessor.cs @@ -12,15 +12,15 @@ namespace ImageSharp.Processing.Processors /// /// Sets the background color of the image. /// - /// The pixel format. - internal class BackgroundColorProcessor : ImageProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class BackgroundColorProcessor : ImageProcessor + where TPixel : struct, IPixel { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - /// The to set the background color to. - public BackgroundColorProcessor(TColor color) + /// The to set the background color to. + public BackgroundColorProcessor(TPixel color) { this.Value = color; } @@ -28,10 +28,10 @@ namespace ImageSharp.Processing.Processors /// /// Gets the background color value. /// - public TColor Value { get; } + public TPixel Value { get; } /// - protected override void OnApply(ImageBase source, Rectangle sourceRectangle) + protected override void OnApply(ImageBase source, Rectangle sourceRectangle) { int startY = sourceRectangle.Y; int endY = sourceRectangle.Bottom; @@ -57,7 +57,7 @@ namespace ImageSharp.Processing.Processors Vector4 backgroundColor = this.Value.ToVector4(); - using (PixelAccessor sourcePixels = source.Lock()) + using (PixelAccessor sourcePixels = source.Lock()) { Parallel.For( minY, @@ -82,7 +82,7 @@ namespace ImageSharp.Processing.Processors color = backgroundColor; } - TColor packed = default(TColor); + TPixel packed = default(TPixel); packed.PackFromVector4(color); sourcePixels[offsetX, offsetY] = packed; } diff --git a/src/ImageSharp/Processing/Processors/Effects/BrightnessProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/BrightnessProcessor.cs index 84df5e89e..5647a6453 100644 --- a/src/ImageSharp/Processing/Processors/Effects/BrightnessProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Effects/BrightnessProcessor.cs @@ -10,14 +10,14 @@ namespace ImageSharp.Processing.Processors using System.Threading.Tasks; /// - /// An to change the brightness of an . + /// An to change the brightness of an . /// - /// The pixel format. - internal class BrightnessProcessor : ImageProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class BrightnessProcessor : ImageProcessor + where TPixel : struct, IPixel { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The new brightness of the image. Must be between -100 and 100. /// @@ -35,7 +35,7 @@ namespace ImageSharp.Processing.Processors public int Value { get; } /// - protected override void OnApply(ImageBase source, Rectangle sourceRectangle) + protected override void OnApply(ImageBase source, Rectangle sourceRectangle) { float brightness = this.Value / 100F; @@ -61,7 +61,7 @@ namespace ImageSharp.Processing.Processors startY = 0; } - using (PixelAccessor sourcePixels = source.Lock()) + using (PixelAccessor sourcePixels = source.Lock()) { Parallel.For( minY, @@ -79,7 +79,7 @@ namespace ImageSharp.Processing.Processors Vector3 transformed = new Vector3(vector.X, vector.Y, vector.Z) + new Vector3(brightness); vector = new Vector4(transformed, vector.W); - TColor packed = default(TColor); + TPixel packed = default(TPixel); packed.PackFromVector4(vector.Compress()); sourcePixels[offsetX, offsetY] = packed; diff --git a/src/ImageSharp/Processing/Processors/Effects/ContrastProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/ContrastProcessor.cs index 042e39699..c6abd250b 100644 --- a/src/ImageSharp/Processing/Processors/Effects/ContrastProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Effects/ContrastProcessor.cs @@ -10,14 +10,14 @@ namespace ImageSharp.Processing.Processors using System.Threading.Tasks; /// - /// An to change the contrast of an . + /// An to change the contrast of an . /// - /// The pixel format. - internal class ContrastProcessor : ImageProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class ContrastProcessor : ImageProcessor + where TPixel : struct, IPixel { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The new contrast of the image. Must be between -100 and 100. /// @@ -35,7 +35,7 @@ namespace ImageSharp.Processing.Processors public int Value { get; } /// - protected override void OnApply(ImageBase source, Rectangle sourceRectangle) + protected override void OnApply(ImageBase source, Rectangle sourceRectangle) { float contrast = (100F + this.Value) / 100F; @@ -63,7 +63,7 @@ namespace ImageSharp.Processing.Processors startY = 0; } - using (PixelAccessor sourcePixels = source.Lock()) + using (PixelAccessor sourcePixels = source.Lock()) { Parallel.For( minY, @@ -80,7 +80,7 @@ namespace ImageSharp.Processing.Processors vector -= shiftVector; vector *= contrastVector; vector += shiftVector; - TColor packed = default(TColor); + TPixel packed = default(TPixel); packed.PackFromVector4(vector.Compress()); sourcePixels[offsetX, offsetY] = packed; } diff --git a/src/ImageSharp/Processing/Processors/Effects/InvertProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/InvertProcessor.cs index 4358e8946..9eaa99c71 100644 --- a/src/ImageSharp/Processing/Processors/Effects/InvertProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Effects/InvertProcessor.cs @@ -10,14 +10,14 @@ namespace ImageSharp.Processing.Processors using System.Threading.Tasks; /// - /// An to invert the colors of an . + /// An to invert the colors of an . /// - /// The pixel format. - internal class InvertProcessor : ImageProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class InvertProcessor : ImageProcessor + where TPixel : struct, IPixel { /// - protected override void OnApply(ImageBase source, Rectangle sourceRectangle) + protected override void OnApply(ImageBase source, Rectangle sourceRectangle) { int startY = sourceRectangle.Y; int endY = sourceRectangle.Bottom; @@ -42,7 +42,7 @@ namespace ImageSharp.Processing.Processors startY = 0; } - using (PixelAccessor sourcePixels = source.Lock()) + using (PixelAccessor sourcePixels = source.Lock()) { Parallel.For( minY, @@ -57,7 +57,7 @@ namespace ImageSharp.Processing.Processors Vector4 color = sourcePixels[offsetX, offsetY].ToVector4(); Vector3 vector = inverseVector - new Vector3(color.X, color.Y, color.Z); - TColor packed = default(TColor); + TPixel packed = default(TPixel); packed.PackFromVector4(new Vector4(vector, color.W)); sourcePixels[offsetX, offsetY] = packed; } diff --git a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor.cs index 957955c6c..3ef56b745 100644 --- a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor.cs @@ -10,15 +10,15 @@ namespace ImageSharp.Processing.Processors using System.Threading.Tasks; /// - /// An to apply an oil painting effect to an . + /// An to apply an oil painting effect to an . /// /// Adapted from by Dewald Esterhuizen. - /// The pixel format. - internal class OilPaintingProcessor : ImageProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class OilPaintingProcessor : ImageProcessor + where TPixel : struct, IPixel { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// /// The number of intensity levels. Higher values result in a broader range of color intensities forming part of the result image. @@ -46,7 +46,7 @@ namespace ImageSharp.Processing.Processors public int BrushSize { get; } /// - protected override void OnApply(ImageBase source, Rectangle sourceRectangle) + protected override void OnApply(ImageBase source, Rectangle sourceRectangle) { int startY = sourceRectangle.Y; int endY = sourceRectangle.Bottom; @@ -67,9 +67,9 @@ namespace ImageSharp.Processing.Processors startX = 0; } - using (PixelAccessor targetPixels = new PixelAccessor(source.Width, source.Height)) + using (PixelAccessor targetPixels = new PixelAccessor(source.Width, source.Height)) { - using (PixelAccessor sourcePixels = source.Lock()) + using (PixelAccessor sourcePixels = source.Lock()) { Parallel.For( minY, @@ -143,7 +143,7 @@ namespace ImageSharp.Processing.Processors float green = MathF.Abs(greenBin[maxIndex] / maxIntensity); float blue = MathF.Abs(blueBin[maxIndex] / maxIntensity); - TColor packed = default(TColor); + TPixel packed = default(TPixel); packed.PackFromVector4(new Vector4(red, green, blue, sourcePixels[x, y].ToVector4().W)); targetPixels[x, y] = packed; } diff --git a/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor.cs index 818b1f513..006ae8e60 100644 --- a/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor.cs @@ -10,14 +10,14 @@ namespace ImageSharp.Processing.Processors using System.Threading.Tasks; /// - /// An to pixelate the colors of an . + /// An to pixelate the colors of an . /// - /// The pixel format. - internal class PixelateProcessor : ImageProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class PixelateProcessor : ImageProcessor + where TPixel : struct, IPixel { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The size of the pixels. Must be greater than 0. /// @@ -35,7 +35,7 @@ namespace ImageSharp.Processing.Processors public int Value { get; } /// - protected override void OnApply(ImageBase source, Rectangle sourceRectangle) + protected override void OnApply(ImageBase source, Rectangle sourceRectangle) { int startY = sourceRectangle.Y; int endY = sourceRectangle.Bottom; @@ -64,9 +64,9 @@ namespace ImageSharp.Processing.Processors // Get the range on the y-plane to choose from. IEnumerable range = EnumerableExtensions.SteppedRange(minY, i => i < maxY, size); - using (PixelAccessor targetPixels = new PixelAccessor(source.Width, source.Height)) + using (PixelAccessor targetPixels = new PixelAccessor(source.Width, source.Height)) { - using (PixelAccessor sourcePixels = source.Lock()) + using (PixelAccessor sourcePixels = source.Lock()) { Parallel.ForEach( range, @@ -94,7 +94,7 @@ namespace ImageSharp.Processing.Processors // Get the pixel color in the centre of the soon to be pixelated area. // ReSharper disable AccessToDisposedClosure - TColor pixel = sourcePixels[offsetX + offsetPx, offsetY + offsetPy]; + TPixel pixel = sourcePixels[offsetX + offsetPx, offsetY + offsetPy]; // For each pixel in the pixelate size, set it to the centre color. for (int l = offsetY; l < offsetY + size && l < maxY; l++) diff --git a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs b/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs index 6eeb7398a..223da64ac 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs @@ -10,17 +10,17 @@ namespace ImageSharp.Processing.Processors using System.Threading.Tasks; /// - /// An that applies a radial glow effect an . + /// An that applies a radial glow effect an . /// - /// The pixel format. - internal class GlowProcessor : ImageProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class GlowProcessor : ImageProcessor + where TPixel : struct, IPixel { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The color or the glow. - public GlowProcessor(TColor color) + public GlowProcessor(TPixel color) { this.GlowColor = color; } @@ -28,7 +28,7 @@ namespace ImageSharp.Processing.Processors /// /// Gets or sets the glow color to apply. /// - public TColor GlowColor { get; set; } + public TPixel GlowColor { get; set; } /// /// Gets or sets the the radius. @@ -36,13 +36,13 @@ namespace ImageSharp.Processing.Processors public float Radius { get; set; } /// - protected override void OnApply(ImageBase source, Rectangle sourceRectangle) + protected override void OnApply(ImageBase source, Rectangle sourceRectangle) { int startY = sourceRectangle.Y; int endY = sourceRectangle.Bottom; int startX = sourceRectangle.X; int endX = sourceRectangle.Right; - TColor glowColor = this.GlowColor; + TPixel glowColor = this.GlowColor; Vector2 centre = Rectangle.Center(sourceRectangle).ToVector2(); float maxDistance = this.Radius > 0 ? MathF.Min(this.Radius, sourceRectangle.Width * .5F) : sourceRectangle.Width * .5F; @@ -63,7 +63,7 @@ namespace ImageSharp.Processing.Processors startY = 0; } - using (PixelAccessor sourcePixels = source.Lock()) + using (PixelAccessor sourcePixels = source.Lock()) { Parallel.For( minY, @@ -77,7 +77,7 @@ namespace ImageSharp.Processing.Processors int offsetX = x - startX; float distance = Vector2.Distance(centre, new Vector2(offsetX, offsetY)); Vector4 sourceColor = sourcePixels[offsetX, offsetY].ToVector4(); - TColor packed = default(TColor); + TPixel packed = default(TPixel); packed.PackFromVector4(Vector4BlendTransforms.PremultipliedLerp(sourceColor, glowColor.ToVector4(), 1 - (.95F * (distance / maxDistance)))); sourcePixels[offsetX, offsetY] = packed; } diff --git a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs b/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs index 40d6d94ac..9be0cfde2 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs @@ -10,17 +10,17 @@ namespace ImageSharp.Processing.Processors using System.Threading.Tasks; /// - /// An that applies a radial vignette effect to an . + /// An that applies a radial vignette effect to an . /// - /// The pixel format. - internal class VignetteProcessor : ImageProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class VignetteProcessor : ImageProcessor + where TPixel : struct, IPixel { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The color of the vignette. - public VignetteProcessor(TColor color) + public VignetteProcessor(TPixel color) { this.VignetteColor = color; } @@ -28,7 +28,7 @@ namespace ImageSharp.Processing.Processors /// /// Gets or sets the vignette color to apply. /// - public TColor VignetteColor { get; set; } + public TPixel VignetteColor { get; set; } /// /// Gets or sets the the x-radius. @@ -41,13 +41,13 @@ namespace ImageSharp.Processing.Processors public float RadiusY { get; set; } /// - protected override void OnApply(ImageBase source, Rectangle sourceRectangle) + protected override void OnApply(ImageBase source, Rectangle sourceRectangle) { int startY = sourceRectangle.Y; int endY = sourceRectangle.Bottom; int startX = sourceRectangle.X; int endX = sourceRectangle.Right; - TColor vignetteColor = this.VignetteColor; + TPixel vignetteColor = this.VignetteColor; Vector2 centre = Rectangle.Center(sourceRectangle).ToVector2(); float rX = this.RadiusX > 0 ? MathF.Min(this.RadiusX, sourceRectangle.Width * .5F) : sourceRectangle.Width * .5F; float rY = this.RadiusY > 0 ? MathF.Min(this.RadiusY, sourceRectangle.Height * .5F) : sourceRectangle.Height * .5F; @@ -70,7 +70,7 @@ namespace ImageSharp.Processing.Processors startY = 0; } - using (PixelAccessor sourcePixels = source.Lock()) + using (PixelAccessor sourcePixels = source.Lock()) { Parallel.For( minY, @@ -84,7 +84,7 @@ namespace ImageSharp.Processing.Processors int offsetX = x - startX; float distance = Vector2.Distance(centre, new Vector2(offsetX, offsetY)); Vector4 sourceColor = sourcePixels[offsetX, offsetY].ToVector4(); - TColor packed = default(TColor); + TPixel packed = default(TPixel); packed.PackFromVector4(Vector4BlendTransforms.PremultipliedLerp(sourceColor, vignetteColor.ToVector4(), .9F * (distance / maxDistance))); sourcePixels[offsetX, offsetY] = packed; } diff --git a/src/ImageSharp/Processing/Processors/Transforms/CropProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/CropProcessor.cs index 7d473c55e..1b96e098e 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/CropProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/CropProcessor.cs @@ -11,12 +11,12 @@ namespace ImageSharp.Processing.Processors /// /// Provides methods to allow the cropping of an image. /// - /// The pixel format. - internal class CropProcessor : ImageProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class CropProcessor : ImageProcessor + where TPixel : struct, IPixel { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The target cropped rectangle. public CropProcessor(Rectangle cropRectangle) @@ -30,7 +30,7 @@ namespace ImageSharp.Processing.Processors public Rectangle CropRectangle { get; } /// - protected override void OnApply(ImageBase source, Rectangle sourceRectangle) + protected override void OnApply(ImageBase source, Rectangle sourceRectangle) { if (this.CropRectangle == sourceRectangle) { @@ -42,9 +42,9 @@ namespace ImageSharp.Processing.Processors int minX = Math.Max(this.CropRectangle.X, sourceRectangle.X); int maxX = Math.Min(this.CropRectangle.Right, sourceRectangle.Right); - using (PixelAccessor targetPixels = new PixelAccessor(this.CropRectangle.Width, this.CropRectangle.Height)) + using (PixelAccessor targetPixels = new PixelAccessor(this.CropRectangle.Width, this.CropRectangle.Height)) { - using (PixelAccessor sourcePixels = source.Lock()) + using (PixelAccessor sourcePixels = source.Lock()) { Parallel.For( minY, diff --git a/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor.cs index 049fbf2de..67259477c 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor.cs @@ -11,12 +11,12 @@ namespace ImageSharp.Processing.Processors /// Provides methods to allow the cropping of an image to preserve areas of highest /// entropy. /// - /// The pixel format. - internal class EntropyCropProcessor : ImageProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class EntropyCropProcessor : ImageProcessor + where TPixel : struct, IPixel { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The threshold to split the image. Must be between 0 and 1. /// @@ -34,15 +34,15 @@ namespace ImageSharp.Processing.Processors public float Value { get; } /// - protected override void OnApply(ImageBase source, Rectangle sourceRectangle) + protected override void OnApply(ImageBase source, Rectangle sourceRectangle) { - using (ImageBase temp = new Image(source)) + using (ImageBase temp = new Image(source)) { // Detect the edges. - new SobelProcessor().Apply(temp, sourceRectangle); + new SobelProcessor().Apply(temp, sourceRectangle); // Apply threshold binarization filter. - new BinaryThresholdProcessor(this.Value).Apply(temp, sourceRectangle); + new BinaryThresholdProcessor(this.Value).Apply(temp, sourceRectangle); // Search for the first white pixels Rectangle rectangle = ImageMaths.GetFilteredBoundingRectangle(temp, 0); @@ -52,7 +52,7 @@ namespace ImageSharp.Processing.Processors return; } - new CropProcessor(rectangle).Apply(source, sourceRectangle); + new CropProcessor(rectangle).Apply(source, sourceRectangle); } } } diff --git a/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor.cs index 290d81799..86dc8bb15 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor.cs @@ -11,12 +11,12 @@ namespace ImageSharp.Processing.Processors /// /// Provides methods that allow the flipping of an image around its center point. /// - /// The pixel format. - internal class FlipProcessor : ImageProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class FlipProcessor : ImageProcessor + where TPixel : struct, IPixel { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The used to perform flipping. public FlipProcessor(FlipType flipType) @@ -30,7 +30,7 @@ namespace ImageSharp.Processing.Processors public FlipType FlipType { get; } /// - protected override void OnApply(ImageBase source, Rectangle sourceRectangle) + protected override void OnApply(ImageBase source, Rectangle sourceRectangle) { switch (this.FlipType) { @@ -49,15 +49,15 @@ namespace ImageSharp.Processing.Processors /// at half the height of the image. /// /// The source image to apply the process to. - private void FlipX(ImageBase source) + private void FlipX(ImageBase source) { int width = source.Width; int height = source.Height; int halfHeight = (int)Math.Ceiling(source.Height * .5F); - using (PixelAccessor targetPixels = new PixelAccessor(width, height)) + using (PixelAccessor targetPixels = new PixelAccessor(width, height)) { - using (PixelAccessor sourcePixels = source.Lock()) + using (PixelAccessor sourcePixels = source.Lock()) { Parallel.For( 0, @@ -83,15 +83,15 @@ namespace ImageSharp.Processing.Processors /// at half of the width of the image. /// /// The source image to apply the process to. - private void FlipY(ImageBase source) + private void FlipY(ImageBase source) { int width = source.Width; int height = source.Height; int halfWidth = (int)Math.Ceiling(width * .5F); - using (PixelAccessor targetPixels = new PixelAccessor(width, height)) + using (PixelAccessor targetPixels = new PixelAccessor(width, height)) { - using (PixelAccessor sourcePixels = source.Lock()) + using (PixelAccessor sourcePixels = source.Lock()) { Parallel.For( 0, diff --git a/src/ImageSharp/Processing/Processors/Transforms/Matrix3x2Processor.cs b/src/ImageSharp/Processing/Processors/Transforms/Matrix3x2Processor.cs index 0c290a9b6..a8cd71003 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Matrix3x2Processor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Matrix3x2Processor.cs @@ -11,9 +11,9 @@ namespace ImageSharp.Processing.Processors /// /// Provides methods to transform an image using a . /// - /// The pixel format. - internal abstract class Matrix3x2Processor : ImageProcessor - where TColor : struct, IPixel + /// The pixel format. + internal abstract class Matrix3x2Processor : ImageProcessor + where TPixel : struct, IPixel { /// /// Gets the rectangle designating the target canvas. @@ -41,7 +41,7 @@ namespace ImageSharp.Processing.Processors /// /// The . /// - protected Matrix3x2 GetCenteredMatrix(ImageBase source, Matrix3x2 matrix) + protected Matrix3x2 GetCenteredMatrix(ImageBase source, Matrix3x2 matrix) { Matrix3x2 translationToTargetCenter = Matrix3x2.CreateTranslation(-this.CanvasRectangle.Width * .5F, -this.CanvasRectangle.Height * .5F); Matrix3x2 translateToSourceCenter = Matrix3x2.CreateTranslation(source.Width * .5F, source.Height * .5F); diff --git a/src/ImageSharp/Processing/Processors/Transforms/ResamplingWeightedProcessor.Weights.cs b/src/ImageSharp/Processing/Processors/Transforms/ResamplingWeightedProcessor.Weights.cs index 4c43d654d..5d29924e1 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/ResamplingWeightedProcessor.Weights.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/ResamplingWeightedProcessor.Weights.cs @@ -7,7 +7,7 @@ namespace ImageSharp.Processing.Processors /// /// Conains the definition of and . /// - internal abstract partial class ResamplingWeightedProcessor + internal abstract partial class ResamplingWeightedProcessor { /// /// Points to a collection of of weights allocated in . diff --git a/src/ImageSharp/Processing/Processors/Transforms/ResamplingWeightedProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/ResamplingWeightedProcessor.cs index 50c75a3fd..bd7ca3f60 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/ResamplingWeightedProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/ResamplingWeightedProcessor.cs @@ -14,12 +14,12 @@ namespace ImageSharp.Processing.Processors /// Provides methods that allow the resizing of images using various algorithms. /// Adapted from /// - /// The pixel format. - internal abstract partial class ResamplingWeightedProcessor : ImageProcessor - where TColor : struct, IPixel + /// The pixel format. + internal abstract partial class ResamplingWeightedProcessor : ImageProcessor + where TPixel : struct, IPixel { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The sampler to perform the resize operation. /// The target width. @@ -139,7 +139,7 @@ namespace ImageSharp.Processing.Processors } /// - protected override void BeforeApply(ImageBase source, Rectangle sourceRectangle) + protected override void BeforeApply(ImageBase source, Rectangle sourceRectangle) { if (!(this.Sampler is NearestNeighborResampler)) { @@ -154,7 +154,7 @@ namespace ImageSharp.Processing.Processors } /// - protected override void AfterApply(ImageBase source, Rectangle sourceRectangle) + protected override void AfterApply(ImageBase source, Rectangle sourceRectangle) { base.AfterApply(source, sourceRectangle); this.HorizontalWeights?.Dispose(); diff --git a/src/ImageSharp/Processing/Processors/Transforms/ResizeProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/ResizeProcessor.cs index 08d96e283..9601cc7bb 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/ResizeProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/ResizeProcessor.cs @@ -12,12 +12,12 @@ namespace ImageSharp.Processing.Processors /// /// Provides methods that allow the resizing of images using various algorithms. /// - /// The pixel format. - internal class ResizeProcessor : ResamplingWeightedProcessor - where TColor : struct, IPixel + /// The pixel format. + internal class ResizeProcessor : ResamplingWeightedProcessor + where TPixel : struct, IPixel { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The sampler to perform the resize operation. /// The target width. @@ -28,7 +28,7 @@ namespace ImageSharp.Processing.Processors } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The sampler to perform the resize operation. /// The target width. @@ -42,7 +42,7 @@ namespace ImageSharp.Processing.Processors } /// - protected override unsafe void OnApply(ImageBase source, Rectangle sourceRectangle) + protected override unsafe void OnApply(ImageBase source, Rectangle sourceRectangle) { // Jump out, we'll deal with that later. if (source.Width == this.Width && source.Height == this.Height && sourceRectangle == this.ResizeRectangle) @@ -70,9 +70,9 @@ namespace ImageSharp.Processing.Processors float widthFactor = sourceRectangle.Width / (float)this.ResizeRectangle.Width; float heightFactor = sourceRectangle.Height / (float)this.ResizeRectangle.Height; - using (PixelAccessor targetPixels = new PixelAccessor(width, height)) + using (PixelAccessor targetPixels = new PixelAccessor(width, height)) { - using (PixelAccessor sourcePixels = source.Lock()) + using (PixelAccessor sourcePixels = source.Lock()) { Parallel.For( minY, @@ -103,9 +103,9 @@ namespace ImageSharp.Processing.Processors // are the upper and lower bounds of the source rectangle. // TODO: Using a transposed variant of 'firstPassPixels' could eliminate the need for the WeightsWindow.ComputeWeightedColumnSum() method, and improve speed! - using (PixelAccessor targetPixels = new PixelAccessor(width, height)) + using (PixelAccessor targetPixels = new PixelAccessor(width, height)) { - using (PixelAccessor sourcePixels = source.Lock()) + using (PixelAccessor sourcePixels = source.Lock()) using (Buffer2D firstPassPixels = new Buffer2D(width, source.Height)) { firstPassPixels.Clear(); @@ -119,9 +119,9 @@ namespace ImageSharp.Processing.Processors // TODO: Without Parallel.For() this buffer object could be reused: using (Buffer tempRowBuffer = new Buffer(sourcePixels.Width)) { - BufferSpan sourceRow = sourcePixels.GetRowSpan(y); + BufferSpan sourceRow = sourcePixels.GetRowSpan(y); - BulkPixelOperations.Instance.ToVector4( + BulkPixelOperations.Instance.ToVector4( sourceRow, tempRowBuffer, sourceRow.Length); @@ -162,7 +162,7 @@ namespace ImageSharp.Processing.Processors // Destination color components Vector4 destination = window.ComputeWeightedColumnSum(firstPassPixels, x); destination = destination.Compress(); - TColor d = default(TColor); + TPixel d = default(TPixel); d.PackFromVector4(destination); targetPixels[x, y] = d; } @@ -174,7 +174,7 @@ namespace ImageSharp.Processing.Processors // Destination color components Vector4 destination = window.ComputeWeightedColumnSum(firstPassPixels, x); - TColor d = default(TColor); + TPixel d = default(TPixel); d.PackFromVector4(destination); targetPixels[x, y] = d; } diff --git a/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs index 16e0b6635..7d0afce26 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs @@ -12,9 +12,9 @@ namespace ImageSharp.Processing.Processors /// /// Provides methods that allow the rotating of images. /// - /// The pixel format. - internal class RotateProcessor : Matrix3x2Processor - where TColor : struct, IPixel + /// The pixel format. + internal class RotateProcessor : Matrix3x2Processor + where TPixel : struct, IPixel { /// /// The transform matrix to apply. @@ -32,7 +32,7 @@ namespace ImageSharp.Processing.Processors public bool Expand { get; set; } = true; /// - protected override void OnApply(ImageBase source, Rectangle sourceRectangle) + protected override void OnApply(ImageBase source, Rectangle sourceRectangle) { if (this.OptimizedApply(source)) { @@ -43,9 +43,9 @@ namespace ImageSharp.Processing.Processors int width = this.CanvasRectangle.Width; Matrix3x2 matrix = this.GetCenteredMatrix(source, this.processMatrix); - using (PixelAccessor targetPixels = new PixelAccessor(width, height)) + using (PixelAccessor targetPixels = new PixelAccessor(width, height)) { - using (PixelAccessor sourcePixels = source.Lock()) + using (PixelAccessor sourcePixels = source.Lock()) { Parallel.For( 0, @@ -69,7 +69,7 @@ namespace ImageSharp.Processing.Processors } /// - protected override void BeforeApply(ImageBase source, Rectangle sourceRectangle) + protected override void BeforeApply(ImageBase source, Rectangle sourceRectangle) { if (MathF.Abs(this.Angle) < Constants.Epsilon || MathF.Abs(this.Angle - 90) < Constants.Epsilon || MathF.Abs(this.Angle - 180) < Constants.Epsilon || MathF.Abs(this.Angle - 270) < Constants.Epsilon) { @@ -88,7 +88,7 @@ namespace ImageSharp.Processing.Processors /// /// The source image. /// The - private bool OptimizedApply(ImageBase source) + private bool OptimizedApply(ImageBase source) { if (MathF.Abs(this.Angle) < Constants.Epsilon) { @@ -121,14 +121,14 @@ namespace ImageSharp.Processing.Processors /// Rotates the image 270 degrees clockwise at the centre point. /// /// The source image. - private void Rotate270(ImageBase source) + private void Rotate270(ImageBase source) { int width = source.Width; int height = source.Height; - using (PixelAccessor targetPixels = new PixelAccessor(height, width)) + using (PixelAccessor targetPixels = new PixelAccessor(height, width)) { - using (PixelAccessor sourcePixels = source.Lock()) + using (PixelAccessor sourcePixels = source.Lock()) { Parallel.For( 0, @@ -154,14 +154,14 @@ namespace ImageSharp.Processing.Processors /// Rotates the image 180 degrees clockwise at the centre point. /// /// The source image. - private void Rotate180(ImageBase source) + private void Rotate180(ImageBase source) { int width = source.Width; int height = source.Height; - using (PixelAccessor targetPixels = new PixelAccessor(width, height)) + using (PixelAccessor targetPixels = new PixelAccessor(width, height)) { - using (PixelAccessor sourcePixels = source.Lock()) + using (PixelAccessor sourcePixels = source.Lock()) { Parallel.For( 0, @@ -186,14 +186,14 @@ namespace ImageSharp.Processing.Processors /// Rotates the image 90 degrees clockwise at the centre point. /// /// The source image. - private void Rotate90(ImageBase source) + private void Rotate90(ImageBase source) { int width = source.Width; int height = source.Height; - using (PixelAccessor targetPixels = new PixelAccessor(height, width)) + using (PixelAccessor targetPixels = new PixelAccessor(height, width)) { - using (PixelAccessor sourcePixels = source.Lock()) + using (PixelAccessor sourcePixels = source.Lock()) { Parallel.For( 0, diff --git a/src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs index 5fe3f7d95..e5b6f12bf 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs @@ -12,9 +12,9 @@ namespace ImageSharp.Processing.Processors /// /// Provides methods that allow the skewing of images. /// - /// The pixel format. - internal class SkewProcessor : Matrix3x2Processor - where TColor : struct, IPixel + /// The pixel format. + internal class SkewProcessor : Matrix3x2Processor + where TPixel : struct, IPixel { /// /// The transform matrix to apply. @@ -37,15 +37,15 @@ namespace ImageSharp.Processing.Processors public bool Expand { get; set; } = true; /// - protected override void OnApply(ImageBase source, Rectangle sourceRectangle) + protected override void OnApply(ImageBase source, Rectangle sourceRectangle) { int height = this.CanvasRectangle.Height; int width = this.CanvasRectangle.Width; Matrix3x2 matrix = this.GetCenteredMatrix(source, this.processMatrix); - using (PixelAccessor targetPixels = new PixelAccessor(width, height)) + using (PixelAccessor targetPixels = new PixelAccessor(width, height)) { - using (PixelAccessor sourcePixels = source.Lock()) + using (PixelAccessor sourcePixels = source.Lock()) { Parallel.For( 0, @@ -69,7 +69,7 @@ namespace ImageSharp.Processing.Processors } /// - protected override void BeforeApply(ImageBase source, Rectangle sourceRectangle) + protected override void BeforeApply(ImageBase source, Rectangle sourceRectangle) { this.processMatrix = Point.CreateSkew(new Point(0, 0), -this.AngleX, -this.AngleY); if (this.Expand) diff --git a/src/ImageSharp/Processing/Transforms/AutoOrient.cs b/src/ImageSharp/Processing/Transforms/AutoOrient.cs index 8c5e22b99..5634c3299 100644 --- a/src/ImageSharp/Processing/Transforms/AutoOrient.cs +++ b/src/ImageSharp/Processing/Transforms/AutoOrient.cs @@ -10,18 +10,18 @@ namespace ImageSharp using Processing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Adjusts an image so that its orientation is suitable for viewing. Adjustments are based on EXIF metadata embedded in the image. /// - /// The pixel format. + /// The pixel format. /// The image to auto rotate. /// The - public static Image AutoOrient(this Image source) - where TColor : struct, IPixel + public static Image AutoOrient(this Image source) + where TPixel : struct, IPixel { Orientation orientation = GetExifOrientation(source); @@ -60,11 +60,11 @@ namespace ImageSharp /// /// Returns the current EXIF orientation /// - /// The pixel format. + /// The pixel format. /// The image to auto rotate. /// The - private static Orientation GetExifOrientation(Image source) - where TColor : struct, IPixel + private static Orientation GetExifOrientation(Image source) + where TPixel : struct, IPixel { if (source.MetaData.ExifProfile == null) { diff --git a/src/ImageSharp/Processing/Transforms/Crop.cs b/src/ImageSharp/Processing/Transforms/Crop.cs index 92773aaea..59c1209f9 100644 --- a/src/ImageSharp/Processing/Transforms/Crop.cs +++ b/src/ImageSharp/Processing/Transforms/Crop.cs @@ -10,20 +10,20 @@ namespace ImageSharp using Processing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Crops an image to the given width and height. /// - /// The pixel format. + /// The pixel format. /// The image to resize. /// The target image width. /// The target image height. - /// The - public static Image Crop(this Image source, int width, int height) - where TColor : struct, IPixel + /// The + public static Image Crop(this Image source, int width, int height) + where TPixel : struct, IPixel { return Crop(source, new Rectangle(0, 0, width, height)); } @@ -31,16 +31,16 @@ namespace ImageSharp /// /// Crops an image to the given rectangle. /// - /// The pixel format. + /// The pixel format. /// The image to crop. /// /// The structure that specifies the portion of the image object to retain. /// /// The - public static Image Crop(this Image source, Rectangle cropRectangle) - where TColor : struct, IPixel + public static Image Crop(this Image source, Rectangle cropRectangle) + where TPixel : struct, IPixel { - CropProcessor processor = new CropProcessor(cropRectangle); + CropProcessor processor = new CropProcessor(cropRectangle); source.ApplyProcessor(processor, source.Bounds); return source; diff --git a/src/ImageSharp/Processing/Transforms/EntropyCrop.cs b/src/ImageSharp/Processing/Transforms/EntropyCrop.cs index ad2ce89e3..59d0211a1 100644 --- a/src/ImageSharp/Processing/Transforms/EntropyCrop.cs +++ b/src/ImageSharp/Processing/Transforms/EntropyCrop.cs @@ -10,21 +10,21 @@ namespace ImageSharp using Processing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Crops an image to the area of greatest entropy. /// - /// The pixel format. + /// The pixel format. /// The image to crop. /// The threshold for entropic density. /// The - public static Image EntropyCrop(this Image source, float threshold = .5f) - where TColor : struct, IPixel + public static Image EntropyCrop(this Image source, float threshold = .5f) + where TPixel : struct, IPixel { - EntropyCropProcessor processor = new EntropyCropProcessor(threshold); + EntropyCropProcessor processor = new EntropyCropProcessor(threshold); source.ApplyProcessor(processor, source.Bounds); return source; diff --git a/src/ImageSharp/Processing/Transforms/Flip.cs b/src/ImageSharp/Processing/Transforms/Flip.cs index ed096eb75..1cc79f888 100644 --- a/src/ImageSharp/Processing/Transforms/Flip.cs +++ b/src/ImageSharp/Processing/Transforms/Flip.cs @@ -11,21 +11,21 @@ namespace ImageSharp using Processing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Flips an image by the given instructions. /// - /// The pixel format. + /// The pixel format. /// The image to rotate, flip, or both. /// The to perform the flip. /// The - public static Image Flip(this Image source, FlipType flipType) - where TColor : struct, IPixel + public static Image Flip(this Image source, FlipType flipType) + where TPixel : struct, IPixel { - FlipProcessor processor = new FlipProcessor(flipType); + FlipProcessor processor = new FlipProcessor(flipType); source.ApplyProcessor(processor, source.Bounds); return source; diff --git a/src/ImageSharp/Processing/Transforms/Options/ResizeHelper.cs b/src/ImageSharp/Processing/Transforms/Options/ResizeHelper.cs index 4be938c39..1e7d7e24f 100644 --- a/src/ImageSharp/Processing/Transforms/Options/ResizeHelper.cs +++ b/src/ImageSharp/Processing/Transforms/Options/ResizeHelper.cs @@ -17,14 +17,14 @@ namespace ImageSharp.Processing /// /// Calculates the target location and bounds to perform the resize operation against. /// - /// The pixel format. + /// The pixel format. /// The source image. /// The resize options. /// /// The . /// - public static Rectangle CalculateTargetLocationAndBounds(ImageBase source, ResizeOptions options) - where TColor : struct, IPixel + public static Rectangle CalculateTargetLocationAndBounds(ImageBase source, ResizeOptions options) + where TPixel : struct, IPixel { switch (options.Mode) { @@ -48,14 +48,14 @@ namespace ImageSharp.Processing /// /// Calculates the target rectangle for crop mode. /// - /// The pixel format. + /// The pixel format. /// The source image. /// The resize options. /// /// The . /// - private static Rectangle CalculateCropRectangle(ImageBase source, ResizeOptions options) - where TColor : struct, IPixel + private static Rectangle CalculateCropRectangle(ImageBase source, ResizeOptions options) + where TPixel : struct, IPixel { int width = options.Size.Width; int height = options.Size.Height; @@ -167,14 +167,14 @@ namespace ImageSharp.Processing /// /// Calculates the target rectangle for pad mode. /// - /// The pixel format. + /// The pixel format. /// The source image. /// The resize options. /// /// The . /// - private static Rectangle CalculatePadRectangle(ImageBase source, ResizeOptions options) - where TColor : struct, IPixel + private static Rectangle CalculatePadRectangle(ImageBase source, ResizeOptions options) + where TPixel : struct, IPixel { int width = options.Size.Width; int height = options.Size.Height; @@ -248,14 +248,14 @@ namespace ImageSharp.Processing /// /// Calculates the target rectangle for box pad mode. /// - /// The pixel format. + /// The pixel format. /// The source image. /// The resize options. /// /// The . /// - private static Rectangle CalculateBoxPadRectangle(ImageBase source, ResizeOptions options) - where TColor : struct, IPixel + private static Rectangle CalculateBoxPadRectangle(ImageBase source, ResizeOptions options) + where TPixel : struct, IPixel { int width = options.Size.Width; int height = options.Size.Height; @@ -335,14 +335,14 @@ namespace ImageSharp.Processing /// /// Calculates the target rectangle for max mode. /// - /// The pixel format. + /// The pixel format. /// The source image. /// The resize options. /// /// The . /// - private static Rectangle CalculateMaxRectangle(ImageBase source, ResizeOptions options) - where TColor : struct, IPixel + private static Rectangle CalculateMaxRectangle(ImageBase source, ResizeOptions options) + where TPixel : struct, IPixel { int width = options.Size.Width; int height = options.Size.Height; @@ -376,14 +376,14 @@ namespace ImageSharp.Processing /// /// Calculates the target rectangle for min mode. /// - /// The pixel format. + /// The pixel format. /// The source image. /// The resize options. /// /// The . /// - private static Rectangle CalculateMinRectangle(ImageBase source, ResizeOptions options) - where TColor : struct, IPixel + private static Rectangle CalculateMinRectangle(ImageBase source, ResizeOptions options) + where TPixel : struct, IPixel { int width = options.Size.Width; int height = options.Size.Height; diff --git a/src/ImageSharp/Processing/Transforms/Pad.cs b/src/ImageSharp/Processing/Transforms/Pad.cs index bd530ecd8..3aebe2304 100644 --- a/src/ImageSharp/Processing/Transforms/Pad.cs +++ b/src/ImageSharp/Processing/Transforms/Pad.cs @@ -11,20 +11,20 @@ namespace ImageSharp using Processing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Evenly pads an image to fit the new dimensions. /// - /// The pixel format. + /// The pixel format. /// The source image to pad. /// The new width. /// The new height. - /// The . - public static Image Pad(this Image source, int width, int height) - where TColor : struct, IPixel + /// The . + public static Image Pad(this Image source, int width, int height) + where TPixel : struct, IPixel { ResizeOptions options = new ResizeOptions { diff --git a/src/ImageSharp/Processing/Transforms/Resize.cs b/src/ImageSharp/Processing/Transforms/Resize.cs index 1952aa1a7..82c4b16c3 100644 --- a/src/ImageSharp/Processing/Transforms/Resize.cs +++ b/src/ImageSharp/Processing/Transforms/Resize.cs @@ -11,20 +11,20 @@ namespace ImageSharp using Processing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Resizes an image in accordance with the given . /// - /// The pixel format. + /// The pixel format. /// The image to resize. /// The resize options. - /// The + /// The /// Passing zero for one of height or width within the resize options will automatically preserve the aspect ratio of the original image - public static Image Resize(this Image source, ResizeOptions options) - where TColor : struct, IPixel + public static Image Resize(this Image source, ResizeOptions options) + where TPixel : struct, IPixel { // Ensure size is populated across both dimensions. if (options.Size.Width == 0 && options.Size.Height > 0) @@ -45,13 +45,13 @@ namespace ImageSharp /// /// Resizes an image to the given . /// - /// The pixel format. + /// The pixel format. /// The image to resize. /// The target image size. - /// The + /// The /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image - public static Image Resize(this Image source, Size size) - where TColor : struct, IPixel + public static Image Resize(this Image source, Size size) + where TPixel : struct, IPixel { return Resize(source, size.Width, size.Height, new BicubicResampler(), false); } @@ -59,14 +59,14 @@ namespace ImageSharp /// /// Resizes an image to the given width and height. /// - /// The pixel format. + /// The pixel format. /// The image to resize. /// The target image width. /// The target image height. - /// The + /// The /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image - public static Image Resize(this Image source, int width, int height) - where TColor : struct, IPixel + public static Image Resize(this Image source, int width, int height) + where TPixel : struct, IPixel { return Resize(source, width, height, new BicubicResampler(), false); } @@ -74,15 +74,15 @@ namespace ImageSharp /// /// Resizes an image to the given width and height. /// - /// The pixel format. + /// The pixel format. /// The image to resize. /// The target image width. /// The target image height. /// Whether to compress and expand the image color-space to gamma correct the image during processing. - /// The + /// The /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image - public static Image Resize(this Image source, int width, int height, bool compand) - where TColor : struct, IPixel + public static Image Resize(this Image source, int width, int height, bool compand) + where TPixel : struct, IPixel { return Resize(source, width, height, new BicubicResampler(), compand); } @@ -90,15 +90,15 @@ namespace ImageSharp /// /// Resizes an image to the given width and height with the given sampler. /// - /// The pixel format. + /// The pixel format. /// The image to resize. /// The target image width. /// The target image height. /// The to perform the resampling. - /// The + /// The /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image - public static Image Resize(this Image source, int width, int height, IResampler sampler) - where TColor : struct, IPixel + public static Image Resize(this Image source, int width, int height, IResampler sampler) + where TPixel : struct, IPixel { return Resize(source, width, height, sampler, false); } @@ -106,16 +106,16 @@ namespace ImageSharp /// /// Resizes an image to the given width and height with the given sampler. /// - /// The pixel format. + /// The pixel format. /// The image to resize. /// The target image width. /// The target image height. /// The to perform the resampling. /// Whether to compress and expand the image color-space to gamma correct the image during processing. - /// The + /// The /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image - public static Image Resize(this Image source, int width, int height, IResampler sampler, bool compand) - where TColor : struct, IPixel + public static Image Resize(this Image source, int width, int height, IResampler sampler, bool compand) + where TPixel : struct, IPixel { return Resize(source, width, height, sampler, source.Bounds, new Rectangle(0, 0, width, height), compand); } @@ -124,7 +124,7 @@ namespace ImageSharp /// Resizes an image to the given width and height with the given sampler and /// source rectangle. /// - /// The pixel format. + /// The pixel format. /// The image to resize. /// The target image width. /// The target image height. @@ -136,10 +136,10 @@ namespace ImageSharp /// The structure that specifies the portion of the target image object to draw to. /// /// Whether to compress and expand the image color-space to gamma correct the image during processing. - /// The + /// The /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image - public static Image Resize(this Image source, int width, int height, IResampler sampler, Rectangle sourceRectangle, Rectangle targetRectangle, bool compand = false) - where TColor : struct, IPixel + public static Image Resize(this Image source, int width, int height, IResampler sampler, Rectangle sourceRectangle, Rectangle targetRectangle, bool compand = false) + where TPixel : struct, IPixel { if (width == 0 && height > 0) { @@ -156,8 +156,8 @@ namespace ImageSharp Guard.MustBeGreaterThan(width, 0, nameof(width)); Guard.MustBeGreaterThan(height, 0, nameof(height)); - ResizeProcessor processor = - new ResizeProcessor(sampler, width, height, targetRectangle) { Compand = compand }; + ResizeProcessor processor = + new ResizeProcessor(sampler, width, height, targetRectangle) { Compand = compand }; source.ApplyProcessor(processor, sourceRectangle); return source; diff --git a/src/ImageSharp/Processing/Transforms/Rotate.cs b/src/ImageSharp/Processing/Transforms/Rotate.cs index 76311ef25..09fcb3534 100644 --- a/src/ImageSharp/Processing/Transforms/Rotate.cs +++ b/src/ImageSharp/Processing/Transforms/Rotate.cs @@ -11,19 +11,19 @@ namespace ImageSharp using Processing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Rotates an image by the given angle in degrees, expanding the image to fit the rotated result. /// - /// The pixel format. + /// The pixel format. /// The image to rotate. /// The angle in degrees to perform the rotation. /// The - public static Image Rotate(this Image source, float degrees) - where TColor : struct, IPixel + public static Image Rotate(this Image source, float degrees) + where TPixel : struct, IPixel { return Rotate(source, degrees, true); } @@ -31,12 +31,12 @@ namespace ImageSharp /// /// Rotates and flips an image by the given instructions. /// - /// The pixel format. + /// The pixel format. /// The image to rotate. /// The to perform the rotation. /// The - public static Image Rotate(this Image source, RotateType rotateType) - where TColor : struct, IPixel + public static Image Rotate(this Image source, RotateType rotateType) + where TPixel : struct, IPixel { return Rotate(source, (float)rotateType, false); } @@ -44,15 +44,15 @@ namespace ImageSharp /// /// Rotates an image by the given angle in degrees. /// - /// The pixel format. + /// The pixel format. /// The image to rotate. /// The angle in degrees to perform the rotation. /// Whether to expand the image to fit the rotated result. /// The - public static Image Rotate(this Image source, float degrees, bool expand) - where TColor : struct, IPixel + public static Image Rotate(this Image source, float degrees, bool expand) + where TPixel : struct, IPixel { - RotateProcessor processor = new RotateProcessor { Angle = degrees, Expand = expand }; + RotateProcessor processor = new RotateProcessor { Angle = degrees, Expand = expand }; source.ApplyProcessor(processor, source.Bounds); return source; diff --git a/src/ImageSharp/Processing/Transforms/RotateFlip.cs b/src/ImageSharp/Processing/Transforms/RotateFlip.cs index d6050db3f..2f59438e9 100644 --- a/src/ImageSharp/Processing/Transforms/RotateFlip.cs +++ b/src/ImageSharp/Processing/Transforms/RotateFlip.cs @@ -9,20 +9,20 @@ namespace ImageSharp using Processing; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Rotates and flips an image by the given instructions. /// - /// The pixel format. + /// The pixel format. /// The image to rotate, flip, or both. /// The to perform the rotation. /// The to perform the flip. /// The - public static Image RotateFlip(this Image source, RotateType rotateType, FlipType flipType) - where TColor : struct, IPixel + public static Image RotateFlip(this Image source, RotateType rotateType, FlipType flipType) + where TPixel : struct, IPixel { return source.Rotate(rotateType).Flip(flipType); } diff --git a/src/ImageSharp/Processing/Transforms/Skew.cs b/src/ImageSharp/Processing/Transforms/Skew.cs index 03fdbcceb..b74660efc 100644 --- a/src/ImageSharp/Processing/Transforms/Skew.cs +++ b/src/ImageSharp/Processing/Transforms/Skew.cs @@ -10,20 +10,20 @@ namespace ImageSharp using Processing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Skews an image by the given angles in degrees, expanding the image to fit the skewed result. /// - /// The pixel format. + /// The pixel format. /// The image to skew. /// The angle in degrees to perform the rotation along the x-axis. /// The angle in degrees to perform the rotation along the y-axis. /// The - public static Image Skew(this Image source, float degreesX, float degreesY) - where TColor : struct, IPixel + public static Image Skew(this Image source, float degreesX, float degreesY) + where TPixel : struct, IPixel { return Skew(source, degreesX, degreesY, true); } @@ -31,16 +31,16 @@ namespace ImageSharp /// /// Skews an image by the given angles in degrees. /// - /// The pixel format. + /// The pixel format. /// The image to skew. /// The angle in degrees to perform the rotation along the x-axis. /// The angle in degrees to perform the rotation along the y-axis. /// Whether to expand the image to fit the skewed result. /// The - public static Image Skew(this Image source, float degreesX, float degreesY, bool expand) - where TColor : struct, IPixel + public static Image Skew(this Image source, float degreesX, float degreesY, bool expand) + where TPixel : struct, IPixel { - SkewProcessor processor = new SkewProcessor { AngleX = degreesX, AngleY = degreesY, Expand = expand }; + SkewProcessor processor = new SkewProcessor { AngleX = degreesX, AngleY = degreesY, Expand = expand }; source.ApplyProcessor(processor, source.Bounds); return source; diff --git a/src/ImageSharp/Quantizers/IQuantizer.cs b/src/ImageSharp/Quantizers/IQuantizer{TPixel}.cs similarity index 73% rename from src/ImageSharp/Quantizers/IQuantizer.cs rename to src/ImageSharp/Quantizers/IQuantizer{TPixel}.cs index 88f273e9b..566ddf6b5 100644 --- a/src/ImageSharp/Quantizers/IQuantizer.cs +++ b/src/ImageSharp/Quantizers/IQuantizer{TPixel}.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // @@ -10,9 +10,9 @@ namespace ImageSharp.Quantizers /// /// Provides methods for allowing quantization of images pixels. /// - /// The pixel format. - public interface IQuantizer : IQuantizer - where TColor : struct, IPixel + /// The pixel format. + public interface IQuantizer : IQuantizer + where TPixel : struct, IPixel { /// /// Quantize an image and return the resulting output pixels. @@ -22,15 +22,15 @@ namespace ImageSharp.Quantizers /// /// A representing a quantized version of the image pixels. /// - QuantizedImage Quantize(ImageBase image, int maxColors); + QuantizedImage Quantize(ImageBase image, int maxColors); } /// /// Provides methods for allowing dithering of quantized image pixels. /// - /// The pixel format. - public interface IDitheredQuantizer : IQuantizer - where TColor : struct, IPixel + /// The pixel format. + public interface IDitheredQuantizer : IQuantizer + where TPixel : struct, IPixel { /// /// Gets or sets a value indicating whether to apply dithering to the output image. diff --git a/src/ImageSharp/Quantizers/OctreeQuantizer.cs b/src/ImageSharp/Quantizers/OctreeQuantizer{TPixel}.cs similarity index 92% rename from src/ImageSharp/Quantizers/OctreeQuantizer.cs rename to src/ImageSharp/Quantizers/OctreeQuantizer{TPixel}.cs index df52ee7f9..2296e589c 100644 --- a/src/ImageSharp/Quantizers/OctreeQuantizer.cs +++ b/src/ImageSharp/Quantizers/OctreeQuantizer{TPixel}.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // @@ -13,14 +13,14 @@ namespace ImageSharp.Quantizers /// Encapsulates methods to calculate the color palette if an image using an Octree pattern. /// /// - /// The pixel format. - public sealed class OctreeQuantizer : Quantizer - where TColor : struct, IPixel + /// The pixel format. + public sealed class OctreeQuantizer : Quantizer + where TPixel : struct, IPixel { /// /// A lookup table for colors /// - private readonly Dictionary colorMap = new Dictionary(); + private readonly Dictionary colorMap = new Dictionary(); /// /// The pixel buffer, used to reduce allocations. @@ -40,10 +40,10 @@ namespace ImageSharp.Quantizers /// /// The reduced image palette /// - private TColor[] palette; + private TPixel[] palette; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// /// The Octree quantizer is a two pass algorithm. The initial pass sets up the Octree, @@ -55,7 +55,7 @@ namespace ImageSharp.Quantizers } /// - public override QuantizedImage Quantize(ImageBase image, int maxColors) + public override QuantizedImage Quantize(ImageBase image, int maxColors) { this.colors = maxColors.Clamp(1, 255); this.octree = new Octree(this.GetBitsNeededForColorDepth(this.colors)); @@ -64,15 +64,15 @@ namespace ImageSharp.Quantizers } /// - protected override void SecondPass(PixelAccessor source, byte[] output, int width, int height) + protected override void SecondPass(PixelAccessor source, byte[] output, int width, int height) { // Load up the values for the first pixel. We can use these to speed up the second // pass of the algorithm by avoiding transforming rows of identical color. - TColor sourcePixel = source[0, 0]; - TColor previousPixel = sourcePixel; + TPixel sourcePixel = source[0, 0]; + TPixel previousPixel = sourcePixel; byte pixelValue = this.QuantizePixel(sourcePixel); - TColor[] colorPalette = this.GetPalette(); - TColor transformedPixel = colorPalette[pixelValue]; + TPixel[] colorPalette = this.GetPalette(); + TPixel transformedPixel = colorPalette[pixelValue]; for (int y = 0; y < height; y++) { @@ -110,14 +110,14 @@ namespace ImageSharp.Quantizers } /// - protected override void InitialQuantizePixel(TColor pixel) + protected override void InitialQuantizePixel(TPixel pixel) { // Add the color to the Octree this.octree.AddColor(pixel, this.pixelBuffer); } /// - protected override TColor[] GetPalette() + protected override TPixel[] GetPalette() { return this.palette ?? (this.palette = this.octree.Palletize(Math.Max(this.colors, 1))); } @@ -130,13 +130,13 @@ namespace ImageSharp.Quantizers /// The quantized value /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - private byte QuantizePixel(TColor pixel) + private byte QuantizePixel(TPixel pixel) { if (this.Dither) { // The colors have changed so we need to use Euclidean distance caclulation to find the closest value. // This palette can never be null here. - return this.GetClosestColor(pixel, this.palette, this.colorMap); + return this.GetClosesTPixel(pixel, this.palette, this.colorMap); } return (byte)this.octree.GetPaletteIndex(pixel, this.pixelBuffer); @@ -190,7 +190,7 @@ namespace ImageSharp.Quantizers /// /// Cache the previous color quantized /// - private TColor previousColor; + private TPixel previousColor; /// /// Initializes a new instance of the class. @@ -204,7 +204,7 @@ namespace ImageSharp.Quantizers this.Leaves = 0; this.reducibleNodes = new OctreeNode[9]; this.root = new OctreeNode(0, this.maxColorBits, this); - this.previousColor = default(TColor); + this.previousColor = default(TPixel); this.previousNode = null; } @@ -223,7 +223,7 @@ namespace ImageSharp.Quantizers /// /// The pixel data. /// The buffer array. - public void AddColor(TColor pixel, byte[] buffer) + public void AddColor(TPixel pixel, byte[] buffer) { // Check if this request is for the same color as the last if (this.previousColor.Equals(pixel)) @@ -253,9 +253,9 @@ namespace ImageSharp.Quantizers /// /// The maximum number of colors /// - /// An with the palletized colors + /// An with the palletized colors /// - public TColor[] Palletize(int colorCount) + public TPixel[] Palletize(int colorCount) { while (this.Leaves > colorCount) { @@ -263,7 +263,7 @@ namespace ImageSharp.Quantizers } // Now palletize the nodes - TColor[] palette = new TColor[colorCount + 1]; + TPixel[] palette = new TPixel[colorCount + 1]; int paletteIndex = 0; this.root.ConstructPalette(palette, ref paletteIndex); @@ -280,7 +280,7 @@ namespace ImageSharp.Quantizers /// /// The . /// - public int GetPaletteIndex(TColor pixel, byte[] buffer) + public int GetPaletteIndex(TPixel pixel, byte[] buffer) { return this.root.GetPaletteIndex(pixel, 0, buffer); } @@ -409,7 +409,7 @@ namespace ImageSharp.Quantizers /// The level in the tree /// The tree to which this node belongs /// The buffer array. - public void AddColor(TColor pixel, int colorBits, int level, Octree octree, byte[] buffer) + public void AddColor(TPixel pixel, int colorBits, int level, Octree octree, byte[] buffer) { // Update the color information if this is a leaf if (this.leaf) @@ -478,7 +478,7 @@ namespace ImageSharp.Quantizers /// /// The palette /// The current palette index - public void ConstructPalette(TColor[] palette, ref int index) + public void ConstructPalette(TPixel[] palette, ref int index) { if (this.leaf) { @@ -488,7 +488,7 @@ namespace ImageSharp.Quantizers byte b = (this.blue / this.pixelCount).ToByte(); // And set the color of the palette entry - TColor pixel = default(TColor); + TPixel pixel = default(TPixel); pixel.PackFromBytes(r, g, b, 255); palette[index] = pixel; @@ -517,7 +517,7 @@ namespace ImageSharp.Quantizers /// /// The representing the index of the pixel in the palette. /// - public int GetPaletteIndex(TColor pixel, int level, byte[] buffer) + public int GetPaletteIndex(TPixel pixel, int level, byte[] buffer) { int index = this.paletteIndex; @@ -548,7 +548,7 @@ namespace ImageSharp.Quantizers /// /// The pixel to add. /// The buffer array. - public void Increment(TColor pixel, byte[] buffer) + public void Increment(TPixel pixel, byte[] buffer) { pixel.ToXyzwBytes(buffer, 0); this.pixelCount++; diff --git a/src/ImageSharp/Quantizers/PaletteQuantizer.cs b/src/ImageSharp/Quantizers/PaletteQuantizer{TPixel}.cs similarity index 78% rename from src/ImageSharp/Quantizers/PaletteQuantizer.cs rename to src/ImageSharp/Quantizers/PaletteQuantizer{TPixel}.cs index f48c9ddd8..1c588b842 100644 --- a/src/ImageSharp/Quantizers/PaletteQuantizer.cs +++ b/src/ImageSharp/Quantizers/PaletteQuantizer{TPixel}.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // @@ -13,9 +13,9 @@ namespace ImageSharp.Quantizers /// Encapsulates methods to create a quantized image based upon the given palette. /// /// - /// The pixel format. - public sealed class PaletteQuantizer : Quantizer - where TColor : struct, IPixel + /// The pixel format. + public sealed class PaletteQuantizer : Quantizer + where TPixel : struct, IPixel { /// /// The pixel buffer, used to reduce allocations. @@ -25,32 +25,32 @@ namespace ImageSharp.Quantizers /// /// A lookup table for colors /// - private readonly Dictionary colorMap = new Dictionary(); + private readonly Dictionary colorMap = new Dictionary(); /// /// List of all colors in the palette /// - private TColor[] colors; + private TPixel[] colors; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// /// The color palette. If none is given this will default to the web safe colors defined /// in the CSS Color Module Level 4. /// - public PaletteQuantizer(TColor[] palette = null) + public PaletteQuantizer(TPixel[] palette = null) : base(true) { if (palette == null) { Rgba32[] constants = ColorConstants.WebSafeColors; - TColor[] safe = new TColor[constants.Length + 1]; + TPixel[] safe = new TPixel[constants.Length + 1]; for (int i = 0; i < constants.Length; i++) { constants[i].ToXyzwBytes(this.pixelBuffer, 0); - TColor packed = default(TColor); + TPixel packed = default(TPixel); packed.PackFromBytes(this.pixelBuffer[0], this.pixelBuffer[1], this.pixelBuffer[2], this.pixelBuffer[3]); safe[i] = packed; } @@ -64,22 +64,22 @@ namespace ImageSharp.Quantizers } /// - public override QuantizedImage Quantize(ImageBase image, int maxColors) + public override QuantizedImage Quantize(ImageBase image, int maxColors) { Array.Resize(ref this.colors, maxColors.Clamp(1, 255)); return base.Quantize(image, maxColors); } /// - protected override void SecondPass(PixelAccessor source, byte[] output, int width, int height) + protected override void SecondPass(PixelAccessor source, byte[] output, int width, int height) { // Load up the values for the first pixel. We can use these to speed up the second // pass of the algorithm by avoiding transforming rows of identical color. - TColor sourcePixel = source[0, 0]; - TColor previousPixel = sourcePixel; + TPixel sourcePixel = source[0, 0]; + TPixel previousPixel = sourcePixel; byte pixelValue = this.QuantizePixel(sourcePixel); - TColor[] colorPalette = this.GetPalette(); - TColor transformedPixel = colorPalette[pixelValue]; + TPixel[] colorPalette = this.GetPalette(); + TPixel transformedPixel = colorPalette[pixelValue]; for (int y = 0; y < height; y++) { @@ -117,7 +117,7 @@ namespace ImageSharp.Quantizers } /// - protected override TColor[] GetPalette() + protected override TPixel[] GetPalette() { return this.colors; } @@ -130,9 +130,9 @@ namespace ImageSharp.Quantizers /// The quantized value /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - private byte QuantizePixel(TColor pixel) + private byte QuantizePixel(TPixel pixel) { - return this.GetClosestColor(pixel, this.GetPalette(), this.colorMap); + return this.GetClosesTPixel(pixel, this.GetPalette(), this.colorMap); } } } \ No newline at end of file diff --git a/src/ImageSharp/Quantizers/Quantize.cs b/src/ImageSharp/Quantizers/Quantize.cs index f45cd3f79..44be039f4 100644 --- a/src/ImageSharp/Quantizers/Quantize.cs +++ b/src/ImageSharp/Quantizers/Quantize.cs @@ -11,34 +11,34 @@ namespace ImageSharp using ImageSharp.Quantizers; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Applies quantization to the image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The quantization mode to apply to perform the operation. /// The maximum number of colors to return. Defaults to 256. - /// The . - public static Image Quantize(this Image source, Quantization mode = Quantization.Octree, int maxColors = 256) - where TColor : struct, IPixel + /// The . + public static Image Quantize(this Image source, Quantization mode = Quantization.Octree, int maxColors = 256) + where TPixel : struct, IPixel { - IQuantizer quantizer; + IQuantizer quantizer; switch (mode) { case Quantization.Wu: - quantizer = new WuQuantizer(); + quantizer = new WuQuantizer(); break; case Quantization.Palette: - quantizer = new PaletteQuantizer(); + quantizer = new PaletteQuantizer(); break; default: - quantizer = new OctreeQuantizer(); + quantizer = new OctreeQuantizer(); break; } @@ -48,18 +48,18 @@ namespace ImageSharp /// /// Applies quantization to the image. /// - /// The pixel format. + /// The pixel format. /// The image this method extends. /// The quantizer to apply to perform the operation. /// The maximum number of colors to return. - /// The . - public static Image Quantize(this Image source, IQuantizer quantizer, int maxColors) - where TColor : struct, IPixel + /// The . + public static Image Quantize(this Image source, IQuantizer quantizer, int maxColors) + where TPixel : struct, IPixel { - QuantizedImage quantized = quantizer.Quantize(source, maxColors); + QuantizedImage quantized = quantizer.Quantize(source, maxColors); int palleteCount = quantized.Palette.Length - 1; - using (PixelAccessor pixels = new PixelAccessor(quantized.Width, quantized.Height)) + using (PixelAccessor pixels = new PixelAccessor(quantized.Width, quantized.Height)) { Parallel.For( 0, @@ -70,7 +70,7 @@ namespace ImageSharp for (int x = 0; x < pixels.Width; x++) { int i = x + (y * pixels.Width); - TColor color = quantized.Palette[Math.Min(palleteCount, quantized.Pixels[i])]; + TPixel color = quantized.Palette[Math.Min(palleteCount, quantized.Pixels[i])]; pixels[x, y] = color; } }); diff --git a/src/ImageSharp/Quantizers/QuantizedImage.cs b/src/ImageSharp/Quantizers/QuantizedImage{TPixel}.cs similarity index 83% rename from src/ImageSharp/Quantizers/QuantizedImage.cs rename to src/ImageSharp/Quantizers/QuantizedImage{TPixel}.cs index 471abbae7..927128065 100644 --- a/src/ImageSharp/Quantizers/QuantizedImage.cs +++ b/src/ImageSharp/Quantizers/QuantizedImage{TPixel}.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // @@ -10,18 +10,18 @@ namespace ImageSharp.Quantizers /// /// Represents a quantized image where the pixels indexed by a color palette. /// - /// The pixel format. - public class QuantizedImage - where TColor : struct, IPixel + /// The pixel format. + public class QuantizedImage + where TPixel : struct, IPixel { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The image width. /// The image height. /// The color palette. /// The quantized pixels. - public QuantizedImage(int width, int height, TColor[] palette, byte[] pixels) + public QuantizedImage(int width, int height, TPixel[] palette, byte[] pixels) { Guard.MustBeGreaterThan(width, 0, nameof(width)); Guard.MustBeGreaterThan(height, 0, nameof(height)); @@ -52,7 +52,7 @@ namespace ImageSharp.Quantizers /// /// Gets the color palette of this . /// - public TColor[] Palette { get; } + public TPixel[] Palette { get; } /// /// Gets the pixels of this . diff --git a/src/ImageSharp/Quantizers/Quantizer.cs b/src/ImageSharp/Quantizers/Quantizer{TPixel}.cs similarity index 85% rename from src/ImageSharp/Quantizers/Quantizer.cs rename to src/ImageSharp/Quantizers/Quantizer{TPixel}.cs index 492ec5f2b..1cf620bf9 100644 --- a/src/ImageSharp/Quantizers/Quantizer.cs +++ b/src/ImageSharp/Quantizers/Quantizer{TPixel}.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // @@ -14,9 +14,9 @@ namespace ImageSharp.Quantizers /// /// Encapsulates methods to calculate the color palette of an image. /// - /// The pixel format. - public abstract class Quantizer : IDitheredQuantizer - where TColor : struct, IPixel + /// The pixel format. + public abstract class Quantizer : IDitheredQuantizer + where TPixel : struct, IPixel { /// /// Flag used to indicate whether a single pass or two passes are needed for quantization. @@ -24,7 +24,7 @@ namespace ImageSharp.Quantizers private readonly bool singlePass; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// /// If true, the quantization only needs to loop through the source pixels once @@ -46,7 +46,7 @@ namespace ImageSharp.Quantizers public IErrorDiffuser DitherType { get; set; } = new SierraLite(); /// - public virtual QuantizedImage Quantize(ImageBase image, int maxColors) + public virtual QuantizedImage Quantize(ImageBase image, int maxColors) { Guard.NotNull(image, nameof(image)); @@ -54,9 +54,9 @@ namespace ImageSharp.Quantizers int height = image.Height; int width = image.Width; byte[] quantizedPixels = new byte[width * height]; - TColor[] colorPalette; + TPixel[] colorPalette; - using (PixelAccessor pixels = image.Lock()) + using (PixelAccessor pixels = image.Lock()) { // Call the FirstPass function if not a single pass algorithm. // For something like an Octree quantizer, this will run through @@ -72,8 +72,8 @@ namespace ImageSharp.Quantizers if (this.Dither) { // We clone the image as we don't want to alter the original. - using (Image clone = new Image(image)) - using (PixelAccessor clonedPixels = clone.Lock()) + using (Image clone = new Image(image)) + using (PixelAccessor clonedPixels = clone.Lock()) { this.SecondPass(clonedPixels, quantizedPixels, width, height); } @@ -84,7 +84,7 @@ namespace ImageSharp.Quantizers } } - return new QuantizedImage(width, height, colorPalette, quantizedPixels); + return new QuantizedImage(width, height, colorPalette, quantizedPixels); } /// @@ -93,7 +93,7 @@ namespace ImageSharp.Quantizers /// The source data /// The width in pixels of the image. /// The height in pixels of the image. - protected virtual void FirstPass(PixelAccessor source, int width, int height) + protected virtual void FirstPass(PixelAccessor source, int width, int height) { // Loop through each row for (int y = 0; y < height; y++) @@ -114,7 +114,7 @@ namespace ImageSharp.Quantizers /// The output pixel array /// The width in pixels of the image /// The height in pixels of the image - protected abstract void SecondPass(PixelAccessor source, byte[] output, int width, int height); + protected abstract void SecondPass(PixelAccessor source, byte[] output, int width, int height); /// /// Override this to process the pixel in the first pass of the algorithm @@ -124,7 +124,7 @@ namespace ImageSharp.Quantizers /// This function need only be overridden if your quantize algorithm needs two passes, /// such as an Octree quantizer. /// - protected virtual void InitialQuantizePixel(TColor pixel) + protected virtual void InitialQuantizePixel(TPixel pixel) { } @@ -132,9 +132,9 @@ namespace ImageSharp.Quantizers /// Retrieve the palette for the quantized image. Can be called more than once so make sure calls are cached. /// /// - /// + /// /// - protected abstract TColor[] GetPalette(); + protected abstract TPixel[] GetPalette(); /// /// Returns the closest color from the palette to the given color by calculating the Euclidean distance. @@ -144,7 +144,7 @@ namespace ImageSharp.Quantizers /// The cache to store the result in. /// The [MethodImpl(MethodImplOptions.AggressiveInlining)] - protected byte GetClosestColor(TColor pixel, TColor[] colorPalette, Dictionary cache) + protected byte GetClosesTPixel(TPixel pixel, TPixel[] colorPalette, Dictionary cache) { // Check if the color is in the lookup table if (cache.ContainsKey(pixel)) diff --git a/src/ImageSharp/Quantizers/WuArrayPool.cs b/src/ImageSharp/Quantizers/WuArrayPool.cs index 5e4956f01..bd8ee9d6b 100644 --- a/src/ImageSharp/Quantizers/WuArrayPool.cs +++ b/src/ImageSharp/Quantizers/WuArrayPool.cs @@ -8,7 +8,7 @@ namespace ImageSharp.Quantizers using System.Buffers; /// - /// Provides array pooling for the . + /// Provides array pooling for the . /// This is a separate class so that the pools can be shared accross multiple generic quantizer instaces. /// internal static class WuArrayPool @@ -29,7 +29,7 @@ namespace ImageSharp.Quantizers public static readonly ArrayPool BytePool = ArrayPool.Create(TableLength, 5); /// - /// The table length. Matches the calculated value in + /// The table length. Matches the calculated value in /// private const int TableLength = 2471625; } diff --git a/src/ImageSharp/Quantizers/WuQuantizer.cs b/src/ImageSharp/Quantizers/WuQuantizer{TPixel}.cs similarity index 96% rename from src/ImageSharp/Quantizers/WuQuantizer.cs rename to src/ImageSharp/Quantizers/WuQuantizer{TPixel}.cs index 46af6fab9..16ab64f3c 100644 --- a/src/ImageSharp/Quantizers/WuQuantizer.cs +++ b/src/ImageSharp/Quantizers/WuQuantizer{TPixel}.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // @@ -30,9 +30,9 @@ namespace ImageSharp.Quantizers /// but more expensive versions. /// /// - /// The pixel format. - public class WuQuantizer : Quantizer - where TColor : struct, IPixel + /// The pixel format. + public class WuQuantizer : Quantizer + where TPixel : struct, IPixel { /// /// The index bits. @@ -67,7 +67,7 @@ namespace ImageSharp.Quantizers /// /// A lookup table for colors /// - private readonly Dictionary colorMap = new Dictionary(); + private readonly Dictionary colorMap = new Dictionary(); /// /// Moment of P(c). @@ -112,7 +112,7 @@ namespace ImageSharp.Quantizers /// /// The reduced image palette /// - private TColor[] palette; + private TPixel[] palette; /// /// The color cube representing the image palette @@ -120,7 +120,7 @@ namespace ImageSharp.Quantizers private Box[] colorCube; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// /// The Wu quantizer is a two pass algorithm. The initial pass sets up the 3-D color histogram, @@ -132,7 +132,7 @@ namespace ImageSharp.Quantizers } /// - public override QuantizedImage Quantize(ImageBase image, int maxColors) + public override QuantizedImage Quantize(ImageBase image, int maxColors) { Guard.NotNull(image, nameof(image)); @@ -163,11 +163,11 @@ namespace ImageSharp.Quantizers } /// - protected override TColor[] GetPalette() + protected override TPixel[] GetPalette() { if (this.palette == null) { - this.palette = new TColor[this.colors]; + this.palette = new TPixel[this.colors]; for (int k = 0; k < this.colors; k++) { this.Mark(this.colorCube[k], (byte)k); @@ -181,7 +181,7 @@ namespace ImageSharp.Quantizers float b = Volume(this.colorCube[k], this.vmb) / weight; float a = Volume(this.colorCube[k], this.vma) / weight; - TColor color = default(TColor); + TPixel color = default(TPixel); color.PackFromVector4(new Vector4(r, g, b, a) / 255F); this.palette[k] = color; } @@ -192,7 +192,7 @@ namespace ImageSharp.Quantizers } /// - protected override void InitialQuantizePixel(TColor pixel) + protected override void InitialQuantizePixel(TPixel pixel) { // Add the color to a 3-D color histogram. // Colors are expected in r->g->b->a format @@ -219,7 +219,7 @@ namespace ImageSharp.Quantizers } /// - protected override void FirstPass(PixelAccessor source, int width, int height) + protected override void FirstPass(PixelAccessor source, int width, int height) { // Build up the 3-D color histogram // Loop through each row @@ -238,15 +238,15 @@ namespace ImageSharp.Quantizers } /// - protected override void SecondPass(PixelAccessor source, byte[] output, int width, int height) + protected override void SecondPass(PixelAccessor source, byte[] output, int width, int height) { // Load up the values for the first pixel. We can use these to speed up the second // pass of the algorithm by avoiding transforming rows of identical color. - TColor sourcePixel = source[0, 0]; - TColor previousPixel = sourcePixel; + TPixel sourcePixel = source[0, 0]; + TPixel previousPixel = sourcePixel; byte pixelValue = this.QuantizePixel(sourcePixel); - TColor[] colorPalette = this.GetPalette(); - TColor transformedPixel = colorPalette[pixelValue]; + TPixel[] colorPalette = this.GetPalette(); + TPixel transformedPixel = colorPalette[pixelValue]; for (int y = 0; y < height; y++) { @@ -825,13 +825,13 @@ namespace ImageSharp.Quantizers /// The quantized value /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - private byte QuantizePixel(TColor pixel) + private byte QuantizePixel(TPixel pixel) { if (this.Dither) { // The colors have changed so we need to use Euclidean distance caclulation to find the closest value. // This palette can never be null here. - return this.GetClosestColor(pixel, this.palette, this.colorMap); + return this.GetClosesTPixel(pixel, this.palette, this.colorMap); } // Expected order r->g->b->a diff --git a/tests/ImageSharp.Benchmarks/Color/Bulk/PackFromXyzw.cs b/tests/ImageSharp.Benchmarks/Color/Bulk/PackFromXyzw.cs index c0d50bf5b..00b0b503c 100644 --- a/tests/ImageSharp.Benchmarks/Color/Bulk/PackFromXyzw.cs +++ b/tests/ImageSharp.Benchmarks/Color/Bulk/PackFromXyzw.cs @@ -5,10 +5,10 @@ namespace ImageSharp.Benchmarks.Color.Bulk using Rgba32 = ImageSharp.Rgba32; - public abstract class PackFromXyzw - where TColor : struct, IPixel + public abstract class PackFromXyzw + where TPixel : struct, IPixel { - private Buffer destination; + private Buffer destination; private Buffer source; @@ -18,7 +18,7 @@ namespace ImageSharp.Benchmarks.Color.Bulk [Setup] public void Setup() { - this.destination = new Buffer(this.Count); + this.destination = new Buffer(this.Count); this.source = new Buffer(this.Count * 4); } @@ -33,12 +33,12 @@ namespace ImageSharp.Benchmarks.Color.Bulk public void PerElement() { byte[] s = this.source.Array; - TColor[] d = this.destination.Array; + TPixel[] d = this.destination.Array; for (int i = 0; i < this.Count; i++) { int i4 = i * 4; - TColor c = default(TColor); + TPixel c = default(TPixel); c.PackFromBytes(s[i4], s[i4 + 1], s[i4 + 2], s[i4 + 3]); d[i] = c; } @@ -47,13 +47,13 @@ namespace ImageSharp.Benchmarks.Color.Bulk [Benchmark] public void CommonBulk() { - new BulkPixelOperations().PackFromXyzwBytes(this.source, this.destination, this.Count); + new BulkPixelOperations().PackFromXyzwBytes(this.source, this.destination, this.Count); } [Benchmark] public void OptimizedBulk() { - BulkPixelOperations.Instance.PackFromXyzwBytes(this.source, this.destination, this.Count); + BulkPixelOperations.Instance.PackFromXyzwBytes(this.source, this.destination, this.Count); } } diff --git a/tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4.cs b/tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4.cs index bd1b0e11d..b3a23147e 100644 --- a/tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4.cs +++ b/tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4.cs @@ -5,10 +5,10 @@ namespace ImageSharp.Benchmarks.Color.Bulk using BenchmarkDotNet.Attributes; - public abstract class ToVector4 - where TColor : struct, IPixel + public abstract class ToVector4 + where TPixel : struct, IPixel { - private Buffer source; + private Buffer source; private Buffer destination; @@ -18,7 +18,7 @@ namespace ImageSharp.Benchmarks.Color.Bulk [Setup] public void Setup() { - this.source = new Buffer(this.Count); + this.source = new Buffer(this.Count); this.destination = new Buffer(this.Count); } @@ -32,12 +32,12 @@ namespace ImageSharp.Benchmarks.Color.Bulk [Benchmark(Baseline = true)] public void PerElement() { - TColor[] s = this.source.Array; + TPixel[] s = this.source.Array; Vector4[] d = this.destination.Array; for (int i = 0; i < this.Count; i++) { - TColor c = s[i]; + TPixel c = s[i]; d[i] = c.ToVector4(); } } @@ -45,13 +45,13 @@ namespace ImageSharp.Benchmarks.Color.Bulk [Benchmark] public void CommonBulk() { - new BulkPixelOperations().ToVector4(this.source, this.destination, this.Count); + new BulkPixelOperations().ToVector4(this.source, this.destination, this.Count); } [Benchmark] public void OptimizedBulk() { - BulkPixelOperations.Instance.ToVector4(this.source, this.destination, this.Count); + BulkPixelOperations.Instance.ToVector4(this.source, this.destination, this.Count); } } diff --git a/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyz.cs b/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyz.cs index c90f78d16..ad7e2a9cf 100644 --- a/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyz.cs +++ b/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyz.cs @@ -5,10 +5,10 @@ namespace ImageSharp.Benchmarks.Color.Bulk using Rgba32 = ImageSharp.Rgba32; - public abstract class ToXyz - where TColor : struct, IPixel + public abstract class ToXyz + where TPixel : struct, IPixel { - private Buffer source; + private Buffer source; private Buffer destination; @@ -18,7 +18,7 @@ namespace ImageSharp.Benchmarks.Color.Bulk [Setup] public void Setup() { - this.source = new Buffer(this.Count); + this.source = new Buffer(this.Count); this.destination = new Buffer(this.Count * 3); } @@ -32,12 +32,12 @@ namespace ImageSharp.Benchmarks.Color.Bulk [Benchmark(Baseline = true)] public void PerElement() { - TColor[] s = this.source.Array; + TPixel[] s = this.source.Array; byte[] d = this.destination.Array; for (int i = 0; i < this.Count; i++) { - TColor c = s[i]; + TPixel c = s[i]; c.ToXyzBytes(d, i * 4); } } @@ -45,13 +45,13 @@ namespace ImageSharp.Benchmarks.Color.Bulk [Benchmark] public void CommonBulk() { - new BulkPixelOperations().ToXyzBytes(this.source, this.destination, this.Count); + new BulkPixelOperations().ToXyzBytes(this.source, this.destination, this.Count); } [Benchmark] public void OptimizedBulk() { - BulkPixelOperations.Instance.ToXyzBytes(this.source, this.destination, this.Count); + BulkPixelOperations.Instance.ToXyzBytes(this.source, this.destination, this.Count); } } diff --git a/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs b/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs index 9ec8adc79..75e0f247c 100644 --- a/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs +++ b/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs @@ -10,10 +10,10 @@ namespace ImageSharp.Benchmarks.Color.Bulk using Rgba32 = ImageSharp.Rgba32; - public abstract class ToXyzw - where TColor : struct, IPixel + public abstract class ToXyzw + where TPixel : struct, IPixel { - private Buffer source; + private Buffer source; private Buffer destination; @@ -23,7 +23,7 @@ namespace ImageSharp.Benchmarks.Color.Bulk [Setup] public void Setup() { - this.source = new Buffer(this.Count); + this.source = new Buffer(this.Count); this.destination = new Buffer(this.Count * 4); } @@ -37,12 +37,12 @@ namespace ImageSharp.Benchmarks.Color.Bulk [Benchmark(Baseline = true)] public void PerElement() { - TColor[] s = this.source.Array; + TPixel[] s = this.source.Array; byte[] d = this.destination.Array; for (int i = 0; i < this.Count; i++) { - TColor c = s[i]; + TPixel c = s[i]; c.ToXyzwBytes(d, i * 4); } } @@ -50,13 +50,13 @@ namespace ImageSharp.Benchmarks.Color.Bulk [Benchmark] public void CommonBulk() { - new BulkPixelOperations().ToXyzwBytes(this.source, this.destination, this.Count); + new BulkPixelOperations().ToXyzwBytes(this.source, this.destination, this.Count); } [Benchmark] public void OptimizedBulk() { - BulkPixelOperations.Instance.ToXyzwBytes(this.source, this.destination, this.Count); + BulkPixelOperations.Instance.ToXyzwBytes(this.source, this.destination, this.Count); } } diff --git a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs index c34a63ad6..19aefd06b 100644 --- a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs @@ -71,15 +71,15 @@ namespace ImageSharp.Tests.Colors [Theory] [WithBlankImages(1, 1, PixelTypes.All)] - public void GetGlobalInstance(TestImageProvider dummy) - where TColor : struct, IPixel + public void GetGlobalInstance(TestImageProvider dummy) + where TPixel : struct, IPixel { - Assert.NotNull(BulkPixelOperations.Instance); + Assert.NotNull(BulkPixelOperations.Instance); } } - public abstract class BulkPixelOperationsTests : MeasureFixture - where TColor : struct, IPixel + public abstract class BulkPixelOperationsTests : MeasureFixture + where TPixel : struct, IPixel { protected BulkPixelOperationsTests(ITestOutputHelper output) : base(output) @@ -88,11 +88,11 @@ namespace ImageSharp.Tests.Colors public static TheoryData ArraySizesData => new TheoryData { 7, 16, 1111 }; - private static BulkPixelOperations Operations => BulkPixelOperations.Instance; + private static BulkPixelOperations Operations => BulkPixelOperations.Instance; - internal static TColor[] CreateExpectedPixelData(Vector4[] source) + internal static TPixel[] CreateExpectedPixelData(Vector4[] source) { - TColor[] expected = new TColor[source.Length]; + TPixel[] expected = new TPixel[source.Length]; for (int i = 0; i < expected.Length; i++) { @@ -106,7 +106,7 @@ namespace ImageSharp.Tests.Colors public void PackFromVector4(int count) { Vector4[] source = CreateVector4TestData(count); - TColor[] expected = CreateExpectedPixelData(source); + TPixel[] expected = CreateExpectedPixelData(source); TestOperation( source, @@ -115,7 +115,7 @@ namespace ImageSharp.Tests.Colors ); } - internal static Vector4[] CreateExpectedVector4Data(TColor[] source) + internal static Vector4[] CreateExpectedVector4Data(TPixel[] source) { Vector4[] expected = new Vector4[source.Length]; @@ -130,7 +130,7 @@ namespace ImageSharp.Tests.Colors [MemberData(nameof(ArraySizesData))] public void ToVector4(int count) { - TColor[] source = CreatePixelTestData(count); + TPixel[] source = CreatePixelTestData(count); Vector4[] expected = CreateExpectedVector4Data(source); TestOperation( @@ -146,7 +146,7 @@ namespace ImageSharp.Tests.Colors public void PackFromXyzBytes(int count) { byte[] source = CreateByteTestData(count * 3); - TColor[] expected = new TColor[count]; + TPixel[] expected = new TPixel[count]; for (int i = 0; i < count; i++) { @@ -166,7 +166,7 @@ namespace ImageSharp.Tests.Colors [MemberData(nameof(ArraySizesData))] public void ToXyzBytes(int count) { - TColor[] source = CreatePixelTestData(count); + TPixel[] source = CreatePixelTestData(count); byte[] expected = new byte[count * 3]; for (int i = 0; i < count; i++) @@ -187,7 +187,7 @@ namespace ImageSharp.Tests.Colors public void PackFromXyzwBytes(int count) { byte[] source = CreateByteTestData(count * 4); - TColor[] expected = new TColor[count]; + TPixel[] expected = new TPixel[count]; for (int i = 0; i < count; i++) { @@ -207,7 +207,7 @@ namespace ImageSharp.Tests.Colors [MemberData(nameof(ArraySizesData))] public void ToXyzwBytes(int count) { - TColor[] source = CreatePixelTestData(count); + TPixel[] source = CreatePixelTestData(count); byte[] expected = new byte[count * 4]; for (int i = 0; i < count; i++) @@ -228,7 +228,7 @@ namespace ImageSharp.Tests.Colors public void PackFromZyxBytes(int count) { byte[] source = CreateByteTestData(count * 3); - TColor[] expected = new TColor[count]; + TPixel[] expected = new TPixel[count]; for (int i = 0; i < count; i++) { @@ -248,7 +248,7 @@ namespace ImageSharp.Tests.Colors [MemberData(nameof(ArraySizesData))] public void ToZyxBytes(int count) { - TColor[] source = CreatePixelTestData(count); + TPixel[] source = CreatePixelTestData(count); byte[] expected = new byte[count * 3]; for (int i = 0; i < count; i++) @@ -269,7 +269,7 @@ namespace ImageSharp.Tests.Colors public void PackFromZyxwBytes(int count) { byte[] source = CreateByteTestData(count * 4); - TColor[] expected = new TColor[count]; + TPixel[] expected = new TPixel[count]; for (int i = 0; i < count; i++) { @@ -289,7 +289,7 @@ namespace ImageSharp.Tests.Colors [MemberData(nameof(ArraySizesData))] public void ToZyxwBytes(int count) { - TColor[] source = CreatePixelTestData(count); + TPixel[] source = CreatePixelTestData(count); byte[] expected = new byte[count * 4]; for (int i = 0; i < count; i++) @@ -387,9 +387,9 @@ namespace ImageSharp.Tests.Colors return result; } - internal static TColor[] CreatePixelTestData(int length) + internal static TPixel[] CreatePixelTestData(int length) { - TColor[] result = new TColor[length]; + TPixel[] result = new TPixel[length]; Random rnd = new Random(42); // Deterministic random values diff --git a/tests/ImageSharp.Tests/Formats/Jpg/BadEofJpegTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/BadEofJpegTests.cs index 47b114393..453f689f2 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/BadEofJpegTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/BadEofJpegTests.cs @@ -28,10 +28,10 @@ namespace ImageSharp.Tests [Theory] [WithFile(TestImages.Jpeg.Baseline.Bad.MissingEOF, PixelTypes.Rgba32)] - public void LoadBaselineImage(TestImageProvider provider) - where TColor : struct, IPixel + public void LoadBaselineImage(TestImageProvider provider) + where TPixel : struct, IPixel { - using (Image image = provider.GetImage()) + using (Image image = provider.GetImage()) { Assert.NotNull(image); provider.Utility.SaveTestOutputFile(image, "bmp"); @@ -40,10 +40,10 @@ namespace ImageSharp.Tests [Theory] // TODO: #18 [WithFile(TestImages.Jpeg.Progressive.Bad.BadEOF, PixelTypes.Rgba32)] - public void LoadProgressiveImage(TestImageProvider provider) - where TColor : struct, IPixel + public void LoadProgressiveImage(TestImageProvider provider) + where TPixel : struct, IPixel { - using (Image image = provider.GetImage()) + using (Image image = provider.GetImage()) { Assert.NotNull(image); provider.Utility.SaveTestOutputFile(image, "bmp"); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs index 316430dfc..60f310bbd 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs @@ -26,10 +26,10 @@ namespace ImageSharp.Tests [Theory] [WithFileCollection(nameof(BaselineTestJpegs), PixelTypes.Rgba32 | PixelTypes.StandardImageClass | PixelTypes.Argb32)] - public void OpenBaselineJpeg_SaveBmp(TestImageProvider provider) - where TColor : struct, IPixel + public void OpenBaselineJpeg_SaveBmp(TestImageProvider provider) + where TPixel : struct, IPixel { - using (Image image = provider.GetImage()) + using (Image image = provider.GetImage()) { provider.Utility.SaveTestOutputFile(image, "bmp"); } @@ -37,10 +37,10 @@ namespace ImageSharp.Tests [Theory] [WithFileCollection(nameof(ProgressiveTestJpegs), PixelTypes.Rgba32 | PixelTypes.StandardImageClass | PixelTypes.Argb32)] - public void OpenProgressiveJpeg_SaveBmp(TestImageProvider provider) - where TColor : struct, IPixel + public void OpenProgressiveJpeg_SaveBmp(TestImageProvider provider) + where TPixel : struct, IPixel { - using (Image image = provider.GetImage()) + using (Image image = provider.GetImage()) { provider.Utility.SaveTestOutputFile(image, "bmp"); } @@ -52,14 +52,14 @@ namespace ImageSharp.Tests [WithSolidFilledImages(16, 16, 255, 0, 0, PixelTypes.StandardImageClass, JpegSubsample.Ratio444, 75)] [WithSolidFilledImages(16, 16, 255, 0, 0, PixelTypes.StandardImageClass, JpegSubsample.Ratio444, 100)] [WithSolidFilledImages(8, 8, 255, 0, 0, PixelTypes.StandardImageClass, JpegSubsample.Ratio444, 100)] - public void DecodeGenerated_SaveBmp( - TestImageProvider provider, + public void DecodeGenerated_SaveBmp( + TestImageProvider provider, JpegSubsample subsample, int quality) - where TColor : struct, IPixel + where TPixel : struct, IPixel { byte[] data; - using (Image image = provider.GetImage()) + using (Image image = provider.GetImage()) { JpegEncoder encoder = new JpegEncoder(); JpegEncoderOptions options = new JpegEncoderOptions { Subsample = subsample, Quality = quality }; @@ -72,18 +72,18 @@ namespace ImageSharp.Tests } // TODO: Automatic image comparers could help here a lot :P - Image mirror = provider.Factory.CreateImage(data); + Image mirror = provider.Factory.CreateImage(data); provider.Utility.TestName += $"_{subsample}_Q{quality}"; provider.Utility.SaveTestOutputFile(mirror, "bmp"); } [Theory] [WithSolidFilledImages(42, 88, 255, 0, 0, PixelTypes.StandardImageClass)] - public void DecodeGenerated_MetadataOnly( - TestImageProvider provider) - where TColor : struct, IPixel + public void DecodeGenerated_MetadataOnly( + TestImageProvider provider) + where TPixel : struct, IPixel { - using (Image image = provider.GetImage()) + using (Image image = provider.GetImage()) { using (MemoryStream ms = new MemoryStream()) { @@ -92,7 +92,7 @@ namespace ImageSharp.Tests using (JpegDecoderCore decoder = new JpegDecoderCore(null, null)) { - Image mirror = decoder.Decode(ms); + Image mirror = decoder.Decode(ms); Assert.Equal(decoder.ImageWidth, image.Width); Assert.Equal(decoder.ImageHeight, image.Height); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs index 3d2e9f310..5bc5e780c 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs @@ -31,10 +31,10 @@ namespace ImageSharp.Tests [WithFile(TestImages.Jpeg.Baseline.Lake, PixelTypes.StandardImageClass, 75, JpegSubsample.Ratio420)] [WithFile(TestImages.Jpeg.Baseline.Snake, PixelTypes.StandardImageClass, 75, JpegSubsample.Ratio444)] [WithFile(TestImages.Jpeg.Baseline.Lake, PixelTypes.StandardImageClass, 75, JpegSubsample.Ratio444)] - public void LoadResizeSave(TestImageProvider provider, int quality, JpegSubsample subsample) - where TColor : struct, IPixel + public void LoadResizeSave(TestImageProvider provider, int quality, JpegSubsample subsample) + where TPixel : struct, IPixel { - using (Image image = provider.GetImage().Resize(new ResizeOptions { Size = new Size(150, 100), Mode = ResizeMode.Max })) + using (Image image = provider.GetImage().Resize(new ResizeOptions { Size = new Size(150, 100), Mode = ResizeMode.Max })) { image.MetaData.Quality = quality; image.MetaData.ExifProfile = null; // Reduce the size of the file @@ -50,10 +50,10 @@ namespace ImageSharp.Tests [Theory] [WithFileCollection(nameof(AllBmpFiles), PixelTypes.Rgba32 | PixelTypes.StandardImageClass | PixelTypes.Argb32, JpegSubsample.Ratio420, 75)] [WithFileCollection(nameof(AllBmpFiles), PixelTypes.Rgba32 | PixelTypes.StandardImageClass | PixelTypes.Argb32, JpegSubsample.Ratio444, 75)] - public void OpenBmp_SaveJpeg(TestImageProvider provider, JpegSubsample subSample, int quality) - where TColor : struct, IPixel + public void OpenBmp_SaveJpeg(TestImageProvider provider, JpegSubsample subSample, int quality) + where TPixel : struct, IPixel { - using (Image image = provider.GetImage()) + using (Image image = provider.GetImage()) { ImagingTestCaseUtility utility = provider.Utility; utility.TestName += "_" + subSample + "_Q" + quality; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegUtilsTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegUtilsTests.cs index ea1a46f2f..117a5354f 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegUtilsTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegUtilsTests.cs @@ -15,11 +15,11 @@ namespace ImageSharp.Tests public class JpegUtilsTests : TestBase { - public static Image CreateTestImage(GenericFactory factory) - where TColor : struct, IPixel + public static Image CreateTestImage(GenericFactory factory) + where TPixel : struct, IPixel { - Image image = factory.CreateImage(10, 10); - using (PixelAccessor pixels = image.Lock()) + Image image = factory.CreateImage(10, 10); + using (PixelAccessor pixels = image.Lock()) { for (int i = 0; i < 10; i++) { @@ -27,7 +27,7 @@ namespace ImageSharp.Tests { Vector4 v = new Vector4(i / 10f, j / 10f, 0, 1); - TColor color = default(TColor); + TPixel color = default(TPixel); color.PackFromVector4(v); pixels[i, j] = color; @@ -40,14 +40,14 @@ namespace ImageSharp.Tests [Theory] [WithMemberFactory(nameof(CreateTestImage), PixelTypes.Rgba32| PixelTypes.StandardImageClass | PixelTypes.Argb32)] - public void CopyStretchedRGBTo_FromOrigo(TestImageProvider provider) - where TColor : struct, IPixel + public void CopyStretchedRGBTo_FromOrigo(TestImageProvider provider) + where TPixel : struct, IPixel { - using (Image src = provider.GetImage()) - using (Image dest = provider.Factory.CreateImage(8, 8)) - using (PixelArea area = new PixelArea(8, 8, ComponentOrder.Xyz)) - using (PixelAccessor s = src.Lock()) - using (PixelAccessor d = dest.Lock()) + using (Image src = provider.GetImage()) + using (Image dest = provider.Factory.CreateImage(8, 8)) + using (PixelArea area = new PixelArea(8, 8, ComponentOrder.Xyz)) + using (PixelAccessor s = src.Lock()) + using (PixelAccessor d = dest.Lock()) { s.CopyRGBBytesStretchedTo(area, 0, 0); d.CopyFrom(area, 0, 0); @@ -62,14 +62,14 @@ namespace ImageSharp.Tests [Theory] [WithMemberFactory(nameof(CreateTestImage), PixelTypes.Rgba32| PixelTypes.StandardImageClass | PixelTypes.Argb32)] - public void CopyStretchedRGBTo_WithOffset(TestImageProvider provider) - where TColor : struct, IPixel + public void CopyStretchedRGBTo_WithOffset(TestImageProvider provider) + where TPixel : struct, IPixel { - using (Image src = provider.GetImage()) - using (PixelArea area = new PixelArea(8, 8, ComponentOrder.Xyz)) - using (Image dest = provider.Factory.CreateImage(8, 8)) - using (PixelAccessor s = src.Lock()) - using (PixelAccessor d = dest.Lock()) + using (Image src = provider.GetImage()) + using (PixelArea area = new PixelArea(8, 8, ComponentOrder.Xyz)) + using (Image dest = provider.Factory.CreateImage(8, 8)) + using (PixelAccessor s = src.Lock()) + using (PixelAccessor d = dest.Lock()) { s.CopyRGBBytesStretchedTo(area, 7, 6); d.CopyFrom(area, 0, 0); diff --git a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs index 51cb0cdc0..b70df9c17 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs @@ -17,10 +17,10 @@ namespace ImageSharp.Tests { [Theory] [WithBlankImages(1, 1, PixelTypes.All)] - public void WritesFileMarker(TestImageProvider provider) - where TColor : struct, IPixel + public void WritesFileMarker(TestImageProvider provider) + where TPixel : struct, IPixel { - using (Image image = provider.GetImage()) + using (Image image = provider.GetImage()) using (MemoryStream ms = new MemoryStream()) { image.Save(ms, new PngEncoder()); diff --git a/tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs index a7453f77c..1e3879a93 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs @@ -19,11 +19,11 @@ namespace ImageSharp.Tests.Formats.Png { [Theory] [WithTestPatternImages(300, 300, PixelTypes.All)] - public void GeneralTest(TestImageProvider provider) - where TColor : struct, IPixel + public void GeneralTest(TestImageProvider provider) + where TPixel : struct, IPixel { // does saving a file then repoening mean both files are identical??? - using (Image image = provider.GetImage()) + using (Image image = provider.GetImage()) using (MemoryStream ms = new MemoryStream()) { // image.Save(provider.Utility.GetTestOutputFileName("bmp")); @@ -40,11 +40,11 @@ namespace ImageSharp.Tests.Formats.Png [Theory] [WithTestPatternImages(100, 100, PixelTypes.All)] - public void CanSaveIndexedPng(TestImageProvider provider) - where TColor : struct, IPixel + public void CanSaveIndexedPng(TestImageProvider provider) + where TPixel : struct, IPixel { // does saving a file then repoening mean both files are identical??? - using (Image image = provider.GetImage()) + using (Image image = provider.GetImage()) using (MemoryStream ms = new MemoryStream()) { // image.Save(provider.Utility.GetTestOutputFileName("bmp")); @@ -62,11 +62,11 @@ namespace ImageSharp.Tests.Formats.Png // JJS: Commented out for now since the test does not take into lossy nature of indexing. //[Theory] //[WithTestPatternImages(100, 100, PixelTypes.Color)] - //public void CanSaveIndexedPngTwice(TestImageProvider provider) - // where TColor : struct, IPixel + //public void CanSaveIndexedPngTwice(TestImageProvider provider) + // where TPixel : struct, IPixel //{ // // does saving a file then repoening mean both files are identical??? - // using (Image source = provider.GetImage()) + // using (Image source = provider.GetImage()) // using (MemoryStream ms = new MemoryStream()) // { // source.MetaData.Quality = 256; @@ -104,11 +104,11 @@ namespace ImageSharp.Tests.Formats.Png [Theory] [WithTestPatternImages(300, 300, PixelTypes.All)] - public void Resize(TestImageProvider provider) - where TColor : struct, IPixel + public void Resize(TestImageProvider provider) + where TPixel : struct, IPixel { // does saving a file then repoening mean both files are identical??? - using (Image image = provider.GetImage()) + using (Image image = provider.GetImage()) using (MemoryStream ms = new MemoryStream()) { // image.Save(provider.Utility.GetTestOutputFileName("png")); diff --git a/tests/ImageSharp.Tests/Image/PixelAccessorTests.cs b/tests/ImageSharp.Tests/Image/PixelAccessorTests.cs index 858b968d6..b48ffd7e9 100644 --- a/tests/ImageSharp.Tests/Image/PixelAccessorTests.cs +++ b/tests/ImageSharp.Tests/Image/PixelAccessorTests.cs @@ -15,11 +15,11 @@ namespace ImageSharp.Tests /// public class PixelAccessorTests { - public static Image CreateTestImage(GenericFactory factory) - where TColor : struct, IPixel + public static Image CreateTestImage(GenericFactory factory) + where TPixel : struct, IPixel { - Image image = factory.CreateImage(10, 10); - using (PixelAccessor pixels = image.Lock()) + Image image = factory.CreateImage(10, 10); + using (PixelAccessor pixels = image.Lock()) { for (int i = 0; i < 10; i++) { @@ -28,7 +28,7 @@ namespace ImageSharp.Tests Vector4 v = new Vector4(i, j, 0, 1); v /= 10; - TColor color = default(TColor); + TPixel color = default(TPixel); color.PackFromVector4(v); pixels[i, j] = color; @@ -43,21 +43,21 @@ namespace ImageSharp.Tests [WithMemberFactory(nameof(CreateTestImage), PixelTypes.All, ComponentOrder.Zyx)] [WithMemberFactory(nameof(CreateTestImage), PixelTypes.All, ComponentOrder.Xyzw)] [WithMemberFactory(nameof(CreateTestImage), PixelTypes.All, ComponentOrder.Zyxw)] - public void CopyTo_Then_CopyFrom_OnFullImageRect(TestImageProvider provider, ComponentOrder order) - where TColor : struct, IPixel + public void CopyTo_Then_CopyFrom_OnFullImageRect(TestImageProvider provider, ComponentOrder order) + where TPixel : struct, IPixel { - using (Image src = provider.GetImage()) + using (Image src = provider.GetImage()) { - using (Image dest = new Image(src.Width, src.Height)) + using (Image dest = new Image(src.Width, src.Height)) { - using (PixelArea area = new PixelArea(src.Width, src.Height, order)) + using (PixelArea area = new PixelArea(src.Width, src.Height, order)) { - using (PixelAccessor srcPixels = src.Lock()) + using (PixelAccessor srcPixels = src.Lock()) { srcPixels.CopyTo(area, 0, 0); } - using (PixelAccessor destPixels = dest.Lock()) + using (PixelAccessor destPixels = dest.Lock()) { destPixels.CopyFrom(area, 0, 0); } @@ -69,10 +69,10 @@ namespace ImageSharp.Tests } // TODO: Need a processor in the library with this signature - private static void Fill(Image image, Rectangle region, TColor color) - where TColor : struct, IPixel + private static void Fill(Image image, Rectangle region, TPixel color) + where TPixel : struct, IPixel { - using (PixelAccessor pixels = image.Lock()) + using (PixelAccessor pixels = image.Lock()) { for (int y = region.Top; y < region.Bottom; y++) { @@ -89,21 +89,21 @@ namespace ImageSharp.Tests [WithBlankImages(16, 16, PixelTypes.All, ComponentOrder.Zyx)] [WithBlankImages(16, 16, PixelTypes.All, ComponentOrder.Xyzw)] [WithBlankImages(16, 16, PixelTypes.All, ComponentOrder.Zyxw)] - public void CopyToThenCopyFromWithOffset(TestImageProvider provider, ComponentOrder order) - where TColor : struct, IPixel + public void CopyToThenCopyFromWithOffset(TestImageProvider provider, ComponentOrder order) + where TPixel : struct, IPixel { - using (Image destImage = new Image(8, 8)) + using (Image destImage = new Image(8, 8)) { - using (Image srcImage = provider.GetImage()) + using (Image srcImage = provider.GetImage()) { - Fill(srcImage, new Rectangle(4, 4, 8, 8), NamedColors.Red); - using (PixelAccessor srcPixels = srcImage.Lock()) + Fill(srcImage, new Rectangle(4, 4, 8, 8), NamedColors.Red); + using (PixelAccessor srcPixels = srcImage.Lock()) { - using (PixelArea area = new PixelArea(8, 8, order)) + using (PixelArea area = new PixelArea(8, 8, order)) { srcPixels.CopyTo(area, 4, 4); - using (PixelAccessor destPixels = destImage.Lock()) + using (PixelAccessor destPixels = destImage.Lock()) { destPixels.CopyFrom(area, 0, 0); } @@ -114,7 +114,7 @@ namespace ImageSharp.Tests provider.Utility.SourceFileOrDescription = order.ToString(); provider.Utility.SaveTestOutputFile(destImage, "bmp"); - using (Image expectedImage = new Image(8, 8).Fill(NamedColors.Red)) + using (Image expectedImage = new Image(8, 8).Fill(NamedColors.Red)) { Assert.True(destImage.IsEquivalentTo(expectedImage)); } @@ -158,17 +158,17 @@ namespace ImageSharp.Tests } } - private static void CopyFromZYX(Image image) - where TColor : struct, IPixel + private static void CopyFromZYX(Image image) + where TPixel : struct, IPixel { - using (PixelAccessor pixels = image.Lock()) + using (PixelAccessor pixels = image.Lock()) { byte red = 1; byte green = 2; byte blue = 3; byte alpha = 255; - using (PixelArea row = new PixelArea(1, ComponentOrder.Zyx)) + using (PixelArea row = new PixelArea(1, ComponentOrder.Zyx)) { row.Bytes[0] = blue; row.Bytes[1] = green; @@ -185,17 +185,17 @@ namespace ImageSharp.Tests } } - private static void CopyFromZYXW(Image image) - where TColor : struct, IPixel + private static void CopyFromZYXW(Image image) + where TPixel : struct, IPixel { - using (PixelAccessor pixels = image.Lock()) + using (PixelAccessor pixels = image.Lock()) { byte red = 1; byte green = 2; byte blue = 3; byte alpha = 4; - using (PixelArea row = new PixelArea(1, ComponentOrder.Zyxw)) + using (PixelArea row = new PixelArea(1, ComponentOrder.Zyxw)) { row.Bytes[0] = blue; row.Bytes[1] = green; @@ -213,18 +213,18 @@ namespace ImageSharp.Tests } } - private static void CopyToZYX(Image image) - where TColor : struct, IPixel + private static void CopyToZYX(Image image) + where TPixel : struct, IPixel { - using (PixelAccessor pixels = image.Lock()) + using (PixelAccessor pixels = image.Lock()) { byte red = 1; byte green = 2; byte blue = 3; - using (PixelArea row = new PixelArea(1, ComponentOrder.Zyx)) + using (PixelArea row = new PixelArea(1, ComponentOrder.Zyx)) { - pixels[0, 0] = (TColor)(object)new Rgba32(red, green, blue); + pixels[0, 0] = (TPixel)(object)new Rgba32(red, green, blue); pixels.CopyTo(row, 0); @@ -235,19 +235,19 @@ namespace ImageSharp.Tests } } - private static void CopyToZYXW(Image image) - where TColor : struct, IPixel + private static void CopyToZYXW(Image image) + where TPixel : struct, IPixel { - using (PixelAccessor pixels = image.Lock()) + using (PixelAccessor pixels = image.Lock()) { byte red = 1; byte green = 2; byte blue = 3; byte alpha = 4; - using (PixelArea row = new PixelArea(1, ComponentOrder.Zyxw)) + using (PixelArea row = new PixelArea(1, ComponentOrder.Zyxw)) { - pixels[0, 0] = (TColor)(object)new Rgba32(red, green, blue, alpha); + pixels[0, 0] = (TPixel)(object)new Rgba32(red, green, blue, alpha); pixels.CopyTo(row, 0); diff --git a/tests/ImageSharp.Tests/ImageComparer.cs b/tests/ImageSharp.Tests/ImageComparer.cs index 41b884dd4..37b367931 100644 --- a/tests/ImageSharp.Tests/ImageComparer.cs +++ b/tests/ImageSharp.Tests/ImageComparer.cs @@ -16,8 +16,8 @@ /// /// Does a visual comparison between 2 images and then asserts the difference is less then a configurable threshold /// - /// The color of the expected image - /// The color type fo the the actual image + /// The color of the expected image + /// The color type fo the the actual image /// The expected image /// The actual image /// @@ -32,9 +32,9 @@ /// This is a sampling factor we sample a grid of average pixels width by high /// The default undefined value is /// - public static void CheckSimilarity(Image expected, Image actual, float imageTheshold = DefaultImageThreshold, byte segmentThreshold = DefaultSegmentThreshold, int scalingFactor = DefaultScalingFactor) - where TColorA : struct, IPixel - where TColorB : struct, IPixel + public static void CheckSimilarity(Image expected, Image actual, float imageTheshold = DefaultImageThreshold, byte segmentThreshold = DefaultSegmentThreshold, int scalingFactor = DefaultScalingFactor) + where TPixelA : struct, IPixel + where TPixelB : struct, IPixel { float percentage = expected.PercentageDifference(actual, segmentThreshold, scalingFactor); @@ -44,8 +44,8 @@ /// /// Does a visual comparison between 2 images and then and returns the percentage diffence between the 2 /// - /// The color of the source image - /// The color type for the target image + /// The color of the source image + /// The color type for the target image /// The source image /// The target image /// @@ -57,9 +57,9 @@ /// The default undefined value is /// /// Returns a number from 0 - 1 which represents the diference focter between the images. - public static float PercentageDifference(this Image source, Image target, byte segmentThreshold = DefaultSegmentThreshold, int scalingFactor = DefaultScalingFactor) - where TColorA : struct, IPixel - where TColorB : struct, IPixel + public static float PercentageDifference(this Image source, Image target, byte segmentThreshold = DefaultSegmentThreshold, int scalingFactor = DefaultScalingFactor) + where TPixelA : struct, IPixel + where TPixelB : struct, IPixel { // code adapted from https://www.codeproject.com/Articles/374386/Simple-image-comparison-in-NET Fast2DArray differences = GetDifferences(source, target, scalingFactor); @@ -74,9 +74,9 @@ return diffPixels / (scalingFactor * scalingFactor); } - private static Fast2DArray GetDifferences(Image source, Image target, int scalingFactor) - where TColorA : struct, IPixel - where TColorB : struct, IPixel + private static Fast2DArray GetDifferences(Image source, Image target, int scalingFactor) + where TPixelA : struct, IPixel + where TPixelB : struct, IPixel { Fast2DArray differences = new Fast2DArray(scalingFactor, scalingFactor); Fast2DArray firstGray = source.GetGrayScaleValues(scalingFactor); @@ -93,13 +93,13 @@ return differences; } - private static Fast2DArray GetGrayScaleValues(this Image source, int scalingFactor) - where TColorA : struct, IPixel + private static Fast2DArray GetGrayScaleValues(this Image source, int scalingFactor) + where TPixelA : struct, IPixel { byte[] buffer = new byte[4]; - using (Image img = new Image(source).Resize(scalingFactor, scalingFactor).Grayscale()) + using (Image img = new Image(source).Resize(scalingFactor, scalingFactor).Grayscale()) { - using (PixelAccessor pixels = img.Lock()) + using (PixelAccessor pixels = img.Lock()) { Fast2DArray grayScale = new Fast2DArray(scalingFactor, scalingFactor); for (int y = 0; y < scalingFactor; y++) diff --git a/tests/ImageSharp.Tests/Processors/Filters/GrayscaleTest.cs b/tests/ImageSharp.Tests/Processors/Filters/GrayscaleTest.cs index 97947a787..f4b3c31ef 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/GrayscaleTest.cs +++ b/tests/ImageSharp.Tests/Processors/Filters/GrayscaleTest.cs @@ -20,14 +20,14 @@ namespace ImageSharp.Tests [Theory] [WithTestPatternImages(50, 50, PixelTypes.StandardImageClass, GrayscaleMode.Bt709)] [WithTestPatternImages(50, 50, PixelTypes.StandardImageClass, GrayscaleMode.Bt601)] - public void ImageShouldApplyGrayscaleFilterAll(TestImageProvider provider, GrayscaleMode value) - where TColor : struct, IPixel + public void ImageShouldApplyGrayscaleFilterAll(TestImageProvider provider, GrayscaleMode value) + where TPixel : struct, IPixel { - using (Image image = provider.GetImage()) + using (Image image = provider.GetImage()) { image.Grayscale(value); byte[] data = new byte[3]; - foreach (TColor p in image.Pixels) + foreach (TPixel p in image.Pixels) { p.ToXyzBytes(data, 0); Assert.Equal(data[0], data[1]); diff --git a/tests/ImageSharp.Tests/TestFormat.cs b/tests/ImageSharp.Tests/TestFormat.cs index 084ad5993..3c4edb7b0 100644 --- a/tests/ImageSharp.Tests/TestFormat.cs +++ b/tests/ImageSharp.Tests/TestFormat.cs @@ -68,17 +68,17 @@ namespace ImageSharp.Tests } } - public Image Sample() - where TColor : struct, IPixel + public Image Sample() + where TPixel : struct, IPixel { lock (this._sampleImages) { - if (!this._sampleImages.ContainsKey(typeof(TColor))) + if (!this._sampleImages.ContainsKey(typeof(TPixel))) { - this._sampleImages.Add(typeof(TColor), new Image(1, 1)); + this._sampleImages.Add(typeof(TPixel), new Image(1, 1)); } - return (Image)this._sampleImages[typeof(TColor)]; + return (Image)this._sampleImages[typeof(TPixel)]; } } @@ -149,7 +149,7 @@ namespace ImageSharp.Tests } - public Image Decode(Configuration config, Stream stream, IDecoderOptions options) where TColor : struct, IPixel + public Image Decode(Configuration config, Stream stream, IDecoderOptions options) where TPixel : struct, IPixel { var ms = new MemoryStream(); @@ -163,7 +163,7 @@ namespace ImageSharp.Tests }); // TODO record this happend so we an verify it. - return this.testFormat.Sample(); + return this.testFormat.Sample(); } } @@ -176,7 +176,7 @@ namespace ImageSharp.Tests this.testFormat = testFormat; } - public void Encode(Image image, Stream stream, IEncoderOptions options) where TColor : struct, IPixel + public void Encode(Image image, Stream stream, IEncoderOptions options) where TPixel : struct, IPixel { // TODO record this happend so we an verify it. } diff --git a/tests/ImageSharp.Tests/TestUtilities/Attributes/ImageDataAttributeBase.cs b/tests/ImageSharp.Tests/TestUtilities/Attributes/ImageDataAttributeBase.cs index 206393e27..ffbd1b888 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Attributes/ImageDataAttributeBase.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Attributes/ImageDataAttributeBase.cs @@ -13,7 +13,7 @@ namespace ImageSharp.Tests using Xunit.Sdk; /// - /// Base class for Theory Data attributes which pass an instance of to the test case. + /// Base class for Theory Data attributes which pass an instance of to the test case. /// public abstract class ImageDataAttributeBase : DataAttribute { diff --git a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithBlankImageAttribute.cs b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithBlankImageAttribute.cs index e1f8f4c55..25d3c8cac 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithBlankImageAttribute.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithBlankImageAttribute.cs @@ -9,13 +9,13 @@ namespace ImageSharp.Tests using System.Reflection; /// - /// Triggers passing instances which produce a blank image of size width * height. - /// One instance will be passed for each the pixel format defined by the pixelTypes parameter + /// Triggers passing instances which produce a blank image of size width * height. + /// One instance will be passed for each the pixel format defined by the pixelTypes parameter /// public class WithBlankImagesAttribute : ImageDataAttributeBase { /// - /// Triggers passing an that produces a blank image of size width * height + /// Triggers passing an that produces a blank image of size width * height /// /// The required width /// The required height diff --git a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithFileAttribute.cs b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithFileAttribute.cs index 617a9a237..752c114e5 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithFileAttribute.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithFileAttribute.cs @@ -9,16 +9,16 @@ namespace ImageSharp.Tests using System.Reflection; /// - /// Triggers passing instances which read an image from the given file - /// One instance will be passed for each the pixel format defined by the pixelTypes parameter + /// Triggers passing instances which read an image from the given file + /// One instance will be passed for each the pixel format defined by the pixelTypes parameter /// public class WithFileAttribute : ImageDataAttributeBase { private readonly string fileName; /// - /// Triggers passing instances which read an image from the given file - /// One instance will be passed for each the pixel format defined by the pixelTypes parameter + /// Triggers passing instances which read an image from the given file + /// One instance will be passed for each the pixel format defined by the pixelTypes parameter /// /// The name of the file /// The requested pixel types diff --git a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithFileCollectionAttribute.cs b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithFileCollectionAttribute.cs index be0fa7b3f..3bd93e609 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithFileCollectionAttribute.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithFileCollectionAttribute.cs @@ -11,16 +11,16 @@ namespace ImageSharp.Tests using System.Reflection; /// - /// Triggers passing instances which read an image for each file being enumerated by the (static) test class field/property defined by enumeratorMemberName - /// instances will be passed for each the pixel format defined by the pixelTypes parameter + /// Triggers passing instances which read an image for each file being enumerated by the (static) test class field/property defined by enumeratorMemberName + /// instances will be passed for each the pixel format defined by the pixelTypes parameter /// public class WithFileCollectionAttribute : ImageDataAttributeBase { private readonly string enumeratorMemberName; /// - /// Triggers passing instances which read an image for each file being enumerated by the (static) test class field/property defined by enumeratorMemberName - /// instances will be passed for each the pixel format defined by the pixelTypes parameter + /// Triggers passing instances which read an image for each file being enumerated by the (static) test class field/property defined by enumeratorMemberName + /// instances will be passed for each the pixel format defined by the pixelTypes parameter /// /// The name of the static test class field/property enumerating the files /// The requested pixel types diff --git a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithMemberFactoryAttribute.cs b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithMemberFactoryAttribute.cs index fa5e57dd0..661640f66 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithMemberFactoryAttribute.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithMemberFactoryAttribute.cs @@ -10,17 +10,17 @@ namespace ImageSharp.Tests using System.Reflection; /// - /// Triggers passing instances which return the image produced by the given test class member method - /// instances will be passed for each the pixel format defined by the pixelTypes parameter - /// The parameter of the factory method must be a instance + /// Triggers passing instances which return the image produced by the given test class member method + /// instances will be passed for each the pixel format defined by the pixelTypes parameter + /// The parameter of the factory method must be a instance /// public class WithMemberFactoryAttribute : ImageDataAttributeBase { private readonly string memberMethodName; /// - /// Triggers passing instances which return the image produced by the given test class member method - /// instances will be passed for each the pixel format defined by the pixelTypes parameter + /// Triggers passing instances which return the image produced by the given test class member method + /// instances will be passed for each the pixel format defined by the pixelTypes parameter /// /// The name of the static test class which returns the image /// The requested pixel types diff --git a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithSolidFilledImagesAttribute.cs b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithSolidFilledImagesAttribute.cs index d225f8a77..9a8538e78 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithSolidFilledImagesAttribute.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithSolidFilledImagesAttribute.cs @@ -9,14 +9,14 @@ namespace ImageSharp.Tests using System.Reflection; /// - /// Triggers passing instances which produce an image of size width * height filled with the requested color. - /// One instance will be passed for each the pixel format defined by the pixelTypes parameter + /// Triggers passing instances which produce an image of size width * height filled with the requested color. + /// One instance will be passed for each the pixel format defined by the pixelTypes parameter /// public class WithSolidFilledImagesAttribute : WithBlankImagesAttribute { /// - /// Triggers passing instances which produce an image of size width * height filled with the requested color. - /// One instance will be passed for each the pixel format defined by the pixelTypes parameter + /// Triggers passing instances which produce an image of size width * height filled with the requested color. + /// One instance will be passed for each the pixel format defined by the pixelTypes parameter /// /// The width of the requested image /// The height of the requested image @@ -38,8 +38,8 @@ namespace ImageSharp.Tests } /// - /// Triggers passing instances which produce an image of size width * height filled with the requested color. - /// One instance will be passed for each the pixel format defined by the pixelTypes parameter + /// Triggers passing instances which produce an image of size width * height filled with the requested color. + /// One instance will be passed for each the pixel format defined by the pixelTypes parameter /// /// The width of the requested image /// The height of the requested image diff --git a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithTestPatternImageAttribute.cs b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithTestPatternImageAttribute.cs index 98bc45f5b..f2d2aeb88 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithTestPatternImageAttribute.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithTestPatternImageAttribute.cs @@ -9,13 +9,13 @@ namespace ImageSharp.Tests using System.Reflection; /// - /// Triggers passing instances which produce a blank image of size width * height. - /// One instance will be passed for each the pixel format defined by the pixelTypes parameter + /// Triggers passing instances which produce a blank image of size width * height. + /// One instance will be passed for each the pixel format defined by the pixelTypes parameter /// public class WithTestPatternImagesAttribute : ImageDataAttributeBase { /// - /// Triggers passing an that produces a test pattern image of size width * height + /// Triggers passing an that produces a test pattern image of size width * height /// /// The required width /// The required height diff --git a/tests/ImageSharp.Tests/TestUtilities/Factories/GenericFactory.cs b/tests/ImageSharp.Tests/TestUtilities/Factories/GenericFactory.cs index c2fe0dc5c..2791c25b1 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Factories/GenericFactory.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Factories/GenericFactory.cs @@ -11,22 +11,22 @@ namespace ImageSharp.Tests /// Utility class to create specialized subclasses of generic classes (eg. ) /// Used as parameter for -based factory methods /// - public class GenericFactory - where TColor : struct, IPixel + public class GenericFactory + where TPixel : struct, IPixel { - public virtual Image CreateImage(int width, int height) + public virtual Image CreateImage(int width, int height) { - return new Image(width, height); + return new Image(width, height); } - public virtual Image CreateImage(byte[] bytes) + public virtual Image CreateImage(byte[] bytes) { - return Image.Load(bytes); + return Image.Load(bytes); } - public virtual Image CreateImage(Image other) + public virtual Image CreateImage(Image other) { - return new Image(other); + return new Image(other); } } } \ No newline at end of file diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BlankProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BlankProvider.cs index 6dc0d89c5..e7512cb2d 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BlankProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BlankProvider.cs @@ -8,10 +8,10 @@ namespace ImageSharp.Tests using System; using Xunit.Abstractions; - public abstract partial class TestImageProvider - where TColor : struct, IPixel + public abstract partial class TestImageProvider + where TPixel : struct, IPixel { - private class BlankProvider : TestImageProvider, IXunitSerializable + private class BlankProvider : TestImageProvider, IXunitSerializable { public BlankProvider(int width, int height) { @@ -30,7 +30,7 @@ namespace ImageSharp.Tests protected int Width { get; private set; } - public override Image GetImage() => this.Factory.CreateImage(this.Width, this.Height); + public override Image GetImage() => this.Factory.CreateImage(this.Width, this.Height); public override void Deserialize(IXunitSerializationInfo info) diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs index bc18209f3..1b7bbe4e7 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs @@ -9,12 +9,12 @@ namespace ImageSharp.Tests using System.Collections.Concurrent; using Xunit.Abstractions; - public abstract partial class TestImageProvider - where TColor : struct, IPixel + public abstract partial class TestImageProvider + where TPixel : struct, IPixel { - private class FileProvider : TestImageProvider, IXunitSerializable + private class FileProvider : TestImageProvider, IXunitSerializable { - // Need PixelTypes in the dictionary key, because result images of TestImageProvider.FileProvider + // Need PixelTypes in the dictionary key, because result images of TestImageProvider.FileProvider // are shared between PixelTypes.Color & PixelTypes.StandardImageClass private class Key : Tuple { @@ -24,8 +24,8 @@ namespace ImageSharp.Tests } } - private static ConcurrentDictionary> cache = - new ConcurrentDictionary>(); + private static ConcurrentDictionary> cache = + new ConcurrentDictionary>(); private string filePath; @@ -40,11 +40,11 @@ namespace ImageSharp.Tests public override string SourceFileOrDescription => this.filePath; - public override Image GetImage() + public override Image GetImage() { Key key = new Key(this.PixelType, this.filePath); - Image cachedImage = cache.GetOrAdd( + Image cachedImage = cache.GetOrAdd( key, fn => { diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/LambdaProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/LambdaProvider.cs index 9addc8ca6..8739d556d 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/LambdaProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/LambdaProvider.cs @@ -8,22 +8,22 @@ namespace ImageSharp.Tests using System; /// - /// Provides instances for parametric unit tests. + /// Provides instances for parametric unit tests. /// - /// The pixel format of the image - public abstract partial class TestImageProvider - where TColor : struct, IPixel + /// The pixel format of the image + public abstract partial class TestImageProvider + where TPixel : struct, IPixel { - private class LambdaProvider : TestImageProvider + private class LambdaProvider : TestImageProvider { - private readonly Func, Image> creator; + private readonly Func, Image> creator; - public LambdaProvider(Func, Image> creator) + public LambdaProvider(Func, Image> creator) { this.creator = creator; } - public override Image GetImage() => this.creator(this.Factory); + public override Image GetImage() => this.creator(this.Factory); } } } \ No newline at end of file diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs index 9a6750872..c2c903e9e 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs @@ -9,11 +9,11 @@ namespace ImageSharp.Tests using Xunit.Abstractions; /// - /// Provides instances for parametric unit tests. + /// Provides instances for parametric unit tests. /// - /// The pixel format of the image - public abstract partial class TestImageProvider - where TColor : struct, IPixel + /// The pixel format of the image + public abstract partial class TestImageProvider + where TPixel : struct, IPixel { private class SolidProvider : BlankProvider { @@ -46,10 +46,10 @@ namespace ImageSharp.Tests public override string SourceFileOrDescription => $"Solid{this.Width}x{this.Height}_({this.r},{this.g},{this.b},{this.a})"; - public override Image GetImage() + public override Image GetImage() { - Image image = base.GetImage(); - TColor color = default(TColor); + Image image = base.GetImage(); + TPixel color = default(TPixel); color.PackFromBytes(this.r, this.g, this.b, this.a); return image.Fill(color); diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs index 26192ba1e..643e70617 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs @@ -10,13 +10,13 @@ namespace ImageSharp.Tests using Xunit.Abstractions; /// - /// Provides instances for parametric unit tests. + /// Provides instances for parametric unit tests. /// - /// The pixel format of the image - public abstract partial class TestImageProvider - where TColor : struct, IPixel + /// The pixel format of the image + public abstract partial class TestImageProvider + where TPixel : struct, IPixel { - public PixelTypes PixelType { get; private set; } = typeof(TColor).GetPixelType(); + public PixelTypes PixelType { get; private set; } = typeof(TPixel).GetPixelType(); public virtual string SourceFileOrDescription => ""; @@ -25,25 +25,25 @@ namespace ImageSharp.Tests /// public ImagingTestCaseUtility Utility { get; private set; } - public GenericFactory Factory { get; private set; } = new GenericFactory(); + public GenericFactory Factory { get; private set; } = new GenericFactory(); public string TypeName { get; private set; } public string MethodName { get; private set; } - public static TestImageProvider TestPattern( + public static TestImageProvider TestPattern( int width, int height, MethodInfo testMethod = null, PixelTypes pixelTypeOverride = PixelTypes.Undefined) => new TestPatternProvider(width, height).Init(testMethod, pixelTypeOverride); - public static TestImageProvider Blank( + public static TestImageProvider Blank( int width, int height, MethodInfo testMethod = null, PixelTypes pixelTypeOverride = PixelTypes.Undefined) => new BlankProvider(width, height).Init(testMethod, pixelTypeOverride); - public static TestImageProvider File( + public static TestImageProvider File( string filePath, MethodInfo testMethod = null, PixelTypes pixelTypeOverride = PixelTypes.Undefined) @@ -51,13 +51,13 @@ namespace ImageSharp.Tests return new FileProvider(filePath).Init(testMethod, pixelTypeOverride); } - public static TestImageProvider Lambda( - Func, Image> func, + public static TestImageProvider Lambda( + Func, Image> func, MethodInfo testMethod = null, PixelTypes pixelTypeOverride = PixelTypes.Undefined) => new LambdaProvider(func).Init(testMethod, pixelTypeOverride); - public static TestImageProvider Solid( + public static TestImageProvider Solid( int width, int height, byte r, @@ -71,9 +71,9 @@ namespace ImageSharp.Tests } /// - /// Returns an instance to the test case with the necessary traits. + /// Returns an instance to the test case with the necessary traits. /// - public abstract Image GetImage(); + public abstract Image GetImage(); public virtual void Deserialize(IXunitSerializationInfo info) { @@ -91,7 +91,7 @@ namespace ImageSharp.Tests info.AddValue("MethodName", this.MethodName); } - protected TestImageProvider Init(string typeName, string methodName, PixelTypes pixelTypeOverride) + protected TestImageProvider Init(string typeName, string methodName, PixelTypes pixelTypeOverride) { if (pixelTypeOverride != PixelTypes.Undefined) { @@ -102,7 +102,7 @@ namespace ImageSharp.Tests if (pixelTypeOverride == PixelTypes.StandardImageClass) { - this.Factory = new ImageFactory() as GenericFactory; + this.Factory = new ImageFactory() as GenericFactory; } this.Utility = new ImagingTestCaseUtility() @@ -119,7 +119,7 @@ namespace ImageSharp.Tests return this; } - protected TestImageProvider Init(MethodInfo testMethod, PixelTypes pixelTypeOverride) + protected TestImageProvider Init(MethodInfo testMethod, PixelTypes pixelTypeOverride) { return Init(testMethod?.DeclaringType.Name, testMethod?.Name, pixelTypeOverride); } diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs index 518c45a45..fb30e7fe4 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs @@ -10,17 +10,17 @@ namespace ImageSharp.Tests using System.Numerics; using Xunit.Abstractions; - public abstract partial class TestImageProvider - where TColor : struct, IPixel + public abstract partial class TestImageProvider + where TPixel : struct, IPixel { /// /// A test image provider that produces test patterns. /// - /// + /// private class TestPatternProvider : BlankProvider { - static Dictionary> testImages = new Dictionary>(); + static Dictionary> testImages = new Dictionary>(); public TestPatternProvider(int width, int height) : base(width, height) @@ -34,29 +34,29 @@ namespace ImageSharp.Tests public override string SourceFileOrDescription => $"TestPattern{this.Width}x{this.Height}"; - public override Image GetImage() + public override Image GetImage() { lock (testImages) { if (!testImages.ContainsKey(this.SourceFileOrDescription)) { - Image image = new Image(this.Width, this.Height); + Image image = new Image(this.Width, this.Height); DrawTestPattern(image); testImages.Add(this.SourceFileOrDescription, image); } } - return new Image(testImages[this.SourceFileOrDescription]); + return new Image(testImages[this.SourceFileOrDescription]); } /// /// Draws the test pattern on an image by drawing 4 other patterns in the for quadrants of the image. /// /// - private static void DrawTestPattern(Image image) + private static void DrawTestPattern(Image image) { // first lets split the image into 4 quadrants - using (PixelAccessor pixels = image.Lock()) + using (PixelAccessor pixels = image.Lock()) { BlackWhiteChecker(pixels); // top left VirticalBars(pixels); // top right @@ -68,7 +68,7 @@ namespace ImageSharp.Tests /// Fills the top right quadrant with alternating solid vertical bars. /// /// - private static void VirticalBars(PixelAccessor pixels) + private static void VirticalBars(PixelAccessor pixels) { // topLeft int left = pixels.Width / 2; @@ -76,9 +76,9 @@ namespace ImageSharp.Tests int top = 0; int bottom = pixels.Height / 2; int stride = pixels.Width / 12; - TColor[] c = { - NamedColors.HotPink, - NamedColors.Blue + TPixel[] c = { + NamedColors.HotPink, + NamedColors.Blue }; int p = 0; for (int y = top; y < bottom; y++) @@ -99,7 +99,7 @@ namespace ImageSharp.Tests /// fills the top left quadrant with a black and white checker board. /// /// - private static void BlackWhiteChecker(PixelAccessor pixels) + private static void BlackWhiteChecker(PixelAccessor pixels) { // topLeft int left = 0; @@ -107,9 +107,9 @@ namespace ImageSharp.Tests int top = 0; int bottom = pixels.Height / 2; int stride = pixels.Width / 6; - TColor[] c = { - NamedColors.Black, - NamedColors.White + TPixel[] c = { + NamedColors.Black, + NamedColors.White }; int p = 0; @@ -138,7 +138,7 @@ namespace ImageSharp.Tests /// Fills the bottom left quadrent with 3 horizental bars in Red, Green and Blue with a alpha gradient from left (transparent) to right (solid). /// /// - private static void TransparentGradients(PixelAccessor pixels) + private static void TransparentGradients(PixelAccessor pixels) { // topLeft int left = 0; @@ -151,7 +151,7 @@ namespace ImageSharp.Tests Vector4 green = Rgba32.Green.ToVector4(); // use real color so we can see har it translates in the test pattern Vector4 blue = Rgba32.Blue.ToVector4(); // use real color so we can see har it translates in the test pattern - TColor c = default(TColor); + TPixel c = default(TPixel); for (int x = left; x < right; x++) { @@ -183,7 +183,7 @@ namespace ImageSharp.Tests /// A better algorithm could be used but it works /// /// - private static void Rainbow(PixelAccessor pixels) + private static void Rainbow(PixelAccessor pixels) { int left = pixels.Width / 2; int right = pixels.Width; @@ -192,7 +192,7 @@ namespace ImageSharp.Tests int pixelCount = left * top; uint stepsPerPixel = (uint)(uint.MaxValue / pixelCount); - TColor c = default(TColor); + TPixel c = default(TPixel); Rgba32 t = new Rgba32(0); for (int x = left; x < right; x++) diff --git a/tests/ImageSharp.Tests/TestUtilities/ImagingTestCaseUtility.cs b/tests/ImageSharp.Tests/TestUtilities/ImagingTestCaseUtility.cs index 9fd33d90b..43a19040a 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImagingTestCaseUtility.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImagingTestCaseUtility.cs @@ -19,12 +19,12 @@ namespace ImageSharp.Tests public class ImagingTestCaseUtility : TestBase { /// - /// Name of the TColor in the owner + /// Name of the TPixel in the owner /// public string PixelTypeName { get; set; } = string.Empty; /// - /// The name of the file which is provided by + /// The name of the file which is provided by /// Or a short string describing the image in the case of a non-file based image provider. /// public string SourceFileOrDescription { get; set; } = string.Empty; @@ -91,13 +91,13 @@ namespace ImageSharp.Tests /// /// Encodes image by the format matching the required extension, than saves it to the recommended output file. /// - /// The pixel format of the image + /// The pixel format of the image /// The image instance /// The requested extension /// Optional encoder /// Optional encoder options - public void SaveTestOutputFile(Image image, string extension = null, IImageEncoder encoder = null, IEncoderOptions options = null) - where TColor : struct, IPixel + public void SaveTestOutputFile(Image image, string extension = null, IImageEncoder encoder = null, IEncoderOptions options = null) + where TPixel : struct, IPixel { string path = this.GetTestOutputFileName(extension); extension = Path.GetExtension(path); diff --git a/tests/ImageSharp.Tests/TestUtilities/PixelTypes.cs b/tests/ImageSharp.Tests/TestUtilities/PixelTypes.cs index 88d67f66a..77c13f125 100644 --- a/tests/ImageSharp.Tests/TestUtilities/PixelTypes.cs +++ b/tests/ImageSharp.Tests/TestUtilities/PixelTypes.cs @@ -9,7 +9,7 @@ namespace ImageSharp.Tests /// /// Flags that are mapped to PackedPixel types. - /// They trigger the desired parametrization for . + /// They trigger the desired parametrization for . /// [Flags] public enum PixelTypes : uint @@ -53,7 +53,7 @@ namespace ImageSharp.Tests Short4 = 1 << 17, /// - /// Triggers instantiating the subclass of + /// Triggers instantiating the subclass of /// StandardImageClass = 1 << 29, diff --git a/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs b/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs index e2bc2bd2d..2a7ea352b 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs @@ -7,8 +7,8 @@ namespace ImageSharp.Tests public static class TestImageExtensions { - public static void DebugSave(this Image img, TestImageProvider provider, string extension = "png") - where TColor : struct, IPixel + public static void DebugSave(this Image img, TestImageProvider provider, string extension = "png") + where TPixel : struct, IPixel { if(!bool.TryParse(Environment.GetEnvironmentVariable("CI"), out bool isCI) || !isCI) { diff --git a/tests/ImageSharp.Tests/TestUtilities/TestUtilityExtensions.cs b/tests/ImageSharp.Tests/TestUtilities/TestUtilityExtensions.cs index a0e92cf8f..2f28896b3 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestUtilityExtensions.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestUtilityExtensions.cs @@ -47,8 +47,8 @@ namespace ImageSharp.Tests public static bool HasFlag(this PixelTypes pixelTypes, PixelTypes flag) => (pixelTypes & flag) == flag; - public static bool IsEquivalentTo(this Image a, Image b, bool compareAlpha = true) - where TColor : struct, IPixel + public static bool IsEquivalentTo(this Image a, Image b, bool compareAlpha = true) + where TPixel : struct, IPixel { if (a.Width != b.Width || a.Height != b.Height) { @@ -58,16 +58,16 @@ namespace ImageSharp.Tests byte[] bytesA = new byte[3]; byte[] bytesB = new byte[3]; - using (PixelAccessor pixA = a.Lock()) + using (PixelAccessor pixA = a.Lock()) { - using (PixelAccessor pixB = b.Lock()) + using (PixelAccessor pixB = b.Lock()) { for (int y = 0; y < a.Height; y++) { for (int x = 0; x < a.Width; x++) { - TColor ca = pixA[x, y]; - TColor cb = pixB[x, y]; + TPixel ca = pixA[x, y]; + TPixel cb = pixB[x, y]; if (compareAlpha) { diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs index 815d46ffc..0f4025ee4 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs @@ -21,10 +21,10 @@ namespace ImageSharp.Tests [Theory] [WithBlankImages(42, 666, PixelTypes.Rgba32 | PixelTypes.Argb32 | PixelTypes.HalfSingle, "hello")] - public void Use_WithEmptyImageAttribute(TestImageProvider provider, string message) - where TColor : struct, IPixel + public void Use_WithEmptyImageAttribute(TestImageProvider provider, string message) + where TPixel : struct, IPixel { - Image img = provider.GetImage(); + Image img = provider.GetImage(); Assert.Equal(42, img.Width); Assert.Equal(666, img.Height); @@ -33,12 +33,12 @@ namespace ImageSharp.Tests [Theory] [WithBlankImages(42, 666, PixelTypes.All, "hello")] - public void Use_WithBlankImagesAttribute_WithAllPixelTypes( - TestImageProvider provider, + public void Use_WithBlankImagesAttribute_WithAllPixelTypes( + TestImageProvider provider, string message) - where TColor : struct, IPixel + where TPixel : struct, IPixel { - Image img = provider.GetImage(); + Image img = provider.GetImage(); Assert.Equal(42, img.Width); Assert.Equal(666, img.Height); @@ -49,8 +49,8 @@ namespace ImageSharp.Tests [WithBlankImages(1, 1, PixelTypes.Rgba32, PixelTypes.Rgba32)] [WithBlankImages(1, 1, PixelTypes.Alpha8, PixelTypes.Alpha8)] [WithBlankImages(1, 1, PixelTypes.StandardImageClass, PixelTypes.StandardImageClass)] - public void PixelType_PropertyValueIsCorrect(TestImageProvider provider, PixelTypes expected) - where TColor : struct, IPixel + public void PixelType_PropertyValueIsCorrect(TestImageProvider provider, PixelTypes expected) + where TPixel : struct, IPixel { Assert.Equal(expected, provider.PixelType); } @@ -58,11 +58,11 @@ namespace ImageSharp.Tests [Theory] [WithBlankImages(1, 1, PixelTypes.StandardImageClass)] [WithFile(TestImages.Bmp.F, PixelTypes.StandardImageClass)] - public void PixelTypes_ColorWithDefaultImageClass_TriggersCreatingTheNonGenericDerivedImageClass( - TestImageProvider provider) - where TColor : struct, IPixel + public void PixelTypes_ColorWithDefaultImageClass_TriggersCreatingTheNonGenericDerivedImageClass( + TestImageProvider provider) + where TPixel : struct, IPixel { - Image img = provider.GetImage(); + Image img = provider.GetImage(); Assert.IsType(img); } @@ -70,11 +70,11 @@ namespace ImageSharp.Tests [Theory] [WithFile(TestImages.Bmp.Car, PixelTypes.All, 88)] [WithFile(TestImages.Bmp.F, PixelTypes.All, 88)] - public void Use_WithFileAttribute(TestImageProvider provider, int yo) - where TColor : struct, IPixel + public void Use_WithFileAttribute(TestImageProvider provider, int yo) + where TPixel : struct, IPixel { Assert.NotNull(provider.Utility.SourceFileOrDescription); - Image img = provider.GetImage(); + Image img = provider.GetImage(); Assert.True(img.Width * img.Height > 0); Assert.Equal(88, yo); @@ -87,26 +87,26 @@ namespace ImageSharp.Tests [Theory] [WithFileCollection(nameof(AllBmpFiles), PixelTypes.Rgba32 | PixelTypes.Argb32)] - public void Use_WithFileCollection(TestImageProvider provider) - where TColor : struct, IPixel + public void Use_WithFileCollection(TestImageProvider provider) + where TPixel : struct, IPixel { Assert.NotNull(provider.Utility.SourceFileOrDescription); - Image image = provider.GetImage(); + Image image = provider.GetImage(); provider.Utility.SaveTestOutputFile(image, "png"); } [Theory] [WithSolidFilledImages(10, 20, 255, 100, 50, 200, PixelTypes.Rgba32 | PixelTypes.Argb32)] - public void Use_WithSolidFilledImagesAttribute(TestImageProvider provider) - where TColor : struct, IPixel + public void Use_WithSolidFilledImagesAttribute(TestImageProvider provider) + where TPixel : struct, IPixel { - Image img = provider.GetImage(); + Image img = provider.GetImage(); Assert.Equal(img.Width, 10); Assert.Equal(img.Height, 20); byte[] colors = new byte[4]; - using (PixelAccessor pixels = img.Lock()) + using (PixelAccessor pixels = img.Lock()) { for (int y = 0; y < pixels.Height; y++) { @@ -124,23 +124,23 @@ namespace ImageSharp.Tests } /// - /// Need to us to create instance of when pixelType is StandardImageClass + /// Need to us to create instance of when pixelType is StandardImageClass /// - /// + /// /// /// - public static Image CreateTestImage(GenericFactory factory) - where TColor : struct, IPixel + public static Image CreateTestImage(GenericFactory factory) + where TPixel : struct, IPixel { return factory.CreateImage(3, 3); } [Theory] [WithMemberFactory(nameof(CreateTestImage), PixelTypes.All)] - public void Use_WithMemberFactoryAttribute(TestImageProvider provider) - where TColor : struct, IPixel + public void Use_WithMemberFactoryAttribute(TestImageProvider provider) + where TPixel : struct, IPixel { - Image img = provider.GetImage(); + Image img = provider.GetImage(); Assert.Equal(img.Width, 3); if (provider.PixelType == PixelTypes.StandardImageClass) { @@ -159,10 +159,10 @@ namespace ImageSharp.Tests [Theory] [MemberData(nameof(BasicData))] - public void Blank_MemberData(TestImageProvider provider) - where TColor : struct, IPixel + public void Blank_MemberData(TestImageProvider provider) + where TPixel : struct, IPixel { - Image img = provider.GetImage(); + Image img = provider.GetImage(); Assert.True(img.Width * img.Height > 0); } @@ -177,13 +177,13 @@ namespace ImageSharp.Tests [Theory] [MemberData(nameof(FileData))] - public void File_MemberData(TestImageProvider provider) - where TColor : struct, IPixel + public void File_MemberData(TestImageProvider provider) + where TPixel : struct, IPixel { this.Output.WriteLine("SRC: " + provider.Utility.SourceFileOrDescription); this.Output.WriteLine("OUT: " + provider.Utility.GetTestOutputFileName()); - Image img = provider.GetImage(); + Image img = provider.GetImage(); Assert.True(img.Width * img.Height > 0); } diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs index 3ad4507df..f47123ef7 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs @@ -23,12 +23,12 @@ namespace ImageSharp.Tests private ITestOutputHelper Output { get; } - public static Image CreateTestImage(GenericFactory factory) - where TColor : struct, IPixel + public static Image CreateTestImage(GenericFactory factory) + where TPixel : struct, IPixel { - Image image = factory.CreateImage(10, 10); + Image image = factory.CreateImage(10, 10); - using (PixelAccessor pixels = image.Lock()) + using (PixelAccessor pixels = image.Lock()) { for (int i = 0; i < 10; i++) { @@ -37,7 +37,7 @@ namespace ImageSharp.Tests Vector4 v = new Vector4(i, j, 0, 1); v /= 10; - TColor color = default(TColor); + TPixel color = default(TPixel); color.PackFromVector4(v); pixels[i, j] = color; @@ -61,11 +61,11 @@ namespace ImageSharp.Tests [Theory] [WithFile(TestImages.Bmp.Car, PixelTypes.Rgba32, true)] [WithFile(TestImages.Bmp.Car, PixelTypes.Rgba32, false)] - public void IsEquivalentTo_WhenFalse(TestImageProvider provider, bool compareAlpha) - where TColor : struct, IPixel + public void IsEquivalentTo_WhenFalse(TestImageProvider provider, bool compareAlpha) + where TPixel : struct, IPixel { - Image a = provider.GetImage(); - Image b = provider.GetImage(); + Image a = provider.GetImage(); + Image b = provider.GetImage(); b = b.OilPaint(3, 2); Assert.False(a.IsEquivalentTo(b, compareAlpha)); @@ -74,11 +74,11 @@ namespace ImageSharp.Tests [Theory] [WithMemberFactory(nameof(CreateTestImage), PixelTypes.Rgba32 | PixelTypes.Bgr565, true)] [WithMemberFactory(nameof(CreateTestImage), PixelTypes.Rgba32 | PixelTypes.Bgr565, false)] - public void IsEquivalentTo_WhenTrue(TestImageProvider provider, bool compareAlpha) - where TColor : struct, IPixel + public void IsEquivalentTo_WhenTrue(TestImageProvider provider, bool compareAlpha) + where TPixel : struct, IPixel { - Image a = provider.GetImage(); - Image b = provider.GetImage(); + Image a = provider.GetImage(); + Image b = provider.GetImage(); Assert.True(a.IsEquivalentTo(b, compareAlpha)); }