diff --git a/src/ImageSharp/Drawing/Brushes/IBrush.cs b/src/ImageSharp/Drawing/Brushes/IBrush.cs index 0f090ebbb..1eea302a5 100644 --- a/src/ImageSharp/Drawing/Brushes/IBrush.cs +++ b/src/ImageSharp/Drawing/Brushes/IBrush.cs @@ -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 /// - IBrushApplicator CreateApplicator(IReadonlyPixelAccessor pixelSource, RectangleF region); + IBrushApplicator 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{TColor}.cs index c8a601bbf..5daf03b93 100644 --- a/src/ImageSharp/Drawing/Brushes/ImageBrush{TColor}.cs +++ b/src/ImageSharp/Drawing/Brushes/ImageBrush{TColor}.cs @@ -32,7 +32,7 @@ namespace ImageSharp.Drawing.Brushes } /// - public IBrushApplicator CreateApplicator(IReadonlyPixelAccessor sourcePixels, RectangleF region) + public IBrushApplicator CreateApplicator(PixelAccessor sourcePixels, RectangleF region) { return new ImageBrushApplicator(this.image, region); } diff --git a/src/ImageSharp/Drawing/Brushes/PatternBrush{TColor}.cs b/src/ImageSharp/Drawing/Brushes/PatternBrush{TColor}.cs index 6373b51ad..76b11236a 100644 --- a/src/ImageSharp/Drawing/Brushes/PatternBrush{TColor}.cs +++ b/src/ImageSharp/Drawing/Brushes/PatternBrush{TColor}.cs @@ -95,7 +95,7 @@ namespace ImageSharp.Drawing.Brushes } /// - public IBrushApplicator CreateApplicator(IReadonlyPixelAccessor sourcePixels, RectangleF region) + public IBrushApplicator CreateApplicator(PixelAccessor sourcePixels, RectangleF region) { return new PatternBrushApplicator(this.pattern, this.stride); } diff --git a/src/ImageSharp/Drawing/Brushes/RecolorBrush{TColor}.cs b/src/ImageSharp/Drawing/Brushes/RecolorBrush{TColor}.cs index 09db4eaf0..534317aff 100644 --- a/src/ImageSharp/Drawing/Brushes/RecolorBrush{TColor}.cs +++ b/src/ImageSharp/Drawing/Brushes/RecolorBrush{TColor}.cs @@ -55,7 +55,7 @@ namespace ImageSharp.Drawing.Brushes public TColor TargetColor { get; } /// - public IBrushApplicator CreateApplicator(IReadonlyPixelAccessor sourcePixels, RectangleF region) + public IBrushApplicator CreateApplicator(PixelAccessor sourcePixels, RectangleF region) { return new RecolorBrushApplicator(sourcePixels, this.SourceColor, this.TargetColor, this.Threashold); } @@ -68,7 +68,7 @@ namespace ImageSharp.Drawing.Brushes /// /// The source pixel accessor. /// - private readonly IReadonlyPixelAccessor source; + private readonly PixelAccessor source; private readonly Vector4 sourceColor; private readonly Vector4 targetColor; private readonly float threashold; @@ -81,7 +81,7 @@ namespace ImageSharp.Drawing.Brushes /// Color of the source. /// Color of the target. /// The threashold . - public RecolorBrushApplicator(IReadonlyPixelAccessor sourcePixels, TColor sourceColor, TColor targetColor, float threashold) + public RecolorBrushApplicator(PixelAccessor sourcePixels, TColor sourceColor, TColor targetColor, float threashold) { this.source = sourcePixels; this.sourceColor = sourceColor.ToVector4(); diff --git a/src/ImageSharp/Drawing/Brushes/SolidBrush{TColor}.cs b/src/ImageSharp/Drawing/Brushes/SolidBrush{TColor}.cs index 2c277b5a7..ac3986bba 100644 --- a/src/ImageSharp/Drawing/Brushes/SolidBrush{TColor}.cs +++ b/src/ImageSharp/Drawing/Brushes/SolidBrush{TColor}.cs @@ -40,7 +40,7 @@ namespace ImageSharp.Drawing.Brushes public TColor Color => this.color; /// - public IBrushApplicator CreateApplicator(IReadonlyPixelAccessor sourcePixels, RectangleF region) + public IBrushApplicator CreateApplicator(PixelAccessor sourcePixels, RectangleF region) { return new SolidBrushApplicator(this.color); } diff --git a/src/ImageSharp/Drawing/Pens/IPen.cs b/src/ImageSharp/Drawing/Pens/IPen.cs index 8b23c1f0f..46b4a2c9d 100644 --- a/src/ImageSharp/Drawing/Pens/IPen.cs +++ b/src/ImageSharp/Drawing/Pens/IPen.cs @@ -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. /// - IPenApplicator CreateApplicator(IReadonlyPixelAccessor pixelSource, RectangleF region); + IPenApplicator CreateApplicator(PixelAccessor pixelSource, RectangleF region); } } diff --git a/src/ImageSharp/Drawing/Pens/Pen{TColor}.cs b/src/ImageSharp/Drawing/Pens/Pen{TColor}.cs index d674b1a56..e9009f3cb 100644 --- a/src/ImageSharp/Drawing/Pens/Pen{TColor}.cs +++ b/src/ImageSharp/Drawing/Pens/Pen{TColor}.cs @@ -112,7 +112,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 IPenApplicator CreateApplicator(IReadonlyPixelAccessor sourcePixels, RectangleF region) + public IPenApplicator CreateApplicator(PixelAccessor sourcePixels, RectangleF region) { if (this.pattern == null || this.pattern.Length < 2) { @@ -129,7 +129,7 @@ namespace ImageSharp.Drawing.Pens private readonly IBrushApplicator brush; private readonly float halfWidth; - public SolidPenApplicator(IReadonlyPixelAccessor 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; @@ -172,7 +172,7 @@ namespace ImageSharp.Drawing.Pens private readonly float[] pattern; private readonly float totalLength; - public PatternPenApplicator(IReadonlyPixelAccessor 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; diff --git a/src/ImageSharp/Image/IReadonlyPixelAccessor{TColor}.cs b/src/ImageSharp/Image/IReadonlyPixelAccessor{TColor}.cs deleted file mode 100644 index dbe17603a..000000000 --- a/src/ImageSharp/Image/IReadonlyPixelAccessor{TColor}.cs +++ /dev/null @@ -1,50 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp -{ - using System; - using System.Diagnostics; - using System.Runtime.CompilerServices; - using System.Runtime.InteropServices; - - /// - /// Provides per-pixel readonly access to generic pixels. - /// - /// The pixel format. - public interface IReadonlyPixelAccessor - { - /// - /// Gets the size of a single pixel in the number of bytes. - /// - int PixelSize { get; } - - /// - /// Gets the width of one row in the number of bytes. - /// - int RowStride { get; } - - /// - /// Gets the width of the image. - /// - int Width { get; } - - /// - /// Gets the height of the image. - /// - int Height { get; } - - /// - /// Gets or sets the pixel at the specified position. - /// - /// The x-coordinate of the pixel. Must be greater than zero and smaller than the width of the pixel. - /// The y-coordinate of the pixel. Must be greater than zero and smaller than the width of the pixel. - /// The at the specified position. - TColor this[int x, int y] - { - get; - } - } -} \ No newline at end of file diff --git a/src/ImageSharp/Image/PixelAccessor{TColor}.cs b/src/ImageSharp/Image/PixelAccessor{TColor}.cs index 8ce780563..3642d3942 100644 --- a/src/ImageSharp/Image/PixelAccessor{TColor}.cs +++ b/src/ImageSharp/Image/PixelAccessor{TColor}.cs @@ -14,7 +14,7 @@ namespace ImageSharp /// Provides per-pixel access to generic pixels. /// /// The pixel format. - public unsafe class PixelAccessor : IReadonlyPixelAccessor, IDisposable + public unsafe class PixelAccessor : IDisposable where TColor : struct, IPackedPixel, IEquatable { ///