From 45e5d5bc512aa0f20e33054f5071dcbbf530fb50 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Thu, 10 May 2018 13:48:16 -0700 Subject: [PATCH] Allow pixel data to be saved directly to a span --- src/ImageSharp/ImageExtensions.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/ImageSharp/ImageExtensions.cs b/src/ImageSharp/ImageExtensions.cs index 9f9a7e57a..192287ba5 100644 --- a/src/ImageSharp/ImageExtensions.cs +++ b/src/ImageSharp/ImageExtensions.cs @@ -4,13 +4,11 @@ using System; using System.Collections.Generic; using System.IO; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.Primitives; namespace SixLabors.ImageSharp { @@ -198,24 +196,24 @@ namespace SixLabors.ImageSharp } /// - /// Saves the raw image to the given bytes. + /// Saves the raw image to the given byte buffer. /// /// The Pixel format. /// The source image /// The buffer to save the raw pixel data to. /// Thrown if the stream is null. - internal static void SavePixelData(this Image source, Span buffer) + public static void SavePixelData(this Image source, Span buffer) where TPixel : struct, IPixel => source.Frames.RootFrame.SavePixelData(MemoryMarshal.Cast(buffer)); /// - /// Saves the raw image to the given bytes. + /// Saves the raw image to the given byte buffer. /// /// The Pixel format. /// The source image /// The buffer to save the raw pixel data to. /// Thrown if the stream is null. - internal static void SavePixelData(this ImageFrame source, Span buffer) + public static void SavePixelData(this ImageFrame source, Span buffer) where TPixel : struct, IPixel { Span sourceBuffer = source.GetPixelSpan(); @@ -224,4 +222,4 @@ namespace SixLabors.ImageSharp sourceBuffer.CopyTo(buffer); } } -} +} \ No newline at end of file