Browse Source

Added method to IImageBase that can be used to initialize the pixels of an image.

pull/20/head
dirk 9 years ago
parent
commit
196cdf8b78
  1. 10
      src/ImageSharp/Image/IImageBase.cs
  2. 18
      src/ImageSharp/Image/ImageBase.cs

10
src/ImageSharp/Image/IImageBase.cs

@ -19,6 +19,16 @@ namespace ImageSharp
/// </summary>
TColor[] Pixels { get; }
/// <summary>
/// Sets the size of the pixel array of the image to the given width and height.
/// </summary>
/// <param name="width">The new width of the image. Must be greater than zero.</param>
/// <param name="height">The new height of the image. Must be greater than zero.</param>
/// <exception cref="System.ArgumentOutOfRangeException">
/// Thrown if either <paramref name="width"/> or <paramref name="height"/> are less than or equal to 0.
/// </exception>
void InitPixels(int width, int height);
/// <summary>
/// Sets the pixel array of the image to the given value.
/// </summary>

18
src/ImageSharp/Image/ImageBase.cs

@ -41,12 +41,7 @@ namespace ImageSharp
/// </exception>
protected ImageBase(int width, int height)
{
Guard.MustBeGreaterThan(width, 0, nameof(width));
Guard.MustBeGreaterThan(height, 0, nameof(height));
this.Width = width;
this.Height = height;
this.pixelBuffer = new TColor[width * height];
this.InitPixels(width, height);
}
/// <summary>
@ -102,6 +97,17 @@ namespace ImageSharp
/// <inheritdoc/>
public int FrameDelay { get; set; }
/// <inheritdoc/>
public void InitPixels(int width, int height)
{
Guard.MustBeGreaterThan(width, 0, nameof(width));
Guard.MustBeGreaterThan(height, 0, nameof(height));
this.Width = width;
this.Height = height;
this.pixelBuffer = new TColor[width * height];
}
/// <inheritdoc/>
public void SetPixels(int width, int height, TColor[] pixels)
{

Loading…
Cancel
Save