Browse Source

Drop IReadonlyPixelAccessor

af/merge-core
Scott Williams 9 years ago
parent
commit
9f9af49711
  1. 2
      src/ImageSharp/Drawing/Brushes/IBrush.cs
  2. 2
      src/ImageSharp/Drawing/Brushes/ImageBrush{TColor}.cs
  3. 2
      src/ImageSharp/Drawing/Brushes/PatternBrush{TColor}.cs
  4. 6
      src/ImageSharp/Drawing/Brushes/RecolorBrush{TColor}.cs
  5. 2
      src/ImageSharp/Drawing/Brushes/SolidBrush{TColor}.cs
  6. 2
      src/ImageSharp/Drawing/Pens/IPen.cs
  7. 6
      src/ImageSharp/Drawing/Pens/Pen{TColor}.cs
  8. 50
      src/ImageSharp/Image/IReadonlyPixelAccessor{TColor}.cs
  9. 2
      src/ImageSharp/Image/PixelAccessor{TColor}.cs

2
src/ImageSharp/Drawing/Brushes/IBrush.cs

@ -32,6 +32,6 @@ namespace ImageSharp.Drawing
/// The <paramref name="region" /> when being applied to things like shapes would usually be the
/// bounding box of the shape not necessarily the bounds of the whole image
/// </remarks>
IBrushApplicator<TColor> CreateApplicator(IReadonlyPixelAccessor<TColor> pixelSource, RectangleF region);
IBrushApplicator<TColor> CreateApplicator(PixelAccessor<TColor> pixelSource, RectangleF region);
}
}

2
src/ImageSharp/Drawing/Brushes/ImageBrush{TColor}.cs

@ -32,7 +32,7 @@ namespace ImageSharp.Drawing.Brushes
}
/// <inheritdoc />
public IBrushApplicator<TColor> CreateApplicator(IReadonlyPixelAccessor<TColor> sourcePixels, RectangleF region)
public IBrushApplicator<TColor> CreateApplicator(PixelAccessor<TColor> sourcePixels, RectangleF region)
{
return new ImageBrushApplicator(this.image, region);
}

2
src/ImageSharp/Drawing/Brushes/PatternBrush{TColor}.cs

@ -95,7 +95,7 @@ namespace ImageSharp.Drawing.Brushes
}
/// <inheritdoc />
public IBrushApplicator<TColor> CreateApplicator(IReadonlyPixelAccessor<TColor> sourcePixels, RectangleF region)
public IBrushApplicator<TColor> CreateApplicator(PixelAccessor<TColor> sourcePixels, RectangleF region)
{
return new PatternBrushApplicator(this.pattern, this.stride);
}

6
src/ImageSharp/Drawing/Brushes/RecolorBrush{TColor}.cs

@ -55,7 +55,7 @@ namespace ImageSharp.Drawing.Brushes
public TColor TargetColor { get; }
/// <inheritdoc />
public IBrushApplicator<TColor> CreateApplicator(IReadonlyPixelAccessor<TColor> sourcePixels, RectangleF region)
public IBrushApplicator<TColor> CreateApplicator(PixelAccessor<TColor> sourcePixels, RectangleF region)
{
return new RecolorBrushApplicator(sourcePixels, this.SourceColor, this.TargetColor, this.Threashold);
}
@ -68,7 +68,7 @@ namespace ImageSharp.Drawing.Brushes
/// <summary>
/// The source pixel accessor.
/// </summary>
private readonly IReadonlyPixelAccessor<TColor> source;
private readonly PixelAccessor<TColor> source;
private readonly Vector4 sourceColor;
private readonly Vector4 targetColor;
private readonly float threashold;
@ -81,7 +81,7 @@ namespace ImageSharp.Drawing.Brushes
/// <param name="sourceColor">Color of the source.</param>
/// <param name="targetColor">Color of the target.</param>
/// <param name="threashold">The threashold .</param>
public RecolorBrushApplicator(IReadonlyPixelAccessor<TColor> sourcePixels, TColor sourceColor, TColor targetColor, float threashold)
public RecolorBrushApplicator(PixelAccessor<TColor> sourcePixels, TColor sourceColor, TColor targetColor, float threashold)
{
this.source = sourcePixels;
this.sourceColor = sourceColor.ToVector4();

2
src/ImageSharp/Drawing/Brushes/SolidBrush{TColor}.cs

@ -40,7 +40,7 @@ namespace ImageSharp.Drawing.Brushes
public TColor Color => this.color;
/// <inheritdoc />
public IBrushApplicator<TColor> CreateApplicator(IReadonlyPixelAccessor<TColor> sourcePixels, RectangleF region)
public IBrushApplicator<TColor> CreateApplicator(PixelAccessor<TColor> sourcePixels, RectangleF region)
{
return new SolidBrushApplicator(this.color);
}

2
src/ImageSharp/Drawing/Pens/IPen.cs

@ -26,6 +26,6 @@ namespace ImageSharp.Drawing.Pens
/// <remarks>
/// The <paramref name="region" /> when being applied to things like shapes would usually be the bounding box of the shape not necessarily the shape of the whole image.
/// </remarks>
IPenApplicator<TColor> CreateApplicator(IReadonlyPixelAccessor<TColor> pixelSource, RectangleF region);
IPenApplicator<TColor> CreateApplicator(PixelAccessor<TColor> pixelSource, RectangleF region);
}
}

6
src/ImageSharp/Drawing/Pens/Pen{TColor}.cs

@ -112,7 +112,7 @@ namespace ImageSharp.Drawing.Pens
/// The <paramref name="region" /> when being applied to things like shapes would ussually be the
/// bounding box of the shape not necorserrally the shape of the whole image
/// </remarks>
public IPenApplicator<TColor> CreateApplicator(IReadonlyPixelAccessor<TColor> sourcePixels, RectangleF region)
public IPenApplicator<TColor> CreateApplicator(PixelAccessor<TColor> sourcePixels, RectangleF region)
{
if (this.pattern == null || this.pattern.Length < 2)
{
@ -129,7 +129,7 @@ namespace ImageSharp.Drawing.Pens
private readonly IBrushApplicator<TColor> brush;
private readonly float halfWidth;
public SolidPenApplicator(IReadonlyPixelAccessor<TColor> sourcePixels, IBrush<TColor> brush, RectangleF region, float width)
public SolidPenApplicator(PixelAccessor<TColor> sourcePixels, IBrush<TColor> 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<TColor> sourcePixels, IBrush<TColor> brush, RectangleF region, float width, float[] pattern)
public PatternPenApplicator(PixelAccessor<TColor> sourcePixels, IBrush<TColor> brush, RectangleF region, float width, float[] pattern)
{
this.brush = brush.CreateApplicator(sourcePixels, region);
this.halfWidth = width / 2;

50
src/ImageSharp/Image/IReadonlyPixelAccessor{TColor}.cs

@ -1,50 +0,0 @@
// <copyright file="IReadonlyPixelAccessor{TColor}.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
/// <summary>
/// Provides per-pixel readonly access to generic <see cref="Image{TColor}"/> pixels.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
public interface IReadonlyPixelAccessor<TColor>
{
/// <summary>
/// Gets the size of a single pixel in the number of bytes.
/// </summary>
int PixelSize { get; }
/// <summary>
/// Gets the width of one row in the number of bytes.
/// </summary>
int RowStride { get; }
/// <summary>
/// Gets the width of the image.
/// </summary>
int Width { get; }
/// <summary>
/// Gets the height of the image.
/// </summary>
int Height { get; }
/// <summary>
/// Gets or sets the pixel at the specified position.
/// </summary>
/// <param name="x">The x-coordinate of the pixel. Must be greater than zero and smaller than the width of the pixel.</param>
/// <param name="y">The y-coordinate of the pixel. Must be greater than zero and smaller than the width of the pixel.</param>
/// <returns>The <see typeparam="TColor"/> at the specified position.</returns>
TColor this[int x, int y]
{
get;
}
}
}

2
src/ImageSharp/Image/PixelAccessor{TColor}.cs

@ -14,7 +14,7 @@ namespace ImageSharp
/// Provides per-pixel access to generic <see cref="Image{TColor}"/> pixels.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
public unsafe class PixelAccessor<TColor> : IReadonlyPixelAccessor<TColor>, IDisposable
public unsafe class PixelAccessor<TColor> : IDisposable
where TColor : struct, IPackedPixel, IEquatable<TColor>
{
/// <summary>

Loading…
Cancel
Save