From 17e212e8f0fbf10bf3ef0eafd8bbed71f891903f Mon Sep 17 00:00:00 2001 From: dirk Date: Fri, 11 Nov 2016 20:28:47 +0100 Subject: [PATCH] Added method to reset the pixels of the PixelAccessor or PixelRow. --- src/ImageSharp/Image/PixelAccessor.cs | 8 ++++++++ src/ImageSharp/Image/PixelRow.cs | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/src/ImageSharp/Image/PixelAccessor.cs b/src/ImageSharp/Image/PixelAccessor.cs index 0cd634126..0f8390677 100644 --- a/src/ImageSharp/Image/PixelAccessor.cs +++ b/src/ImageSharp/Image/PixelAccessor.cs @@ -399,5 +399,13 @@ namespace ImageSharp { return this.pixelsBase + ((targetY * this.Width) * Unsafe.SizeOf()); } + + /// + /// Resets all the pixels to it's initial value. + /// + internal void Reset() + { + Unsafe.InitBlock(this.pixelsBase, 0, (uint)(this.RowStride * this.Height)); + } } } \ No newline at end of file diff --git a/src/ImageSharp/Image/PixelRow.cs b/src/ImageSharp/Image/PixelRow.cs index d19e9ccfe..e13b62005 100644 --- a/src/ImageSharp/Image/PixelRow.cs +++ b/src/ImageSharp/Image/PixelRow.cs @@ -7,6 +7,7 @@ namespace ImageSharp { using System; using System.IO; + using System.Runtime.CompilerServices; using System.Runtime.InteropServices; /// @@ -201,5 +202,13 @@ namespace ImageSharp throw new NotSupportedException(); } + + /// + /// Resets the bytes of the array to it's initial value. + /// + internal void Reset() + { + Unsafe.InitBlock(this.PixelBase, 0, (uint)this.Bytes.Length); + } } }