|
|
|
@ -32,15 +32,17 @@ namespace SixLabors.ImageSharp.Tests |
|
|
|
[WithTestPatternImages(9, 9, PixelTypes.Rgba32)] |
|
|
|
public void CloneAs_ToBgra32(TestImageProvider<Rgba32> provider) |
|
|
|
{ |
|
|
|
using (Image<Rgba32> image = provider.GetImage()) |
|
|
|
using (Image<Bgra32> clone = image.CloneAs<Bgra32>()) |
|
|
|
using Image<Rgba32> image = provider.GetImage(); |
|
|
|
using Image<Bgra32> clone = image.CloneAs<Bgra32>(); |
|
|
|
|
|
|
|
image.ProcessPixelRows(clone, static (imageAccessor, cloneAccessor) => |
|
|
|
{ |
|
|
|
for (int y = 0; y < image.Height; y++) |
|
|
|
for (int y = 0; y < imageAccessor.Height; y++) |
|
|
|
{ |
|
|
|
Span<Rgba32> row = image.DangerousGetRowSpan(y); |
|
|
|
Span<Bgra32> rowClone = clone.DangerousGetRowSpan(y); |
|
|
|
Span<Rgba32> row = imageAccessor.GetRowSpan(y); |
|
|
|
Span<Bgra32> rowClone = cloneAccessor.GetRowSpan(y); |
|
|
|
|
|
|
|
for (int x = 0; x < image.Width; x++) |
|
|
|
for (int x = 0; x < imageAccessor.Width; x++) |
|
|
|
{ |
|
|
|
Rgba32 expected = row[x]; |
|
|
|
Bgra32 actual = rowClone[x]; |
|
|
|
@ -51,22 +53,24 @@ namespace SixLabors.ImageSharp.Tests |
|
|
|
Assert.Equal(expected.A, actual.A); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
[WithTestPatternImages(9, 9, PixelTypes.Rgba32)] |
|
|
|
public void CloneAs_ToBgr24(TestImageProvider<Rgba32> provider) |
|
|
|
{ |
|
|
|
using (Image<Rgba32> image = provider.GetImage()) |
|
|
|
using (Image<Bgr24> clone = image.CloneAs<Bgr24>()) |
|
|
|
using Image<Rgba32> image = provider.GetImage(); |
|
|
|
using Image<Bgr24> clone = image.CloneAs<Bgr24>(); |
|
|
|
|
|
|
|
image.ProcessPixelRows(clone, static (imageAccessor, cloneAccessor) => |
|
|
|
{ |
|
|
|
for (int y = 0; y < image.Height; y++) |
|
|
|
for (int y = 0; y < imageAccessor.Height; y++) |
|
|
|
{ |
|
|
|
Span<Rgba32> row = image.DangerousGetRowSpan(y); |
|
|
|
Span<Bgr24> rowClone = clone.DangerousGetRowSpan(y); |
|
|
|
Span<Rgba32> row = imageAccessor.GetRowSpan(y); |
|
|
|
Span<Bgr24> rowClone = cloneAccessor.GetRowSpan(y); |
|
|
|
|
|
|
|
for (int x = 0; x < image.Width; x++) |
|
|
|
for (int x = 0; x < cloneAccessor.Width; x++) |
|
|
|
{ |
|
|
|
Rgba32 expected = row[x]; |
|
|
|
Bgr24 actual = rowClone[x]; |
|
|
|
@ -76,22 +80,23 @@ namespace SixLabors.ImageSharp.Tests |
|
|
|
Assert.Equal(expected.B, actual.B); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
[WithTestPatternImages(9, 9, PixelTypes.Rgba32)] |
|
|
|
public void CloneAs_ToArgb32(TestImageProvider<Rgba32> provider) |
|
|
|
{ |
|
|
|
using (Image<Rgba32> image = provider.GetImage()) |
|
|
|
using (Image<Argb32> clone = image.CloneAs<Argb32>()) |
|
|
|
using Image<Rgba32> image = provider.GetImage(); |
|
|
|
using Image<Argb32> clone = image.CloneAs<Argb32>(); |
|
|
|
image.ProcessPixelRows(clone, static (imageAccessor, cloneAccessor) => |
|
|
|
{ |
|
|
|
for (int y = 0; y < image.Height; y++) |
|
|
|
for (int y = 0; y < imageAccessor.Height; y++) |
|
|
|
{ |
|
|
|
Span<Rgba32> row = image.DangerousGetRowSpan(y); |
|
|
|
Span<Argb32> rowClone = clone.DangerousGetRowSpan(y); |
|
|
|
Span<Rgba32> row = imageAccessor.GetRowSpan(y); |
|
|
|
Span<Argb32> rowClone = cloneAccessor.GetRowSpan(y); |
|
|
|
|
|
|
|
for (int x = 0; x < image.Width; x++) |
|
|
|
for (int x = 0; x < cloneAccessor.Width; x++) |
|
|
|
{ |
|
|
|
Rgba32 expected = row[x]; |
|
|
|
Argb32 actual = rowClone[x]; |
|
|
|
@ -102,22 +107,23 @@ namespace SixLabors.ImageSharp.Tests |
|
|
|
Assert.Equal(expected.A, actual.A); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
[WithTestPatternImages(9, 9, PixelTypes.Rgba32)] |
|
|
|
public void CloneAs_ToRgb24(TestImageProvider<Rgba32> provider) |
|
|
|
{ |
|
|
|
using (Image<Rgba32> image = provider.GetImage()) |
|
|
|
using (Image<Rgb24> clone = image.CloneAs<Rgb24>()) |
|
|
|
using Image<Rgba32> image = provider.GetImage(); |
|
|
|
using Image<Rgb24> clone = image.CloneAs<Rgb24>(); |
|
|
|
image.ProcessPixelRows(clone, static (imageAccessor, cloneAccessor) => |
|
|
|
{ |
|
|
|
for (int y = 0; y < image.Height; y++) |
|
|
|
for (int y = 0; y < imageAccessor.Height; y++) |
|
|
|
{ |
|
|
|
Span<Rgba32> row = image.DangerousGetRowSpan(y); |
|
|
|
Span<Rgb24> rowClone = clone.DangerousGetRowSpan(y); |
|
|
|
Span<Rgba32> row = imageAccessor.GetRowSpan(y); |
|
|
|
Span<Rgb24> rowClone = cloneAccessor.GetRowSpan(y); |
|
|
|
|
|
|
|
for (int x = 0; x < image.Width; x++) |
|
|
|
for (int x = 0; x < imageAccessor.Width; x++) |
|
|
|
{ |
|
|
|
Rgba32 expected = row[x]; |
|
|
|
Rgb24 actual = rowClone[x]; |
|
|
|
@ -127,7 +133,8 @@ namespace SixLabors.ImageSharp.Tests |
|
|
|
Assert.Equal(expected.B, actual.B); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|