diff --git a/src/ImageSharp/Image/IImageBase.cs b/src/ImageSharp/Image/IImageBase.cs
index fdd82099f6..3168b4bb5d 100644
--- a/src/ImageSharp/Image/IImageBase.cs
+++ b/src/ImageSharp/Image/IImageBase.cs
@@ -19,6 +19,16 @@ namespace ImageSharp
///
TColor[] Pixels { get; }
+ ///
+ /// Sets the size of the pixel array of the image to the given width and height.
+ ///
+ /// The new width of the image. Must be greater than zero.
+ /// The new height of the image. Must be greater than zero.
+ ///
+ /// Thrown if either or are less than or equal to 0.
+ ///
+ void InitPixels(int width, int height);
+
///
/// Sets the pixel array of the image to the given value.
///
diff --git a/src/ImageSharp/Image/ImageBase.cs b/src/ImageSharp/Image/ImageBase.cs
index 10c8c114aa..0bc5275190 100644
--- a/src/ImageSharp/Image/ImageBase.cs
+++ b/src/ImageSharp/Image/ImageBase.cs
@@ -41,12 +41,7 @@ namespace ImageSharp
///
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);
}
///
@@ -102,6 +97,17 @@ namespace ImageSharp
///
public int FrameDelay { get; set; }
+ ///
+ 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];
+ }
+
///
public void SetPixels(int width, int height, TColor[] pixels)
{