diff --git a/DemoContentBuilder/DemoContentBuilder.csproj b/DemoContentBuilder/DemoContentBuilder.csproj index 4897b5b9..c72b0156 100644 --- a/DemoContentBuilder/DemoContentBuilder.csproj +++ b/DemoContentBuilder/DemoContentBuilder.csproj @@ -14,7 +14,7 @@ - + diff --git a/DemoContentBuilder/Texture2DBuilder.cs b/DemoContentBuilder/Texture2DBuilder.cs index a7226f4a..4b200bdd 100644 --- a/DemoContentBuilder/Texture2DBuilder.cs +++ b/DemoContentBuilder/Texture2DBuilder.cs @@ -17,12 +17,15 @@ public unsafe static Texture2DContent Build(Stream dataStream) var content = new Texture2DContent(image.Width, image.Height, 1, sizeof(Rgba32)); var data = (Rgba32*)content.Pin(); //Copy the image data into the Texture2DContent. - for (int rowIndex = 0; rowIndex < image.Height; ++rowIndex) - { - var sourceRow = image.GetPixelRowSpan(rowIndex); - var targetRow = data + content.GetRowOffsetForMip0(rowIndex); - Unsafe.CopyBlockUnaligned(ref *(byte*)targetRow, ref Unsafe.As(ref sourceRow[0]), (uint)(sizeof(Rgba32) * image.Width)); - } + image.ProcessPixelRows(accessor => + { + for (int rowIndex = 0; rowIndex < image.Height; ++rowIndex) + { + var sourceRow = accessor.GetRowSpan(rowIndex); + var targetRow = data + content.GetRowOffsetForMip0(rowIndex); + Unsafe.CopyBlockUnaligned(ref *(byte*)targetRow, ref Unsafe.As(ref sourceRow[0]), (uint)(sizeof(Rgba32) * image.Width)); + } + }); content.Unpin(); return content; }