From 3730a0259ad12432277e82e62d77cc799dee18f3 Mon Sep 17 00:00:00 2001 From: Ynse Hoornenborg Date: Fri, 10 Dec 2021 14:34:51 +0100 Subject: [PATCH] Fix build after merge --- src/ImageSharp/Formats/Pbm/BinaryDecoder.cs | 10 +++++----- src/ImageSharp/Formats/Pbm/BinaryEncoder.cs | 15 ++++++++++----- src/ImageSharp/Formats/Pbm/PlainDecoder.cs | 10 +++++----- src/ImageSharp/Formats/Pbm/PlainEncoder.cs | 15 ++++++++++----- .../ImageComparison/ImageComparingUtils.cs | 4 ++-- 5 files changed, 32 insertions(+), 22 deletions(-) diff --git a/src/ImageSharp/Formats/Pbm/BinaryDecoder.cs b/src/ImageSharp/Formats/Pbm/BinaryDecoder.cs index a469ced8a5..33af30434c 100644 --- a/src/ImageSharp/Formats/Pbm/BinaryDecoder.cs +++ b/src/ImageSharp/Formats/Pbm/BinaryDecoder.cs @@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm for (int y = 0; y < height; y++) { stream.Read(rowSpan); - Span pixelSpan = pixels.GetRowSpan(y); + Span pixelSpan = pixels.DangerousGetRowSpan(y); PixelOperations.Instance.FromL8Bytes( configuration, rowSpan, @@ -95,7 +95,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm for (int y = 0; y < height; y++) { stream.Read(rowSpan); - Span pixelSpan = pixels.GetRowSpan(y); + Span pixelSpan = pixels.DangerousGetRowSpan(y); PixelOperations.Instance.FromL16Bytes( configuration, rowSpan, @@ -117,7 +117,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm for (int y = 0; y < height; y++) { stream.Read(rowSpan); - Span pixelSpan = pixels.GetRowSpan(y); + Span pixelSpan = pixels.DangerousGetRowSpan(y); PixelOperations.Instance.FromRgb24Bytes( configuration, rowSpan, @@ -139,7 +139,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm for (int y = 0; y < height; y++) { stream.Read(rowSpan); - Span pixelSpan = pixels.GetRowSpan(y); + Span pixelSpan = pixels.DangerousGetRowSpan(y); PixelOperations.Instance.FromRgb48Bytes( configuration, rowSpan, @@ -183,7 +183,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm } } - Span pixelSpan = pixels.GetRowSpan(y); + Span pixelSpan = pixels.DangerousGetRowSpan(y); PixelOperations.Instance.FromL8( configuration, rowSpan, diff --git a/src/ImageSharp/Formats/Pbm/BinaryEncoder.cs b/src/ImageSharp/Formats/Pbm/BinaryEncoder.cs index 8b32c18c2f..332ab9b50d 100644 --- a/src/ImageSharp/Formats/Pbm/BinaryEncoder.cs +++ b/src/ImageSharp/Formats/Pbm/BinaryEncoder.cs @@ -62,13 +62,14 @@ namespace SixLabors.ImageSharp.Formats.Pbm { int width = image.Width; int height = image.Height; + Buffer2D pixelBuffer = image.PixelBuffer; MemoryAllocator allocator = configuration.MemoryAllocator; using IMemoryOwner row = allocator.Allocate(width); Span rowSpan = row.GetSpan(); for (int y = 0; y < height; y++) { - Span pixelSpan = image.GetPixelRowSpan(y); + Span pixelSpan = pixelBuffer.DangerousGetRowSpan(y); PixelOperations.Instance.ToL8Bytes( configuration, @@ -86,13 +87,14 @@ namespace SixLabors.ImageSharp.Formats.Pbm const int bytesPerPixel = 2; int width = image.Width; int height = image.Height; + Buffer2D pixelBuffer = image.PixelBuffer; MemoryAllocator allocator = configuration.MemoryAllocator; using IMemoryOwner row = allocator.Allocate(width * bytesPerPixel); Span rowSpan = row.GetSpan(); for (int y = 0; y < height; y++) { - Span pixelSpan = image.GetPixelRowSpan(y); + Span pixelSpan = pixelBuffer.DangerousGetRowSpan(y); PixelOperations.Instance.ToL16Bytes( configuration, @@ -110,13 +112,14 @@ namespace SixLabors.ImageSharp.Formats.Pbm const int bytesPerPixel = 3; int width = image.Width; int height = image.Height; + Buffer2D pixelBuffer = image.PixelBuffer; MemoryAllocator allocator = configuration.MemoryAllocator; using IMemoryOwner row = allocator.Allocate(width * bytesPerPixel); Span rowSpan = row.GetSpan(); for (int y = 0; y < height; y++) { - Span pixelSpan = image.GetPixelRowSpan(y); + Span pixelSpan = pixelBuffer.DangerousGetRowSpan(y); PixelOperations.Instance.ToRgb24Bytes( configuration, @@ -134,13 +137,14 @@ namespace SixLabors.ImageSharp.Formats.Pbm const int bytesPerPixel = 6; int width = image.Width; int height = image.Height; + Buffer2D pixelBuffer = image.PixelBuffer; MemoryAllocator allocator = configuration.MemoryAllocator; using IMemoryOwner row = allocator.Allocate(width * bytesPerPixel); Span rowSpan = row.GetSpan(); for (int y = 0; y < height; y++) { - Span pixelSpan = image.GetPixelRowSpan(y); + Span pixelSpan = pixelBuffer.DangerousGetRowSpan(y); PixelOperations.Instance.ToRgb48Bytes( configuration, @@ -157,6 +161,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm { int width = image.Width; int height = image.Height; + Buffer2D pixelBuffer = image.PixelBuffer; MemoryAllocator allocator = configuration.MemoryAllocator; using IMemoryOwner row = allocator.Allocate(width); Span rowSpan = row.GetSpan(); @@ -165,7 +170,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm int startBit = 0; for (int y = 0; y < height; y++) { - Span pixelSpan = image.GetPixelRowSpan(y); + Span pixelSpan = pixelBuffer.DangerousGetRowSpan(y); PixelOperations.Instance.ToL8( configuration, diff --git a/src/ImageSharp/Formats/Pbm/PlainDecoder.cs b/src/ImageSharp/Formats/Pbm/PlainDecoder.cs index a9e90d788d..aeb527dd20 100644 --- a/src/ImageSharp/Formats/Pbm/PlainDecoder.cs +++ b/src/ImageSharp/Formats/Pbm/PlainDecoder.cs @@ -75,7 +75,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm rowSpan[x] = new L8(value); } - Span pixelSpan = pixels.GetRowSpan(y); + Span pixelSpan = pixels.DangerousGetRowSpan(y); PixelOperations.Instance.FromL8( configuration, rowSpan, @@ -101,7 +101,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm rowSpan[x] = new L16(value); } - Span pixelSpan = pixels.GetRowSpan(y); + Span pixelSpan = pixels.DangerousGetRowSpan(y); PixelOperations.Instance.FromL16( configuration, rowSpan, @@ -131,7 +131,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm rowSpan[x] = new Rgb24(red, green, blue); } - Span pixelSpan = pixels.GetRowSpan(y); + Span pixelSpan = pixels.DangerousGetRowSpan(y); PixelOperations.Instance.FromRgb24( configuration, rowSpan, @@ -161,7 +161,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm rowSpan[x] = new Rgb48(red, green, blue); } - Span pixelSpan = pixels.GetRowSpan(y); + Span pixelSpan = pixels.DangerousGetRowSpan(y); PixelOperations.Instance.FromRgb48( configuration, rowSpan, @@ -187,7 +187,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm rowSpan[x] = value == 0 ? White : Black; } - Span pixelSpan = pixels.GetRowSpan(y); + Span pixelSpan = pixels.DangerousGetRowSpan(y); PixelOperations.Instance.FromL8( configuration, rowSpan, diff --git a/src/ImageSharp/Formats/Pbm/PlainEncoder.cs b/src/ImageSharp/Formats/Pbm/PlainEncoder.cs index 2868922ea5..a64ae38a74 100644 --- a/src/ImageSharp/Formats/Pbm/PlainEncoder.cs +++ b/src/ImageSharp/Formats/Pbm/PlainEncoder.cs @@ -76,6 +76,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm { int width = image.Width; int height = image.Height; + Buffer2D pixelBuffer = image.PixelBuffer; MemoryAllocator allocator = configuration.MemoryAllocator; using IMemoryOwner row = allocator.Allocate(width); Span rowSpan = row.GetSpan(); @@ -84,7 +85,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm for (int y = 0; y < height; y++) { - Span pixelSpan = image.GetPixelRowSpan(y); + Span pixelSpan = pixelBuffer.DangerousGetRowSpan(y); PixelOperations.Instance.ToL8( configuration, pixelSpan, @@ -108,6 +109,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm { int width = image.Width; int height = image.Height; + Buffer2D pixelBuffer = image.PixelBuffer; MemoryAllocator allocator = configuration.MemoryAllocator; using IMemoryOwner row = allocator.Allocate(width); Span rowSpan = row.GetSpan(); @@ -116,7 +118,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm for (int y = 0; y < height; y++) { - Span pixelSpan = image.GetPixelRowSpan(y); + Span pixelSpan = pixelBuffer.DangerousGetRowSpan(y); PixelOperations.Instance.ToL16( configuration, pixelSpan, @@ -140,6 +142,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm { int width = image.Width; int height = image.Height; + Buffer2D pixelBuffer = image.PixelBuffer; MemoryAllocator allocator = configuration.MemoryAllocator; using IMemoryOwner row = allocator.Allocate(width); Span rowSpan = row.GetSpan(); @@ -148,7 +151,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm for (int y = 0; y < height; y++) { - Span pixelSpan = image.GetPixelRowSpan(y); + Span pixelSpan = pixelBuffer.DangerousGetRowSpan(y); PixelOperations.Instance.ToRgb24( configuration, pixelSpan, @@ -178,6 +181,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm { int width = image.Width; int height = image.Height; + Buffer2D pixelBuffer = image.PixelBuffer; MemoryAllocator allocator = configuration.MemoryAllocator; using IMemoryOwner row = allocator.Allocate(width); Span rowSpan = row.GetSpan(); @@ -186,7 +190,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm for (int y = 0; y < height; y++) { - Span pixelSpan = image.GetPixelRowSpan(y); + Span pixelSpan = pixelBuffer.DangerousGetRowSpan(y); PixelOperations.Instance.ToRgb48( configuration, pixelSpan, @@ -216,6 +220,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm { int width = image.Width; int height = image.Height; + Buffer2D pixelBuffer = image.PixelBuffer; MemoryAllocator allocator = configuration.MemoryAllocator; using IMemoryOwner row = allocator.Allocate(width); Span rowSpan = row.GetSpan(); @@ -224,7 +229,7 @@ namespace SixLabors.ImageSharp.Formats.Pbm for (int y = 0; y < height; y++) { - Span pixelSpan = image.GetPixelRowSpan(y); + Span pixelSpan = pixelBuffer.DangerousGetRowSpan(y); PixelOperations.Instance.ToL8( configuration, pixelSpan, diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparingUtils.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparingUtils.cs index 4de1b9a19d..1801d6b590 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparingUtils.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparingUtils.cs @@ -8,9 +8,9 @@ using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; using Xunit; -namespace SixLabors.ImageSharp.Tests.Formats.Tga +namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison { - public static class TgaTestUtils + public static class ImageComparingUtils { public static void CompareWithReferenceDecoder( TestImageProvider provider,