diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColorTests.cs index ba7728b0fc..62e17e1fdb 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColorTests.cs @@ -2,72 +2,104 @@ // Licensed under the Apache License, Version 2.0. using System.Collections.Generic; + using SixLabors.ImageSharp.Formats.Tiff; using SixLabors.ImageSharp.PixelFormats; + using Xunit; -namespace SixLabors.ImageSharp.Tests.Formats.Tiff +namespace SixLabors.ImageSharp.Tests.Formats.Tiff.PhotometricInterpretation { public class BlackIsZeroTiffColorTests : PhotometricInterpretationTestBase { - private static Rgba32 Gray000 = new Rgba32(0, 0, 0, 255); - private static Rgba32 Gray128 = new Rgba32(128, 128, 128, 255); - private static Rgba32 Gray255 = new Rgba32(255, 255, 255, 255); - private static Rgba32 Gray0 = new Rgba32(0, 0, 0, 255); - private static Rgba32 Gray8 = new Rgba32(136, 136, 136, 255); - private static Rgba32 GrayF = new Rgba32(255, 255, 255, 255); - private static Rgba32 Bit0 = new Rgba32(0, 0, 0, 255); - private static Rgba32 Bit1 = new Rgba32(255, 255, 255, 255); - - private static readonly byte[] Bilevel_Bytes4x4 = new byte[] { 0b01010000, - 0b11110000, - 0b01110000, - 0b10010000 }; - - private static readonly Rgba32[][] Bilevel_Result4x4 = new[] { new[] { Bit0, Bit1, Bit0, Bit1 }, - new[] { Bit1, Bit1, Bit1, Bit1 }, - new[] { Bit0, Bit1, Bit1, Bit1 }, - new[] { Bit1, Bit0, Bit0, Bit1 }}; - - private static readonly byte[] Bilevel_Bytes12x4 = new byte[] { 0b01010101, 0b01010000, - 0b11111111, 0b11111111, - 0b01101001, 0b10100000, - 0b10010000, 0b01100000}; - - private static readonly Rgba32[][] Bilevel_Result12x4 = new[] { new[] { Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1 }, - new[] { Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1 }, - new[] { Bit0, Bit1, Bit1, Bit0, Bit1, Bit0, Bit0, Bit1, Bit1, Bit0, Bit1, Bit0 }, - new[] { Bit1, Bit0, Bit0, Bit1, Bit0, Bit0, Bit0, Bit0, Bit0, Bit1, Bit1, Bit0 }}; - - private static readonly byte[] Grayscale4_Bytes4x4 = new byte[] { 0x8F, 0x0F, - 0xFF, 0xFF, - 0x08, 0x8F, - 0xF0, 0xF8 }; - - private static readonly Rgba32[][] Grayscale4_Result4x4 = new[] { new[] { Gray8, GrayF, Gray0, GrayF }, - new[] { GrayF, GrayF, GrayF, GrayF }, - new[] { Gray0, Gray8, Gray8, GrayF }, - new[] { GrayF, Gray0, GrayF, Gray8 }}; - - private static readonly byte[] Grayscale4_Bytes3x4 = new byte[] { 0x8F, 0x00, - 0xFF, 0xF0, - 0x08, 0x80, - 0xF0, 0xF0 }; - - private static readonly Rgba32[][] Grayscale4_Result3x4 = new[] { new[] { Gray8, GrayF, Gray0 }, - new[] { GrayF, GrayF, GrayF }, - new[] { Gray0, Gray8, Gray8 }, - new[] { GrayF, Gray0, GrayF }}; - - private static readonly byte[] Grayscale8_Bytes4x4 = new byte[] { 128, 255, 000, 255, - 255, 255, 255, 255, - 000, 128, 128, 255, - 255, 000, 255, 128 }; - - private static readonly Rgba32[][] Grayscale8_Result4x4 = new[] { new[] { Gray128, Gray255, Gray000, Gray255 }, - new[] { Gray255, Gray255, Gray255, Gray255 }, - new[] { Gray000, Gray128, Gray128, Gray255 }, - new[] { Gray255, Gray000, Gray255, Gray128 }}; + private static Rgba32 gray000 = new Rgba32(0, 0, 0, 255); + private static Rgba32 gray128 = new Rgba32(128, 128, 128, 255); + private static Rgba32 gray255 = new Rgba32(255, 255, 255, 255); + private static Rgba32 gray0 = new Rgba32(0, 0, 0, 255); + private static Rgba32 gray8 = new Rgba32(136, 136, 136, 255); + private static Rgba32 grayF = new Rgba32(255, 255, 255, 255); + private static Rgba32 bit0 = new Rgba32(0, 0, 0, 255); + private static Rgba32 bit1 = new Rgba32(255, 255, 255, 255); + + private static readonly byte[] Bilevel_Bytes4x4 = + { + 0b01010000, + 0b11110000, + 0b01110000, + 0b10010000 + }; + + private static readonly Rgba32[][] Bilevel_Result4x4 = new[] + { + new[] { bit0, bit1, bit0, bit1 }, + new[] { bit1, bit1, bit1, bit1 }, + new[] { bit0, bit1, bit1, bit1 }, + new[] { bit1, bit0, bit0, bit1 } + }; + + private static readonly byte[] Bilevel_Bytes12x4 = + { + 0b01010101, 0b01010000, + 0b11111111, 0b11111111, + 0b01101001, 0b10100000, + 0b10010000, 0b01100000 + }; + + private static readonly Rgba32[][] Bilevel_Result12x4 = + { + new[] { bit0, bit1, bit0, bit1, bit0, bit1, bit0, bit1, bit0, bit1, bit0, bit1 }, + new[] { bit1, bit1, bit1, bit1, bit1, bit1, bit1, bit1, bit1, bit1, bit1, bit1 }, + new[] { bit0, bit1, bit1, bit0, bit1, bit0, bit0, bit1, bit1, bit0, bit1, bit0 }, + new[] { bit1, bit0, bit0, bit1, bit0, bit0, bit0, bit0, bit0, bit1, bit1, bit0 } + }; + + private static readonly byte[] Grayscale4_Bytes4x4 = + { + 0x8F, 0x0F, + 0xFF, 0xFF, + 0x08, 0x8F, + 0xF0, 0xF8 + }; + + private static readonly Rgba32[][] Grayscale4_Result4x4 = + { + new[] { gray8, grayF, gray0, grayF }, + new[] { grayF, grayF, grayF, grayF }, + new[] { gray0, gray8, gray8, grayF }, + new[] { grayF, gray0, grayF, gray8 } + }; + + private static readonly byte[] Grayscale4_Bytes3x4 = + { + 0x8F, 0x00, + 0xFF, 0xF0, + 0x08, 0x80, + 0xF0, 0xF0 + }; + + private static readonly Rgba32[][] Grayscale4_Result3x4 = + { + new[] { gray8, grayF, gray0 }, + new[] { grayF, grayF, grayF }, + new[] { gray0, gray8, gray8 }, + new[] { grayF, gray0, grayF } + }; + + private static readonly byte[] Grayscale8_Bytes4x4 = + { + 128, 255, 000, 255, + 255, 255, 255, 255, + 000, 128, 128, 255, + 255, 000, 255, 128 + }; + + private static readonly Rgba32[][] Grayscale8_Result4x4 = + { + new[] { gray128, gray255, gray000, gray255 }, + new[] { gray255, gray255, gray255, gray255 }, + new[] { gray000, gray128, gray128, gray255 }, + new[] { gray255, gray000, gray255, gray128 } + }; public static IEnumerable Bilevel_Data { diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PaletteTiffColorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PaletteTiffColorTests.cs index 98c7e64988..5e905e3f02 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PaletteTiffColorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PaletteTiffColorTests.cs @@ -2,11 +2,13 @@ // Licensed under the Apache License, Version 2.0. using System.Collections.Generic; + using SixLabors.ImageSharp.Formats.Tiff; using SixLabors.ImageSharp.PixelFormats; + using Xunit; -namespace SixLabors.ImageSharp.Tests.Formats.Tiff +namespace SixLabors.ImageSharp.Tests.Formats.Tiff.PhotometricInterpretation { public class PaletteTiffColorTests : PhotometricInterpretationTestBase { @@ -14,27 +16,24 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff public static ushort[] Palette4_ColorMap { get => GenerateColorMap(Palette4_ColorPalette); } - private static readonly byte[] Palette4_Bytes4x4 = new byte[] { 0x01, 0x23, - 0x4A, 0xD2, - 0x12, 0x34, - 0xAB, 0xEF }; + private static readonly byte[] Palette4_Bytes4x4 = + { + 0x01, 0x23, 0x4A, 0xD2, 0x12, 0x34, 0xAB, 0xEF + }; - private static readonly Rgba32[][] Palette4_Result4x4 = GenerateResult(Palette4_ColorPalette, - new[] { new[] { 0x00, 0x01, 0x02, 0x03 }, - new[] { 0x04, 0x0A, 0x0D, 0x02 }, - new[] { 0x01, 0x02, 0x03, 0x04 }, - new[] { 0x0A, 0x0B, 0x0E, 0x0F }}); + private static readonly Rgba32[][] Palette4_Result4x4 = GenerateResult( + Palette4_ColorPalette, + new[] { new[] { 0x00, 0x01, 0x02, 0x03 }, new[] { 0x04, 0x0A, 0x0D, 0x02 }, new[] { 0x01, 0x02, 0x03, 0x04 }, new[] { 0x0A, 0x0B, 0x0E, 0x0F } }); - private static readonly byte[] Palette4_Bytes3x4 = new byte[] { 0x01, 0x20, - 0x4A, 0xD0, - 0x12, 0x30, - 0xAB, 0xE0 }; + private static readonly byte[] Palette4_Bytes3x4 = + { + 0x01, 0x20, + 0x4A, 0xD0, + 0x12, 0x30, + 0xAB, 0xE0 + }; - private static readonly Rgba32[][] Palette4_Result3x4 = GenerateResult(Palette4_ColorPalette, - new[] { new[] { 0x00, 0x01, 0x02 }, - new[] { 0x04, 0x0A, 0x0D }, - new[] { 0x01, 0x02, 0x03 }, - new[] { 0x0A, 0x0B, 0x0E }}); + private static readonly Rgba32[][] Palette4_Result3x4 = GenerateResult(Palette4_ColorPalette, new[] { new[] { 0x00, 0x01, 0x02 }, new[] { 0x04, 0x0A, 0x0D }, new[] { 0x01, 0x02, 0x03 }, new[] { 0x0A, 0x0B, 0x0E } }); public static IEnumerable Palette4_Data { @@ -51,7 +50,6 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff yield return new object[] { Palette4_Bytes3x4, 4, Palette4_ColorMap, 1, 0, 3, 4, Offset(Palette4_Result3x4, 1, 0, 6, 6) }; yield return new object[] { Palette4_Bytes3x4, 4, Palette4_ColorMap, 0, 1, 3, 4, Offset(Palette4_Result3x4, 0, 1, 6, 6) }; yield return new object[] { Palette4_Bytes3x4, 4, Palette4_ColorMap, 1, 1, 3, 4, Offset(Palette4_Result3x4, 1, 1, 6, 6) }; - } } @@ -59,16 +57,15 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff public static ushort[] Palette8_ColorMap { get => GenerateColorMap(Palette8_ColorPalette); } - private static readonly byte[] Palette8_Bytes4x4 = new byte[] { 000, 001, 002, 003, - 100, 110, 120, 130, - 000, 255, 128, 255, - 050, 100, 150, 200 }; + private static readonly byte[] Palette8_Bytes4x4 = + { + 000, 001, 002, 003, + 100, 110, 120, 130, + 000, 255, 128, 255, + 050, 100, 150, 200 + }; - private static readonly Rgba32[][] Palette8_Result4x4 = GenerateResult(Palette8_ColorPalette, - new[] { new[] { 000, 001, 002, 003 }, - new[] { 100, 110, 120, 130 }, - new[] { 000, 255, 128, 255 }, - new[] { 050, 100, 150, 200 }}); + private static readonly Rgba32[][] Palette8_Result4x4 = GenerateResult(Palette8_ColorPalette, new[] { new[] { 000, 001, 002, 003 }, new[] { 100, 110, 120, 130 }, new[] { 000, 255, 128, 255 }, new[] { 050, 100, 150, 200 } }); public static IEnumerable Palette8_Data { @@ -95,11 +92,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff private static uint[][] GeneratePalette(int count) { - uint[][] palette = new uint[count][]; + var palette = new uint[count][]; for (uint i = 0; i < count; i++) { - palette[i] = new uint[] { (i * 2u) % 65536u, (i * 2625u) % 65536u, (i * 29401u) % 65536u }; + palette[i] = new[] { (i * 2u) % 65536u, (i * 2625u) % 65536u, (i * 29401u) % 65536u }; } return palette; @@ -108,13 +105,13 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff private static ushort[] GenerateColorMap(uint[][] colorPalette) { int colorCount = colorPalette.Length; - ushort[] colorMap = new ushort[colorCount * 3]; + var colorMap = new ushort[colorCount * 3]; for (int i = 0; i < colorCount; i++) { - colorMap[colorCount * 0 + i] = (ushort)colorPalette[i][0]; - colorMap[colorCount * 1 + i] = (ushort)colorPalette[i][1]; - colorMap[colorCount * 2 + i] = (ushort)colorPalette[i][2]; + colorMap[(colorCount * 0) + i] = (ushort)colorPalette[i][0]; + colorMap[(colorCount * 1) + i] = (ushort)colorPalette[i][1]; + colorMap[(colorCount * 2) + i] = (ushort)colorPalette[i][2]; } return colorMap; diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColorTests.cs index 1982a8ebeb..2aab2f3ec9 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColorTests.cs @@ -3,184 +3,237 @@ using System; using System.Collections.Generic; + using SixLabors.ImageSharp.Formats.Tiff; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; + using Xunit; -namespace SixLabors.ImageSharp.Tests.Formats.Tiff +namespace SixLabors.ImageSharp.Tests.Formats.Tiff.PhotometricInterpretation { public class RgbPlanarTiffColorTests : PhotometricInterpretationTestBase { - private static Rgba32 Rgb4_000 = new Rgba32(0, 0, 0, 255); - private static Rgba32 Rgb4_444 = new Rgba32(68, 68, 68, 255); - private static Rgba32 Rgb4_888 = new Rgba32(136, 136, 136, 255); - private static Rgba32 Rgb4_CCC = new Rgba32(204, 204, 204, 255); - private static Rgba32 Rgb4_FFF = new Rgba32(255, 255, 255, 255); - private static Rgba32 Rgb4_F00 = new Rgba32(255, 0, 0, 255); - private static Rgba32 Rgb4_0F0 = new Rgba32(0, 255, 0, 255); - private static Rgba32 Rgb4_00F = new Rgba32(0, 0, 255, 255); - private static Rgba32 Rgb4_F0F = new Rgba32(255, 0, 255, 255); - private static Rgba32 Rgb4_400 = new Rgba32(68, 0, 0, 255); - private static Rgba32 Rgb4_800 = new Rgba32(136, 0, 0, 255); - private static Rgba32 Rgb4_C00 = new Rgba32(204, 0, 0, 255); - private static Rgba32 Rgb4_48C = new Rgba32(68, 136, 204, 255); - - private static byte[] Rgb4_Bytes4x4_R = new byte[] { 0x0F, 0x0F, - 0xF0, 0x0F, - 0x48, 0xC4, - 0x04, 0x8C }; - - private static byte[] Rgb4_Bytes4x4_G = new byte[] { 0x0F, 0x0F, - 0x0F, 0x00, - 0x00, 0x08, - 0x04, 0x8C }; - - private static byte[] Rgb4_Bytes4x4_B = new byte[] { 0x0F, 0x0F, - 0x00, 0xFF, - 0x00, 0x0C, - 0x04, 0x8C }; - - private static byte[][] Rgb4_Bytes4x4 = new[] { Rgb4_Bytes4x4_R, Rgb4_Bytes4x4_G, Rgb4_Bytes4x4_B }; - - private static Rgba32[][] Rgb4_Result4x4 = new[] { new[] { Rgb4_000, Rgb4_FFF, Rgb4_000, Rgb4_FFF }, - new[] { Rgb4_F00, Rgb4_0F0, Rgb4_00F, Rgb4_F0F }, - new[] { Rgb4_400, Rgb4_800, Rgb4_C00, Rgb4_48C }, - new[] { Rgb4_000, Rgb4_444, Rgb4_888, Rgb4_CCC }}; - - private static byte[] Rgb4_Bytes3x4_R = new byte[] { 0x0F, 0x00, - 0xF0, 0x00, - 0x48, 0xC0, - 0x04, 0x80 }; - - private static byte[] Rgb4_Bytes3x4_G = new byte[] { 0x0F, 0x00, - 0x0F, 0x00, - 0x00, 0x00, - 0x04, 0x80 }; - - private static byte[] Rgb4_Bytes3x4_B = new byte[] { 0x0F, 0x00, - 0x00, 0xF0, - 0x00, 0x00, - 0x04, 0x80 }; - - private static byte[][] Rgb4_Bytes3x4 = new[] { Rgb4_Bytes3x4_R, Rgb4_Bytes3x4_G, Rgb4_Bytes3x4_B }; - - private static Rgba32[][] Rgb4_Result3x4 = new[] { new[] { Rgb4_000, Rgb4_FFF, Rgb4_000 }, - new[] { Rgb4_F00, Rgb4_0F0, Rgb4_00F }, - new[] { Rgb4_400, Rgb4_800, Rgb4_C00 }, - new[] { Rgb4_000, Rgb4_444, Rgb4_888 }}; + private static Rgba32 rgb4_000 = new Rgba32(0, 0, 0, 255); + private static Rgba32 rgb4_444 = new Rgba32(68, 68, 68, 255); + private static Rgba32 rgb4_888 = new Rgba32(136, 136, 136, 255); + private static Rgba32 rgb4_CCC = new Rgba32(204, 204, 204, 255); + private static Rgba32 rgb4_FFF = new Rgba32(255, 255, 255, 255); + private static Rgba32 rgb4_F00 = new Rgba32(255, 0, 0, 255); + private static Rgba32 rgb4_0F0 = new Rgba32(0, 255, 0, 255); + private static Rgba32 rgb4_00F = new Rgba32(0, 0, 255, 255); + private static Rgba32 rgb4_F0F = new Rgba32(255, 0, 255, 255); + private static Rgba32 rgb4_400 = new Rgba32(68, 0, 0, 255); + private static Rgba32 rgb4_800 = new Rgba32(136, 0, 0, 255); + private static Rgba32 rgb4_C00 = new Rgba32(204, 0, 0, 255); + private static Rgba32 rgb4_48C = new Rgba32(68, 136, 204, 255); + + private static byte[] rgb4_Bytes4x4_R = + { + 0x0F, 0x0F, + 0xF0, 0x0F, + 0x48, 0xC4, + 0x04, 0x8C + }; + + private static byte[] rgb4_Bytes4x4_G = + { + 0x0F, 0x0F, + 0x0F, 0x00, + 0x00, 0x08, + 0x04, 0x8C + }; + + private static byte[] rgb4_Bytes4x4_B = + { + 0x0F, 0x0F, + 0x00, 0xFF, + 0x00, 0x0C, + 0x04, 0x8C + }; + + private static byte[][] rgb4_Bytes4x4 = { rgb4_Bytes4x4_R, rgb4_Bytes4x4_G, rgb4_Bytes4x4_B }; + + private static Rgba32[][] rgb4_Result4x4 = + { + new[] { rgb4_000, rgb4_FFF, rgb4_000, rgb4_FFF }, + new[] { rgb4_F00, rgb4_0F0, rgb4_00F, rgb4_F0F }, + new[] { rgb4_400, rgb4_800, rgb4_C00, rgb4_48C }, + new[] { rgb4_000, rgb4_444, rgb4_888, rgb4_CCC } + }; + + private static byte[] rgb4_Bytes3x4_R = + { + 0x0F, 0x00, + 0xF0, 0x00, + 0x48, 0xC0, + 0x04, 0x80 + }; + + private static byte[] rgb4_Bytes3x4_G = + { + 0x0F, 0x00, + 0x0F, 0x00, + 0x00, 0x00, + 0x04, 0x80 + }; + + private static byte[] rgb4_Bytes3x4_B = + { + 0x0F, 0x00, + 0x00, 0xF0, + 0x00, 0x00, + 0x04, 0x80 + }; + + private static byte[][] rgb4_Bytes3x4 = { rgb4_Bytes3x4_R, rgb4_Bytes3x4_G, rgb4_Bytes3x4_B }; + + private static Rgba32[][] rgb4_Result3x4 = + { + new[] { rgb4_000, rgb4_FFF, rgb4_000 }, + new[] { rgb4_F00, rgb4_0F0, rgb4_00F }, + new[] { rgb4_400, rgb4_800, rgb4_C00 }, + new[] { rgb4_000, rgb4_444, rgb4_888 } + }; public static IEnumerable Rgb4_Data { get { - yield return new object[] { Rgb4_Bytes4x4, new ushort[] { 4, 4, 4 }, 0, 0, 4, 4, Rgb4_Result4x4 }; - yield return new object[] { Rgb4_Bytes4x4, new ushort[] { 4, 4, 4 }, 0, 0, 4, 4, Offset(Rgb4_Result4x4, 0, 0, 6, 6) }; - yield return new object[] { Rgb4_Bytes4x4, new ushort[] { 4, 4, 4 }, 1, 0, 4, 4, Offset(Rgb4_Result4x4, 1, 0, 6, 6) }; - yield return new object[] { Rgb4_Bytes4x4, new ushort[] { 4, 4, 4 }, 0, 1, 4, 4, Offset(Rgb4_Result4x4, 0, 1, 6, 6) }; - yield return new object[] { Rgb4_Bytes4x4, new ushort[] { 4, 4, 4 }, 1, 1, 4, 4, Offset(Rgb4_Result4x4, 1, 1, 6, 6) }; - - yield return new object[] { Rgb4_Bytes3x4, new ushort[] { 4, 4, 4 }, 0, 0, 3, 4, Rgb4_Result3x4 }; - yield return new object[] { Rgb4_Bytes3x4, new ushort[] { 4, 4, 4 }, 0, 0, 3, 4, Offset(Rgb4_Result3x4, 0, 0, 6, 6) }; - yield return new object[] { Rgb4_Bytes3x4, new ushort[] { 4, 4, 4 }, 1, 0, 3, 4, Offset(Rgb4_Result3x4, 1, 0, 6, 6) }; - yield return new object[] { Rgb4_Bytes3x4, new ushort[] { 4, 4, 4 }, 0, 1, 3, 4, Offset(Rgb4_Result3x4, 0, 1, 6, 6) }; - yield return new object[] { Rgb4_Bytes3x4, new ushort[] { 4, 4, 4 }, 1, 1, 3, 4, Offset(Rgb4_Result3x4, 1, 1, 6, 6) }; + yield return new object[] { rgb4_Bytes4x4, new ushort[] { 4, 4, 4 }, 0, 0, 4, 4, rgb4_Result4x4 }; + yield return new object[] { rgb4_Bytes4x4, new ushort[] { 4, 4, 4 }, 0, 0, 4, 4, Offset(rgb4_Result4x4, 0, 0, 6, 6) }; + yield return new object[] { rgb4_Bytes4x4, new ushort[] { 4, 4, 4 }, 1, 0, 4, 4, Offset(rgb4_Result4x4, 1, 0, 6, 6) }; + yield return new object[] { rgb4_Bytes4x4, new ushort[] { 4, 4, 4 }, 0, 1, 4, 4, Offset(rgb4_Result4x4, 0, 1, 6, 6) }; + yield return new object[] { rgb4_Bytes4x4, new ushort[] { 4, 4, 4 }, 1, 1, 4, 4, Offset(rgb4_Result4x4, 1, 1, 6, 6) }; + + yield return new object[] { rgb4_Bytes3x4, new ushort[] { 4, 4, 4 }, 0, 0, 3, 4, rgb4_Result3x4 }; + yield return new object[] { rgb4_Bytes3x4, new ushort[] { 4, 4, 4 }, 0, 0, 3, 4, Offset(rgb4_Result3x4, 0, 0, 6, 6) }; + yield return new object[] { rgb4_Bytes3x4, new ushort[] { 4, 4, 4 }, 1, 0, 3, 4, Offset(rgb4_Result3x4, 1, 0, 6, 6) }; + yield return new object[] { rgb4_Bytes3x4, new ushort[] { 4, 4, 4 }, 0, 1, 3, 4, Offset(rgb4_Result3x4, 0, 1, 6, 6) }; + yield return new object[] { rgb4_Bytes3x4, new ushort[] { 4, 4, 4 }, 1, 1, 3, 4, Offset(rgb4_Result3x4, 1, 1, 6, 6) }; } } - private static Rgba32 Rgb8_000 = new Rgba32(0, 0, 0, 255); - private static Rgba32 Rgb8_444 = new Rgba32(64, 64, 64, 255); - private static Rgba32 Rgb8_888 = new Rgba32(128, 128, 128, 255); - private static Rgba32 Rgb8_CCC = new Rgba32(192, 192, 192, 255); - private static Rgba32 Rgb8_FFF = new Rgba32(255, 255, 255, 255); - private static Rgba32 Rgb8_F00 = new Rgba32(255, 0, 0, 255); - private static Rgba32 Rgb8_0F0 = new Rgba32(0, 255, 0, 255); - private static Rgba32 Rgb8_00F = new Rgba32(0, 0, 255, 255); - private static Rgba32 Rgb8_F0F = new Rgba32(255, 0, 255, 255); - private static Rgba32 Rgb8_400 = new Rgba32(64, 0, 0, 255); - private static Rgba32 Rgb8_800 = new Rgba32(128, 0, 0, 255); - private static Rgba32 Rgb8_C00 = new Rgba32(192, 0, 0, 255); - private static Rgba32 Rgb8_48C = new Rgba32(64, 128, 192, 255); - - private static byte[] Rgb8_Bytes4x4_R = new byte[] { 000, 255, 000, 255, - 255, 000, 000, 255, - 064, 128, 192, 064, - 000, 064, 128, 192 }; - - private static byte[] Rgb8_Bytes4x4_G = new byte[] { 000, 255, 000, 255, - 000, 255, 000, 000, - 000, 000, 000, 128, - 000, 064, 128, 192 }; - - private static byte[] Rgb8_Bytes4x4_B = new byte[] { 000, 255, 000, 255, - 000, 000, 255, 255, - 000, 000, 000, 192, - 000, 064, 128, 192 }; - - private static byte[][] Rgb8_Bytes4x4 = new[] { Rgb8_Bytes4x4_R, Rgb8_Bytes4x4_G, Rgb8_Bytes4x4_B }; - - private static Rgba32[][] Rgb8_Result4x4 = new[] { new[] { Rgb8_000, Rgb8_FFF, Rgb8_000, Rgb8_FFF }, - new[] { Rgb8_F00, Rgb8_0F0, Rgb8_00F, Rgb8_F0F }, - new[] { Rgb8_400, Rgb8_800, Rgb8_C00, Rgb8_48C }, - new[] { Rgb8_000, Rgb8_444, Rgb8_888, Rgb8_CCC }}; + private static Rgba32 rgb8_000 = new Rgba32(0, 0, 0, 255); + private static Rgba32 rgb8_444 = new Rgba32(64, 64, 64, 255); + private static Rgba32 rgb8_888 = new Rgba32(128, 128, 128, 255); + private static Rgba32 rgb8_CCC = new Rgba32(192, 192, 192, 255); + private static Rgba32 rgb8_FFF = new Rgba32(255, 255, 255, 255); + private static Rgba32 rgb8_F00 = new Rgba32(255, 0, 0, 255); + private static Rgba32 rgb8_0F0 = new Rgba32(0, 255, 0, 255); + private static Rgba32 rgb8_00F = new Rgba32(0, 0, 255, 255); + private static Rgba32 rgb8_F0F = new Rgba32(255, 0, 255, 255); + private static Rgba32 rgb8_400 = new Rgba32(64, 0, 0, 255); + private static Rgba32 rgb8_800 = new Rgba32(128, 0, 0, 255); + private static Rgba32 rgb8_C00 = new Rgba32(192, 0, 0, 255); + private static Rgba32 rgb8_48C = new Rgba32(64, 128, 192, 255); + + private static byte[] rgb8_Bytes4x4_R = + { + 000, 255, 000, 255, + 255, 000, 000, 255, + 064, 128, 192, 064, + 000, 064, 128, 192 + }; + + private static byte[] rgb8_Bytes4x4_G = + { + 000, 255, 000, 255, + 000, 255, 000, 000, + 000, 000, 000, 128, + 000, 064, 128, 192 + }; + + private static byte[] rgb8_Bytes4x4_B = + { + 000, 255, 000, 255, + 000, 000, 255, 255, + 000, 000, 000, 192, + 000, 064, 128, 192 + }; + + private static byte[][] rgb8_Bytes4x4 = + { + rgb8_Bytes4x4_R, rgb8_Bytes4x4_G, rgb8_Bytes4x4_B + }; + + private static Rgba32[][] rgb8_Result4x4 = + { + new[] { rgb8_000, rgb8_FFF, rgb8_000, rgb8_FFF }, + new[] { rgb8_F00, rgb8_0F0, rgb8_00F, rgb8_F0F }, + new[] { rgb8_400, rgb8_800, rgb8_C00, rgb8_48C }, + new[] { rgb8_000, rgb8_444, rgb8_888, rgb8_CCC } + }; public static IEnumerable Rgb8_Data { get { - yield return new object[] { Rgb8_Bytes4x4, new ushort[] { 8, 8, 8 }, 0, 0, 4, 4, Rgb8_Result4x4 }; - yield return new object[] { Rgb8_Bytes4x4, new ushort[] { 8, 8, 8 }, 0, 0, 4, 4, Offset(Rgb8_Result4x4, 0, 0, 6, 6) }; - yield return new object[] { Rgb8_Bytes4x4, new ushort[] { 8, 8, 8 }, 1, 0, 4, 4, Offset(Rgb8_Result4x4, 1, 0, 6, 6) }; - yield return new object[] { Rgb8_Bytes4x4, new ushort[] { 8, 8, 8 }, 0, 1, 4, 4, Offset(Rgb8_Result4x4, 0, 1, 6, 6) }; - yield return new object[] { Rgb8_Bytes4x4, new ushort[] { 8, 8, 8 }, 1, 1, 4, 4, Offset(Rgb8_Result4x4, 1, 1, 6, 6) }; + yield return new object[] { rgb8_Bytes4x4, new ushort[] { 8, 8, 8 }, 0, 0, 4, 4, rgb8_Result4x4 }; + yield return new object[] { rgb8_Bytes4x4, new ushort[] { 8, 8, 8 }, 0, 0, 4, 4, Offset(rgb8_Result4x4, 0, 0, 6, 6) }; + yield return new object[] { rgb8_Bytes4x4, new ushort[] { 8, 8, 8 }, 1, 0, 4, 4, Offset(rgb8_Result4x4, 1, 0, 6, 6) }; + yield return new object[] { rgb8_Bytes4x4, new ushort[] { 8, 8, 8 }, 0, 1, 4, 4, Offset(rgb8_Result4x4, 0, 1, 6, 6) }; + yield return new object[] { rgb8_Bytes4x4, new ushort[] { 8, 8, 8 }, 1, 1, 4, 4, Offset(rgb8_Result4x4, 1, 1, 6, 6) }; } } - private static Rgba32 Rgb484_000 = new Rgba32(0, 0, 0, 255); - private static Rgba32 Rgb484_444 = new Rgba32(68, 64, 68, 255); - private static Rgba32 Rgb484_888 = new Rgba32(136, 128, 136, 255); - private static Rgba32 Rgb484_CCC = new Rgba32(204, 192, 204, 255); - private static Rgba32 Rgb484_FFF = new Rgba32(255, 255, 255, 255); - private static Rgba32 Rgb484_F00 = new Rgba32(255, 0, 0, 255); - private static Rgba32 Rgb484_0F0 = new Rgba32(0, 255, 0, 255); - private static Rgba32 Rgb484_00F = new Rgba32(0, 0, 255, 255); - private static Rgba32 Rgb484_F0F = new Rgba32(255, 0, 255, 255); - private static Rgba32 Rgb484_400 = new Rgba32(68, 0, 0, 255); - private static Rgba32 Rgb484_800 = new Rgba32(136, 0, 0, 255); - private static Rgba32 Rgb484_C00 = new Rgba32(204, 0, 0, 255); - private static Rgba32 Rgb484_48C = new Rgba32(68, 128, 204, 255); - - private static byte[] Rgb484_Bytes4x4_R = new byte[] { 0x0F, 0x0F, - 0xF0, 0x0F, - 0x48, 0xC4, - 0x04, 0x8C }; - - private static byte[] Rgb484_Bytes4x4_G = new byte[] { 0x00, 0xFF, 0x00, 0xFF, - 0x00, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x80, - 0x00, 0x40, 0x80, 0xC0 }; - - private static byte[] Rgb484_Bytes4x4_B = new byte[] { 0x0F, 0x0F, - 0x00, 0xFF, - 0x00, 0x0C, - 0x04, 0x8C }; - - private static Rgba32[][] Rgb484_Result4x4 = new[] { new[] { Rgb484_000, Rgb484_FFF, Rgb484_000, Rgb484_FFF }, - new[] { Rgb484_F00, Rgb484_0F0, Rgb484_00F, Rgb484_F0F }, - new[] { Rgb484_400, Rgb484_800, Rgb484_C00, Rgb484_48C }, - new[] { Rgb484_000, Rgb484_444, Rgb484_888, Rgb484_CCC }}; - - private static byte[][] Rgb484_Bytes4x4 = new[] { Rgb484_Bytes4x4_R, Rgb484_Bytes4x4_G, Rgb484_Bytes4x4_B }; + private static Rgba32 rgb484_000 = new Rgba32(0, 0, 0, 255); + private static Rgba32 rgb484_444 = new Rgba32(68, 64, 68, 255); + private static Rgba32 rgb484_888 = new Rgba32(136, 128, 136, 255); + private static Rgba32 rgb484_CCC = new Rgba32(204, 192, 204, 255); + private static Rgba32 rgb484_FFF = new Rgba32(255, 255, 255, 255); + private static Rgba32 rgb484_F00 = new Rgba32(255, 0, 0, 255); + private static Rgba32 rgb484_0F0 = new Rgba32(0, 255, 0, 255); + private static Rgba32 rgb484_00F = new Rgba32(0, 0, 255, 255); + private static Rgba32 rgb484_F0F = new Rgba32(255, 0, 255, 255); + private static Rgba32 rgb484_400 = new Rgba32(68, 0, 0, 255); + private static Rgba32 rgb484_800 = new Rgba32(136, 0, 0, 255); + private static Rgba32 rgb484_C00 = new Rgba32(204, 0, 0, 255); + private static Rgba32 rgb484_48C = new Rgba32(68, 128, 204, 255); + + private static byte[] rgb484_Bytes4x4_R = + { + 0x0F, 0x0F, + 0xF0, 0x0F, + 0x48, 0xC4, + 0x04, 0x8C + }; + + private static byte[] rgb484_Bytes4x4_G = + { + 0x00, 0xFF, 0x00, 0xFF, + 0x00, 0xFF, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x80, + 0x00, 0x40, 0x80, 0xC0 + }; + + private static byte[] rgb484_Bytes4x4_B = + { + 0x0F, 0x0F, + 0x00, 0xFF, + 0x00, 0x0C, + 0x04, 0x8C + }; + + private static Rgba32[][] rgb484_Result4x4 = + { + new[] { rgb484_000, rgb484_FFF, rgb484_000, rgb484_FFF }, + new[] { rgb484_F00, rgb484_0F0, rgb484_00F, rgb484_F0F }, + new[] { rgb484_400, rgb484_800, rgb484_C00, rgb484_48C }, + new[] { rgb484_000, rgb484_444, rgb484_888, rgb484_CCC } + }; + + private static byte[][] rgb484_Bytes4x4 = { rgb484_Bytes4x4_R, rgb484_Bytes4x4_G, rgb484_Bytes4x4_B }; public static IEnumerable Rgb484_Data { get { - yield return new object[] { Rgb484_Bytes4x4, new ushort[] { 4, 8, 4 }, 0, 0, 4, 4, Rgb484_Result4x4 }; - yield return new object[] { Rgb484_Bytes4x4, new ushort[] { 4, 8, 4 }, 0, 0, 4, 4, Offset(Rgb484_Result4x4, 0, 0, 6, 6) }; - yield return new object[] { Rgb484_Bytes4x4, new ushort[] { 4, 8, 4 }, 1, 0, 4, 4, Offset(Rgb484_Result4x4, 1, 0, 6, 6) }; - yield return new object[] { Rgb484_Bytes4x4, new ushort[] { 4, 8, 4 }, 0, 1, 4, 4, Offset(Rgb484_Result4x4, 0, 1, 6, 6) }; - yield return new object[] { Rgb484_Bytes4x4, new ushort[] { 4, 8, 4 }, 1, 1, 4, 4, Offset(Rgb484_Result4x4, 1, 1, 6, 6) }; + yield return new object[] { rgb484_Bytes4x4, new ushort[] { 4, 8, 4 }, 0, 0, 4, 4, rgb484_Result4x4 }; + yield return new object[] { rgb484_Bytes4x4, new ushort[] { 4, 8, 4 }, 0, 0, 4, 4, Offset(rgb484_Result4x4, 0, 0, 6, 6) }; + yield return new object[] { rgb484_Bytes4x4, new ushort[] { 4, 8, 4 }, 1, 0, 4, 4, Offset(rgb484_Result4x4, 1, 0, 6, 6) }; + yield return new object[] { rgb484_Bytes4x4, new ushort[] { 4, 8, 4 }, 0, 1, 4, 4, Offset(rgb484_Result4x4, 0, 1, 6, 6) }; + yield return new object[] { rgb484_Bytes4x4, new ushort[] { 4, 8, 4 }, 1, 1, 4, 4, Offset(rgb484_Result4x4, 1, 1, 6, 6) }; } } diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbTiffColorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbTiffColorTests.cs index f1ba32c5dd..f1fa118f3d 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbTiffColorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbTiffColorTests.cs @@ -2,135 +2,161 @@ // Licensed under the Apache License, Version 2.0. using System.Collections.Generic; + using SixLabors.ImageSharp.Formats.Tiff; using SixLabors.ImageSharp.PixelFormats; + using Xunit; -namespace SixLabors.ImageSharp.Tests.Formats.Tiff +namespace SixLabors.ImageSharp.Tests.Formats.Tiff.PhotometricInterpretation { public class RgbTiffColorTests : PhotometricInterpretationTestBase { - private static Rgba32 Rgb4_000 = new Rgba32(0, 0, 0, 255); - private static Rgba32 Rgb4_444 = new Rgba32(68, 68, 68, 255); - private static Rgba32 Rgb4_888 = new Rgba32(136, 136, 136, 255); - private static Rgba32 Rgb4_CCC = new Rgba32(204, 204, 204, 255); - private static Rgba32 Rgb4_FFF = new Rgba32(255, 255, 255, 255); - private static Rgba32 Rgb4_F00 = new Rgba32(255, 0, 0, 255); - private static Rgba32 Rgb4_0F0 = new Rgba32(0, 255, 0, 255); - private static Rgba32 Rgb4_00F = new Rgba32(0, 0, 255, 255); - private static Rgba32 Rgb4_F0F = new Rgba32(255, 0, 255, 255); - private static Rgba32 Rgb4_400 = new Rgba32(68, 0, 0, 255); - private static Rgba32 Rgb4_800 = new Rgba32(136, 0, 0, 255); - private static Rgba32 Rgb4_C00 = new Rgba32(204, 0, 0, 255); - private static Rgba32 Rgb4_48C = new Rgba32(68, 136, 204, 255); - - private static byte[] Rgb4_Bytes4x4 = new byte[] { 0x00, 0x0F, 0xFF, 0x00, 0x0F, 0xFF, - 0xF0, 0x00, 0xF0, 0x00, 0xFF, 0x0F, - 0x40, 0x08, 0x00, 0xC0, 0x04, 0x8C, - 0x00, 0x04, 0x44, 0x88, 0x8C, 0xCC }; - - private static Rgba32[][] Rgb4_Result4x4 = new[] { new[] { Rgb4_000, Rgb4_FFF, Rgb4_000, Rgb4_FFF }, - new[] { Rgb4_F00, Rgb4_0F0, Rgb4_00F, Rgb4_F0F }, - new[] { Rgb4_400, Rgb4_800, Rgb4_C00, Rgb4_48C }, - new[] { Rgb4_000, Rgb4_444, Rgb4_888, Rgb4_CCC }}; - - private static byte[] Rgb4_Bytes3x4 = new byte[] { 0x00, 0x0F, 0xFF, 0x00, 0x00, - 0xF0, 0x00, 0xF0, 0x00, 0xF0, - 0x40, 0x08, 0x00, 0xC0, 0x00, - 0x00, 0x04, 0x44, 0x88, 0x80 }; - - private static Rgba32[][] Rgb4_Result3x4 = new[] { new[] { Rgb4_000, Rgb4_FFF, Rgb4_000 }, - new[] { Rgb4_F00, Rgb4_0F0, Rgb4_00F }, - new[] { Rgb4_400, Rgb4_800, Rgb4_C00 }, - new[] { Rgb4_000, Rgb4_444, Rgb4_888 }}; + private static Rgba32 rgb4_000 = new Rgba32(0, 0, 0, 255); + private static Rgba32 rgb4_444 = new Rgba32(68, 68, 68, 255); + private static Rgba32 rgb4_888 = new Rgba32(136, 136, 136, 255); + private static Rgba32 rgb4_CCC = new Rgba32(204, 204, 204, 255); + private static Rgba32 rgb4_FFF = new Rgba32(255, 255, 255, 255); + private static Rgba32 rgb4_F00 = new Rgba32(255, 0, 0, 255); + private static Rgba32 rgb4_0F0 = new Rgba32(0, 255, 0, 255); + private static Rgba32 rgb4_00F = new Rgba32(0, 0, 255, 255); + private static Rgba32 rgb4_F0F = new Rgba32(255, 0, 255, 255); + private static Rgba32 rgb4_400 = new Rgba32(68, 0, 0, 255); + private static Rgba32 rgb4_800 = new Rgba32(136, 0, 0, 255); + private static Rgba32 rgb4_C00 = new Rgba32(204, 0, 0, 255); + private static Rgba32 rgb4_48C = new Rgba32(68, 136, 204, 255); + + private static byte[] rgb4_Bytes4x4 = + { + 0x00, 0x0F, 0xFF, 0x00, 0x0F, 0xFF, + 0xF0, 0x00, 0xF0, 0x00, 0xFF, 0x0F, + 0x40, 0x08, 0x00, 0xC0, 0x04, 0x8C, + 0x00, 0x04, 0x44, 0x88, 0x8C, 0xCC + }; + + private static Rgba32[][] rgb4_Result4x4 = + { + new[] { rgb4_000, rgb4_FFF, rgb4_000, rgb4_FFF }, + new[] { rgb4_F00, rgb4_0F0, rgb4_00F, rgb4_F0F }, + new[] { rgb4_400, rgb4_800, rgb4_C00, rgb4_48C }, + new[] { rgb4_000, rgb4_444, rgb4_888, rgb4_CCC } + }; + + private static byte[] rgb4_Bytes3x4 = + { + 0x00, 0x0F, 0xFF, 0x00, 0x00, + 0xF0, 0x00, 0xF0, 0x00, 0xF0, + 0x40, 0x08, 0x00, 0xC0, 0x00, + 0x00, 0x04, 0x44, 0x88, 0x80 + }; + + private static Rgba32[][] rgb4_Result3x4 = + { + new[] { rgb4_000, rgb4_FFF, rgb4_000 }, + new[] { rgb4_F00, rgb4_0F0, rgb4_00F }, + new[] { rgb4_400, rgb4_800, rgb4_C00 }, + new[] { rgb4_000, rgb4_444, rgb4_888 } + }; public static IEnumerable Rgb4_Data { get { - yield return new object[] { Rgb4_Bytes4x4, new ushort[] { 4, 4, 4 }, 0, 0, 4, 4, Rgb4_Result4x4 }; - yield return new object[] { Rgb4_Bytes4x4, new ushort[] { 4, 4, 4 }, 0, 0, 4, 4, Offset(Rgb4_Result4x4, 0, 0, 6, 6) }; - yield return new object[] { Rgb4_Bytes4x4, new ushort[] { 4, 4, 4 }, 1, 0, 4, 4, Offset(Rgb4_Result4x4, 1, 0, 6, 6) }; - yield return new object[] { Rgb4_Bytes4x4, new ushort[] { 4, 4, 4 }, 0, 1, 4, 4, Offset(Rgb4_Result4x4, 0, 1, 6, 6) }; - yield return new object[] { Rgb4_Bytes4x4, new ushort[] { 4, 4, 4 }, 1, 1, 4, 4, Offset(Rgb4_Result4x4, 1, 1, 6, 6) }; - - yield return new object[] { Rgb4_Bytes3x4, new ushort[] { 4, 4, 4 }, 0, 0, 3, 4, Rgb4_Result3x4 }; - yield return new object[] { Rgb4_Bytes3x4, new ushort[] { 4, 4, 4 }, 0, 0, 3, 4, Offset(Rgb4_Result3x4, 0, 0, 6, 6) }; - yield return new object[] { Rgb4_Bytes3x4, new ushort[] { 4, 4, 4 }, 1, 0, 3, 4, Offset(Rgb4_Result3x4, 1, 0, 6, 6) }; - yield return new object[] { Rgb4_Bytes3x4, new ushort[] { 4, 4, 4 }, 0, 1, 3, 4, Offset(Rgb4_Result3x4, 0, 1, 6, 6) }; - yield return new object[] { Rgb4_Bytes3x4, new ushort[] { 4, 4, 4 }, 1, 1, 3, 4, Offset(Rgb4_Result3x4, 1, 1, 6, 6) }; + yield return new object[] { rgb4_Bytes4x4, new ushort[] { 4, 4, 4 }, 0, 0, 4, 4, rgb4_Result4x4 }; + yield return new object[] { rgb4_Bytes4x4, new ushort[] { 4, 4, 4 }, 0, 0, 4, 4, Offset(rgb4_Result4x4, 0, 0, 6, 6) }; + yield return new object[] { rgb4_Bytes4x4, new ushort[] { 4, 4, 4 }, 1, 0, 4, 4, Offset(rgb4_Result4x4, 1, 0, 6, 6) }; + yield return new object[] { rgb4_Bytes4x4, new ushort[] { 4, 4, 4 }, 0, 1, 4, 4, Offset(rgb4_Result4x4, 0, 1, 6, 6) }; + yield return new object[] { rgb4_Bytes4x4, new ushort[] { 4, 4, 4 }, 1, 1, 4, 4, Offset(rgb4_Result4x4, 1, 1, 6, 6) }; + + yield return new object[] { rgb4_Bytes3x4, new ushort[] { 4, 4, 4 }, 0, 0, 3, 4, rgb4_Result3x4 }; + yield return new object[] { rgb4_Bytes3x4, new ushort[] { 4, 4, 4 }, 0, 0, 3, 4, Offset(rgb4_Result3x4, 0, 0, 6, 6) }; + yield return new object[] { rgb4_Bytes3x4, new ushort[] { 4, 4, 4 }, 1, 0, 3, 4, Offset(rgb4_Result3x4, 1, 0, 6, 6) }; + yield return new object[] { rgb4_Bytes3x4, new ushort[] { 4, 4, 4 }, 0, 1, 3, 4, Offset(rgb4_Result3x4, 0, 1, 6, 6) }; + yield return new object[] { rgb4_Bytes3x4, new ushort[] { 4, 4, 4 }, 1, 1, 3, 4, Offset(rgb4_Result3x4, 1, 1, 6, 6) }; } } - private static Rgba32 Rgb8_000 = new Rgba32(0, 0, 0, 255); - private static Rgba32 Rgb8_444 = new Rgba32(64, 64, 64, 255); - private static Rgba32 Rgb8_888 = new Rgba32(128, 128, 128, 255); - private static Rgba32 Rgb8_CCC = new Rgba32(192, 192, 192, 255); - private static Rgba32 Rgb8_FFF = new Rgba32(255, 255, 255, 255); - private static Rgba32 Rgb8_F00 = new Rgba32(255, 0, 0, 255); - private static Rgba32 Rgb8_0F0 = new Rgba32(0, 255, 0, 255); - private static Rgba32 Rgb8_00F = new Rgba32(0, 0, 255, 255); - private static Rgba32 Rgb8_F0F = new Rgba32(255, 0, 255, 255); - private static Rgba32 Rgb8_400 = new Rgba32(64, 0, 0, 255); - private static Rgba32 Rgb8_800 = new Rgba32(128, 0, 0, 255); - private static Rgba32 Rgb8_C00 = new Rgba32(192, 0, 0, 255); - private static Rgba32 Rgb8_48C = new Rgba32(64, 128, 192, 255); - - private static byte[] Rgb8_Bytes4x4 = new byte[] { 000, 000, 000, 255, 255, 255, 000, 000, 000, 255, 255, 255, - 255, 000, 000, 000, 255, 000, 000, 000, 255, 255, 000, 255, - 064, 000, 000, 128, 000, 000, 192, 000, 000, 064, 128, 192, - 000, 000, 000, 064, 064, 064, 128, 128, 128, 192, 192, 192 }; - - private static Rgba32[][] Rgb8_Result4x4 = new[] { new[] { Rgb8_000, Rgb8_FFF, Rgb8_000, Rgb8_FFF }, - new[] { Rgb8_F00, Rgb8_0F0, Rgb8_00F, Rgb8_F0F }, - new[] { Rgb8_400, Rgb8_800, Rgb8_C00, Rgb8_48C }, - new[] { Rgb8_000, Rgb8_444, Rgb8_888, Rgb8_CCC }}; + private static Rgba32 rgb8_000 = new Rgba32(0, 0, 0, 255); + private static Rgba32 rgb8_444 = new Rgba32(64, 64, 64, 255); + private static Rgba32 rgb8_888 = new Rgba32(128, 128, 128, 255); + private static Rgba32 rgb8_CCC = new Rgba32(192, 192, 192, 255); + private static Rgba32 rgb8_FFF = new Rgba32(255, 255, 255, 255); + private static Rgba32 rgb8_F00 = new Rgba32(255, 0, 0, 255); + private static Rgba32 rgb8_0F0 = new Rgba32(0, 255, 0, 255); + private static Rgba32 rgb8_00F = new Rgba32(0, 0, 255, 255); + private static Rgba32 rgb8_F0F = new Rgba32(255, 0, 255, 255); + private static Rgba32 rgb8_400 = new Rgba32(64, 0, 0, 255); + private static Rgba32 rgb8_800 = new Rgba32(128, 0, 0, 255); + private static Rgba32 rgb8_C00 = new Rgba32(192, 0, 0, 255); + private static Rgba32 rgb8_48C = new Rgba32(64, 128, 192, 255); + + private static byte[] rgb8_Bytes4x4 = + { + 000, 000, 000, 255, 255, 255, 000, 000, 000, 255, 255, 255, + 255, 000, 000, 000, 255, 000, 000, 000, 255, 255, 000, 255, + 064, 000, 000, 128, 000, 000, 192, 000, 000, 064, 128, 192, + 000, 000, 000, 064, 064, 064, 128, 128, 128, 192, 192, 192 + }; + + private static Rgba32[][] rgb8_Result4x4 = + { + new[] { rgb8_000, rgb8_FFF, rgb8_000, rgb8_FFF }, + new[] { rgb8_F00, rgb8_0F0, rgb8_00F, rgb8_F0F }, + new[] { rgb8_400, rgb8_800, rgb8_C00, rgb8_48C }, + new[] { rgb8_000, rgb8_444, rgb8_888, rgb8_CCC } + }; public static IEnumerable Rgb8_Data { get { - yield return new object[] { Rgb8_Bytes4x4, new ushort[] { 8, 8, 8 }, 0, 0, 4, 4, Rgb8_Result4x4 }; - yield return new object[] { Rgb8_Bytes4x4, new ushort[] { 8, 8, 8 }, 0, 0, 4, 4, Offset(Rgb8_Result4x4, 0, 0, 6, 6) }; - yield return new object[] { Rgb8_Bytes4x4, new ushort[] { 8, 8, 8 }, 1, 0, 4, 4, Offset(Rgb8_Result4x4, 1, 0, 6, 6) }; - yield return new object[] { Rgb8_Bytes4x4, new ushort[] { 8, 8, 8 }, 0, 1, 4, 4, Offset(Rgb8_Result4x4, 0, 1, 6, 6) }; - yield return new object[] { Rgb8_Bytes4x4, new ushort[] { 8, 8, 8 }, 1, 1, 4, 4, Offset(Rgb8_Result4x4, 1, 1, 6, 6) }; + yield return new object[] { rgb8_Bytes4x4, new ushort[] { 8, 8, 8 }, 0, 0, 4, 4, rgb8_Result4x4 }; + yield return new object[] { rgb8_Bytes4x4, new ushort[] { 8, 8, 8 }, 0, 0, 4, 4, Offset(rgb8_Result4x4, 0, 0, 6, 6) }; + yield return new object[] { rgb8_Bytes4x4, new ushort[] { 8, 8, 8 }, 1, 0, 4, 4, Offset(rgb8_Result4x4, 1, 0, 6, 6) }; + yield return new object[] { rgb8_Bytes4x4, new ushort[] { 8, 8, 8 }, 0, 1, 4, 4, Offset(rgb8_Result4x4, 0, 1, 6, 6) }; + yield return new object[] { rgb8_Bytes4x4, new ushort[] { 8, 8, 8 }, 1, 1, 4, 4, Offset(rgb8_Result4x4, 1, 1, 6, 6) }; } } - private static Rgba32 Rgb484_000 = new Rgba32(0, 0, 0, 255); - private static Rgba32 Rgb484_444 = new Rgba32(68, 64, 68, 255); - private static Rgba32 Rgb484_888 = new Rgba32(136, 128, 136, 255); - private static Rgba32 Rgb484_CCC = new Rgba32(204, 192, 204, 255); - private static Rgba32 Rgb484_FFF = new Rgba32(255, 255, 255, 255); - private static Rgba32 Rgb484_F00 = new Rgba32(255, 0, 0, 255); - private static Rgba32 Rgb484_0F0 = new Rgba32(0, 255, 0, 255); - private static Rgba32 Rgb484_00F = new Rgba32(0, 0, 255, 255); - private static Rgba32 Rgb484_F0F = new Rgba32(255, 0, 255, 255); - private static Rgba32 Rgb484_400 = new Rgba32(68, 0, 0, 255); - private static Rgba32 Rgb484_800 = new Rgba32(136, 0, 0, 255); - private static Rgba32 Rgb484_C00 = new Rgba32(204, 0, 0, 255); - private static Rgba32 Rgb484_48C = new Rgba32(68, 128, 204, 255); - - private static byte[] Rgb484_Bytes4x4 = new byte[] { 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, - 0xF0, 0x00, 0x0F, 0xF0, 0x00, 0x0F, 0xF0, 0x0F, - 0x40, 0x00, 0x80, 0x00, 0xC0, 0x00, 0x48, 0x0C, - 0x00, 0x00, 0x44, 0x04, 0x88, 0x08, 0xCC, 0x0C }; - - private static Rgba32[][] Rgb484_Result4x4 = new[] { new[] { Rgb484_000, Rgb484_FFF, Rgb484_000, Rgb484_FFF }, - new[] { Rgb484_F00, Rgb484_0F0, Rgb484_00F, Rgb484_F0F }, - new[] { Rgb484_400, Rgb484_800, Rgb484_C00, Rgb484_48C }, - new[] { Rgb484_000, Rgb484_444, Rgb484_888, Rgb484_CCC }}; + private static Rgba32 rgb484_000 = new Rgba32(0, 0, 0, 255); + private static Rgba32 rgb484_444 = new Rgba32(68, 64, 68, 255); + private static Rgba32 rgb484_888 = new Rgba32(136, 128, 136, 255); + private static Rgba32 rgb484_CCC = new Rgba32(204, 192, 204, 255); + private static Rgba32 rgb484_FFF = new Rgba32(255, 255, 255, 255); + private static Rgba32 rgb484_F00 = new Rgba32(255, 0, 0, 255); + private static Rgba32 rgb484_0F0 = new Rgba32(0, 255, 0, 255); + private static Rgba32 rgb484_00F = new Rgba32(0, 0, 255, 255); + private static Rgba32 rgb484_F0F = new Rgba32(255, 0, 255, 255); + private static Rgba32 rgb484_400 = new Rgba32(68, 0, 0, 255); + private static Rgba32 rgb484_800 = new Rgba32(136, 0, 0, 255); + private static Rgba32 rgb484_C00 = new Rgba32(204, 0, 0, 255); + private static Rgba32 rgb484_48C = new Rgba32(68, 128, 204, 255); + + private static byte[] rgb484_Bytes4x4 = + { + 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, + 0xF0, 0x00, 0x0F, 0xF0, 0x00, 0x0F, 0xF0, 0x0F, + 0x40, 0x00, 0x80, 0x00, 0xC0, 0x00, 0x48, 0x0C, + 0x00, 0x00, 0x44, 0x04, 0x88, 0x08, 0xCC, 0x0C + }; + + private static Rgba32[][] rgb484_Result4x4 = + { + new[] { rgb484_000, rgb484_FFF, rgb484_000, rgb484_FFF }, + new[] { rgb484_F00, rgb484_0F0, rgb484_00F, rgb484_F0F }, + new[] { rgb484_400, rgb484_800, rgb484_C00, rgb484_48C }, + new[] { rgb484_000, rgb484_444, rgb484_888, rgb484_CCC } + }; public static IEnumerable Rgb484_Data { get { - yield return new object[] { Rgb484_Bytes4x4, new ushort[] { 4, 8, 4 }, 0, 0, 4, 4, Rgb484_Result4x4 }; - yield return new object[] { Rgb484_Bytes4x4, new ushort[] { 4, 8, 4 }, 0, 0, 4, 4, Offset(Rgb484_Result4x4, 0, 0, 6, 6) }; - yield return new object[] { Rgb484_Bytes4x4, new ushort[] { 4, 8, 4 }, 1, 0, 4, 4, Offset(Rgb484_Result4x4, 1, 0, 6, 6) }; - yield return new object[] { Rgb484_Bytes4x4, new ushort[] { 4, 8, 4 }, 0, 1, 4, 4, Offset(Rgb484_Result4x4, 0, 1, 6, 6) }; - yield return new object[] { Rgb484_Bytes4x4, new ushort[] { 4, 8, 4 }, 1, 1, 4, 4, Offset(Rgb484_Result4x4, 1, 1, 6, 6) }; + yield return new object[] { rgb484_Bytes4x4, new ushort[] { 4, 8, 4 }, 0, 0, 4, 4, rgb484_Result4x4 }; + yield return new object[] { rgb484_Bytes4x4, new ushort[] { 4, 8, 4 }, 0, 0, 4, 4, Offset(rgb484_Result4x4, 0, 0, 6, 6) }; + yield return new object[] { rgb484_Bytes4x4, new ushort[] { 4, 8, 4 }, 1, 0, 4, 4, Offset(rgb484_Result4x4, 1, 0, 6, 6) }; + yield return new object[] { rgb484_Bytes4x4, new ushort[] { 4, 8, 4 }, 0, 1, 4, 4, Offset(rgb484_Result4x4, 0, 1, 6, 6) }; + yield return new object[] { rgb484_Bytes4x4, new ushort[] { 4, 8, 4 }, 1, 1, 4, 4, Offset(rgb484_Result4x4, 1, 1, 6, 6) }; } } diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColorTests.cs index faea296d00..64e1aa077c 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColorTests.cs @@ -2,72 +2,104 @@ // Licensed under the Apache License, Version 2.0. using System.Collections.Generic; + using SixLabors.ImageSharp.Formats.Tiff; using SixLabors.ImageSharp.PixelFormats; + using Xunit; -namespace SixLabors.ImageSharp.Tests.Formats.Tiff +namespace SixLabors.ImageSharp.Tests.Formats.Tiff.PhotometricInterpretation { public class WhiteIsZeroTiffColorTests : PhotometricInterpretationTestBase { - private static Rgba32 Gray000 = new Rgba32(255, 255, 255, 255); - private static Rgba32 Gray128 = new Rgba32(127, 127, 127, 255); - private static Rgba32 Gray255 = new Rgba32(0, 0, 0, 255); - private static Rgba32 Gray0 = new Rgba32(255, 255, 255, 255); - private static Rgba32 Gray8 = new Rgba32(119, 119, 119, 255); - private static Rgba32 GrayF = new Rgba32(0, 0, 0, 255); - private static Rgba32 Bit0 = new Rgba32(255, 255, 255, 255); - private static Rgba32 Bit1 = new Rgba32(0, 0, 0, 255); - - private static readonly byte[] Bilevel_Bytes4x4 = new byte[] { 0b01010000, - 0b11110000, - 0b01110000, - 0b10010000 }; - - private static readonly Rgba32[][] Bilevel_Result4x4 = new[] { new[] { Bit0, Bit1, Bit0, Bit1 }, - new[] { Bit1, Bit1, Bit1, Bit1 }, - new[] { Bit0, Bit1, Bit1, Bit1 }, - new[] { Bit1, Bit0, Bit0, Bit1 }}; - - private static readonly byte[] Bilevel_Bytes12x4 = new byte[] { 0b01010101, 0b01010000, - 0b11111111, 0b11111111, - 0b01101001, 0b10100000, - 0b10010000, 0b01100000}; - - private static readonly Rgba32[][] Bilevel_Result12x4 = new[] { new[] { Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1 }, - new[] { Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1 }, - new[] { Bit0, Bit1, Bit1, Bit0, Bit1, Bit0, Bit0, Bit1, Bit1, Bit0, Bit1, Bit0 }, - new[] { Bit1, Bit0, Bit0, Bit1, Bit0, Bit0, Bit0, Bit0, Bit0, Bit1, Bit1, Bit0 }}; - - private static readonly byte[] Grayscale4_Bytes4x4 = new byte[] { 0x8F, 0x0F, - 0xFF, 0xFF, - 0x08, 0x8F, - 0xF0, 0xF8 }; - - private static readonly Rgba32[][] Grayscale4_Result4x4 = new[] { new[] { Gray8, GrayF, Gray0, GrayF }, - new[] { GrayF, GrayF, GrayF, GrayF }, - new[] { Gray0, Gray8, Gray8, GrayF }, - new[] { GrayF, Gray0, GrayF, Gray8 }}; - - private static readonly byte[] Grayscale4_Bytes3x4 = new byte[] { 0x8F, 0x00, - 0xFF, 0xF0, - 0x08, 0x80, - 0xF0, 0xF0 }; - - private static readonly Rgba32[][] Grayscale4_Result3x4 = new[] { new[] { Gray8, GrayF, Gray0 }, - new[] { GrayF, GrayF, GrayF }, - new[] { Gray0, Gray8, Gray8 }, - new[] { GrayF, Gray0, GrayF }}; - - private static readonly byte[] Grayscale8_Bytes4x4 = new byte[] { 128, 255, 000, 255, - 255, 255, 255, 255, - 000, 128, 128, 255, - 255, 000, 255, 128 }; - - private static readonly Rgba32[][] Grayscale8_Result4x4 = new[] { new[] { Gray128, Gray255, Gray000, Gray255 }, - new[] { Gray255, Gray255, Gray255, Gray255 }, - new[] { Gray000, Gray128, Gray128, Gray255 }, - new[] { Gray255, Gray000, Gray255, Gray128 }}; + private static Rgba32 gray000 = new Rgba32(255, 255, 255, 255); + private static Rgba32 gray128 = new Rgba32(127, 127, 127, 255); + private static Rgba32 gray255 = new Rgba32(0, 0, 0, 255); + private static Rgba32 gray0 = new Rgba32(255, 255, 255, 255); + private static Rgba32 gray8 = new Rgba32(119, 119, 119, 255); + private static Rgba32 grayF = new Rgba32(0, 0, 0, 255); + private static Rgba32 bit0 = new Rgba32(255, 255, 255, 255); + private static Rgba32 bit1 = new Rgba32(0, 0, 0, 255); + + private static readonly byte[] Bilevel_Bytes4x4 = + { + 0b01010000, + 0b11110000, + 0b01110000, + 0b10010000 + }; + + private static readonly Rgba32[][] Bilevel_Result4x4 = + { + new[] { bit0, bit1, bit0, bit1 }, + new[] { bit1, bit1, bit1, bit1 }, + new[] { bit0, bit1, bit1, bit1 }, + new[] { bit1, bit0, bit0, bit1 } + }; + + private static readonly byte[] Bilevel_Bytes12x4 = + { + 0b01010101, 0b01010000, + 0b11111111, 0b11111111, + 0b01101001, 0b10100000, + 0b10010000, 0b01100000 + }; + + private static readonly Rgba32[][] Bilevel_Result12x4 = + { + new[] { bit0, bit1, bit0, bit1, bit0, bit1, bit0, bit1, bit0, bit1, bit0, bit1 }, + new[] { bit1, bit1, bit1, bit1, bit1, bit1, bit1, bit1, bit1, bit1, bit1, bit1 }, + new[] { bit0, bit1, bit1, bit0, bit1, bit0, bit0, bit1, bit1, bit0, bit1, bit0 }, + new[] { bit1, bit0, bit0, bit1, bit0, bit0, bit0, bit0, bit0, bit1, bit1, bit0 } + }; + + private static readonly byte[] Grayscale4_Bytes4x4 = + { + 0x8F, 0x0F, + 0xFF, 0xFF, + 0x08, 0x8F, + 0xF0, 0xF8 + }; + + private static readonly Rgba32[][] Grayscale4_Result4x4 = + { + new[] { gray8, grayF, gray0, grayF }, + new[] { grayF, grayF, grayF, grayF }, + new[] { gray0, gray8, gray8, grayF }, + new[] { grayF, gray0, grayF, gray8 } + }; + + private static readonly byte[] Grayscale4_Bytes3x4 = + { + 0x8F, 0x00, + 0xFF, 0xF0, + 0x08, 0x80, + 0xF0, 0xF0 + }; + + private static readonly Rgba32[][] Grayscale4_Result3x4 = + { + new[] { gray8, grayF, gray0 }, + new[] { grayF, grayF, grayF }, + new[] { gray0, gray8, gray8 }, + new[] { grayF, gray0, grayF } + }; + + private static readonly byte[] Grayscale8_Bytes4x4 = + { + 128, 255, 000, 255, + 255, 255, 255, 255, + 000, 128, 128, 255, + 255, 000, 255, 128 + }; + + private static readonly Rgba32[][] Grayscale8_Result4x4 = + { + new[] { gray128, gray255, gray000, gray255 }, + new[] { gray255, gray255, gray255, gray255 }, + new[] { gray000, gray128, gray128, gray255 }, + new[] { gray255, gray000, gray255, gray128 } + }; public static IEnumerable Bilevel_Data { diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffMetadataTests.cs index 3df4b45cbb..3affbce4c4 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffMetadataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffMetadataTests.cs @@ -70,18 +70,18 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff Assert.Equal(TiffPlanarConfiguration.Chunky, frame.PlanarConfiguration); Assert.Equal(TiffResolutionUnit.Inch, frame.ResolutionUnit); Assert.Equal("IrfanView", frame.Software); - Assert.Equal(null, frame.DateTime); + Assert.Null(frame.DateTime); Assert.Equal("This is author1;Author2", frame.Artist); - Assert.Equal(null, frame.HostComputer); + Assert.Null(frame.HostComputer); Assert.Equal(48, frame.ColorMap.Length); Assert.Equal(10537, frame.ColorMap[0]); Assert.Equal(14392, frame.ColorMap[1]); Assert.Equal(58596, frame.ColorMap[46]); Assert.Equal(3855, frame.ColorMap[47]); - Assert.Equal(null, frame.ExtraSamples); + Assert.Null(frame.ExtraSamples); Assert.Equal(TiffPredictor.None, frame.Predictor); - Assert.Equal(null, frame.SampleFormat); + Assert.Null(frame.SampleFormat); Assert.Equal("This is Авторские права", frame.Copyright); } } @@ -100,7 +100,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff TiffFrameMetadata frame0 = image.Frames[0].Metadata.GetTiffMetadata(); Assert.Equal(TiffNewSubfileType.FullImage, frame0.NewSubfileType); - Assert.Equal(null, frame0.SubfileType); + Assert.Null(frame0.SubfileType); Assert.Equal(255u, frame0.Width); Assert.Equal(255u, frame0.Height); diff --git a/tests/ImageSharp.Tests/Formats/Tiff/Utils/TiffWriterTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/Utils/TiffWriterTests.cs index 15b4955565..7336d0b3f9 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/Utils/TiffWriterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/Utils/TiffWriterTests.cs @@ -8,7 +8,7 @@ using SixLabors.ImageSharp.Memory; using Xunit; -namespace SixLabors.ImageSharp.Tests.Formats.Tiff +namespace SixLabors.ImageSharp.Tests.Formats.Tiff.Utils { [Trait("Category", "Tiff")] public class TiffWriterTests @@ -71,7 +71,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff { using var stream = new MemoryStream(); using var writer = new TiffWriter(stream, MemoryAllocator, Configuration); - writer.Write((uint)12345678); + writer.Write(12345678U); Assert.Equal(new byte[] { 0x4E, 0x61, 0xBC, 0x00 }, stream.ToArray()); } @@ -99,13 +99,13 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff using (var writer = new TiffWriter(stream, MemoryAllocator, Configuration)) { - writer.Write((uint)0x11111111); + writer.Write(0x11111111); long marker = writer.PlaceMarker(); - writer.Write((uint)0x33333333); + writer.Write(0x33333333); writer.WriteMarker(marker, 0x12345678); - writer.Write((uint)0x44444444); + writer.Write(0x44444444); } Assert.Equal( diff --git a/tests/ImageSharp.Tests/TestUtilities/ByteArrayUtility.cs b/tests/ImageSharp.Tests/TestUtilities/ByteArrayUtility.cs index 27dfdb8a21..501651285d 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ByteArrayUtility.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ByteArrayUtility.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Tests +namespace SixLabors.ImageSharp.Tests.TestUtilities { using System; @@ -9,9 +9,9 @@ namespace SixLabors.ImageSharp.Tests { public static byte[] WithByteOrder(this byte[] bytes, bool isLittleEndian) { - if (BitConverter.IsLittleEndian != isLittleEndian) + if (isLittleEndian != BitConverter.IsLittleEndian) { - byte[] reversedBytes = new byte[bytes.Length]; + var reversedBytes = new byte[bytes.Length]; Array.Copy(bytes, reversedBytes, bytes.Length); Array.Reverse(reversedBytes); return reversedBytes; @@ -22,4 +22,4 @@ namespace SixLabors.ImageSharp.Tests } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/TestUtilities/ByteBuffer.cs b/tests/ImageSharp.Tests/TestUtilities/ByteBuffer.cs index 92b59271f9..bbb75a9cf2 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ByteBuffer.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ByteBuffer.cs @@ -1,15 +1,15 @@ // Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Tests +namespace SixLabors.ImageSharp.Tests.TestUtilities { using System; using System.Collections.Generic; public class ByteBuffer { - List bytes = new List(); - bool isLittleEndian; + private readonly List bytes = new List(); + private readonly bool isLittleEndian; public ByteBuffer(bool isLittleEndian) { @@ -18,22 +18,22 @@ namespace SixLabors.ImageSharp.Tests public void AddByte(byte value) { - bytes.Add(value); + this.bytes.Add(value); } public void AddUInt16(ushort value) { - bytes.AddRange(BitConverter.GetBytes(value).WithByteOrder(isLittleEndian)); + this.bytes.AddRange(BitConverter.GetBytes(value).WithByteOrder(this.isLittleEndian)); } public void AddUInt32(uint value) { - bytes.AddRange(BitConverter.GetBytes(value).WithByteOrder(isLittleEndian)); + this.bytes.AddRange(BitConverter.GetBytes(value).WithByteOrder(this.isLittleEndian)); } public byte[] ToArray() { - return bytes.ToArray(); + return this.bytes.ToArray(); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.Formats.cs b/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.Formats.cs index 1bcacc4de4..36f8698441 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.Formats.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.Formats.cs @@ -57,8 +57,7 @@ namespace SixLabors.ImageSharp.Tests new JpegConfigurationModule(), new GifConfigurationModule(), new TgaConfigurationModule(), - new TiffConfigurationModule() - ); + new TiffConfigurationModule()); // Magick codecs should work on all platforms IImageEncoder pngEncoder = IsWindows ? (IImageEncoder)SystemDrawingReferenceEncoder.Png : new PngEncoder();