diff --git a/HPPH/PixelHelper.Convert.cs b/HPPH/PixelHelper.Convert.cs index 80cfdf1..0a0201b 100644 --- a/HPPH/PixelHelper.Convert.cs +++ b/HPPH/PixelHelper.Convert.cs @@ -7,6 +7,18 @@ public static unsafe partial class PixelHelper { #region Methods + public static Span Convert(ReadOnlySpan data) + where TSource : struct, IColor + where TTarget : struct, IColor + { + if (data == null) throw new ArgumentNullException(nameof(data)); + + Span dataCopy = new TSource[data.Length]; + data.CopyTo(dataCopy); + + return Convert(dataCopy); + } + public static Span Convert(Span data) where TSource : struct, IColor where TTarget : struct, IColor @@ -106,7 +118,7 @@ public static unsafe partial class PixelHelper } } - // DarthAffe 07.07.2024: No fallback-implementation here. Shuffle Requires only Seee3 which should be supported nearly anywhere and if not the fallback of Vector128.Shuffle is perfectly fine. + // DarthAffe 07.07.2024: No fallback-implementation here. Shuffle Requires only Ssse3 which should be supported nearly anywhere and if not the fallback of Vector128.Shuffle is perfectly fine. private static void ConvertEqualBpp(Span data, ReadOnlySpan mask, int bpp) { int elementsPerVector = Vector128.Count / bpp;