diff --git a/src/ImageSharp/Image/ImageBase{TColor}.cs b/src/ImageSharp/Image/ImageBase{TColor}.cs index 164b28160f..8fa40faccc 100644 --- a/src/ImageSharp/Image/ImageBase{TColor}.cs +++ b/src/ImageSharp/Image/ImageBase{TColor}.cs @@ -64,7 +64,7 @@ namespace ImageSharp using (PixelAccessor sourcePixels = other.Lock()) using (PixelAccessor target = this.Lock()) { - sourcePixels.CopyImage(target); + sourcePixels.CopyTo(target); } } diff --git a/src/ImageSharp/Image/PixelAccessor{TColor}.cs b/src/ImageSharp/Image/PixelAccessor{TColor}.cs index 9496c93ecc..f62e9a9c9b 100644 --- a/src/ImageSharp/Image/PixelAccessor{TColor}.cs +++ b/src/ImageSharp/Image/PixelAccessor{TColor}.cs @@ -144,34 +144,6 @@ namespace ImageSharp } } - /// - /// Copies a block of pixels at the specified position. - /// - /// The x-coordinate of the source image. - /// The y-coordinate of the source image. - /// The target pixel buffer accessor. - /// The x-coordinate of the target image. - /// The y-coordinate of the target image. - /// The number of pixels to copy - public void CopyBlock(int sourceX, int sourceY, PixelAccessor target, int targetX, int targetY, int pixelCount) - { - int size = Unsafe.SizeOf(); - byte* sourcePtr = this.pixelsBase + (((sourceY * this.Width) + sourceX) * size); - byte* targetPtr = target.pixelsBase + (((targetY * target.Width) + targetX) * size); - uint byteCount = (uint)(pixelCount * size); - - Unsafe.CopyBlock(targetPtr, sourcePtr, byteCount); - } - - /// - /// Copies an entire image. - /// - /// The target pixel buffer accessor. - public void CopyImage(PixelAccessor target) - { - this.CopyBlock(0, 0, target, 0, 0, target.Width * target.Height); - } - /// /// Copied a row of pixels from the image. /// @@ -259,6 +231,17 @@ namespace ImageSharp GC.SuppressFinalize(this); } + /// + /// Copies the pixels to another of the same size. + /// + /// The target pixel buffer accessor. + internal void CopyTo(PixelAccessor target) + { + uint byteCount = (uint)(this.Width * this.Height * Unsafe.SizeOf()); + + Unsafe.CopyBlock(target.pixelsBase, this.pixelsBase, byteCount); + } + /// /// Resets all the pixels to it's initial value. /// diff --git a/tests/ImageSharp.Benchmarks/Image/CopyPixels.cs b/tests/ImageSharp.Benchmarks/Image/CopyPixels.cs index 1003aeaeb7..3c2b1b5d20 100644 --- a/tests/ImageSharp.Benchmarks/Image/CopyPixels.cs +++ b/tests/ImageSharp.Benchmarks/Image/CopyPixels.cs @@ -37,26 +37,5 @@ namespace ImageSharp.Benchmarks.Image return targetPixels[0, 0]; } } - - [Benchmark(Description = "Copy by Row")] - public CoreColor CopyByRow() - { - CoreImage source = new CoreImage(1024, 768); - CoreImage target = new CoreImage(1024, 768); - using (PixelAccessor sourcePixels = source.Lock()) - using (PixelAccessor targetPixels = target.Lock()) - { - Parallel.For( - 0, - source.Height, - Bootstrapper.ParallelOptions, - y => - { - sourcePixels.CopyBlock(0, y, targetPixels, 0, y, source.Width); - }); - - return targetPixels[0, 0]; - } - } } }