Browse Source

Update namespaces and naming

pull/1570/head
Andrew Wilkinson 9 years ago
parent
commit
4f801ae9af
  1. 20
      src/ImageSharp/Formats/Tiff/ImageExtensions.cs
  2. 9
      src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero1TiffColor.cs
  3. 9
      src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero4TiffColor.cs
  4. 9
      src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero8TiffColor.cs
  5. 7
      src/ImageSharp/Formats/Tiff/TiffDecoder.cs
  6. 93
      src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs
  7. 15
      src/ImageSharp/Formats/Tiff/TiffEncoder.cs
  8. 14
      tests/ImageSharp.Formats.Tiff.Tests/Formats/Tiff/PhotometricInterpretation/PhotometricInterpretationTestBase.cs
  9. 32
      tests/ImageSharp.Formats.Tiff.Tests/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColorTests.cs
  10. 2
      tests/ImageSharp.Formats.Tiff.Tests/Formats/Tiff/TiffDecoderHeaderTests.cs
  11. 8
      tests/ImageSharp.Formats.Tiff.Tests/Formats/Tiff/TiffDecoderImageTests.cs

20
src/ImageSharp/Formats/Tiff/ImageExtensions.cs

@ -6,26 +6,26 @@
namespace ImageSharp
{
using System.IO;
using Formats;
using ImageSharp.PixelFormats;
/// <summary>
/// Extension methods for the <see cref="Image{TColor}"/> type.
/// Extension methods for the <see cref="Image{TPixel}"/> type.
/// </summary>
public static partial class ImageExtensions
{
/// <summary>
/// Saves the image to the given stream with the tiff format.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="stream">The stream to save the image to.</param>
/// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception>
/// <returns>
/// The <see cref="Image{TColor}"/>.
/// The <see cref="Image{TPixel}"/>.
/// </returns>
public static Image<TColor> SaveAsTiff<TColor>(this Image<TColor> source, Stream stream)
where TColor : struct, IPixel<TColor>
public static Image<TPixel> SaveAsTiff<TPixel>(this Image<TPixel> source, Stream stream)
where TPixel : struct, IPixel<TPixel>
{
return SaveAsTiff(source, stream, null);
}
@ -33,16 +33,16 @@ namespace ImageSharp
/// <summary>
/// Saves the image to the given stream with the tiff format.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="stream">The stream to save the image to.</param>
/// <param name="options">The options for the encoder.</param>
/// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception>
/// <returns>
/// The <see cref="Image{TColor}"/>.
/// The <see cref="Image{TPixel}"/>.
/// </returns>
public static Image<TColor> SaveAsTiff<TColor>(this Image<TColor> source, Stream stream, ITiffEncoderOptions options)
where TColor : struct, IPixel<TColor>
public static Image<TPixel> SaveAsTiff<TPixel>(this Image<TPixel> source, Stream stream, ITiffEncoderOptions options)
where TPixel : struct, IPixel<TPixel>
{
TiffEncoder encoder = new TiffEncoder();
encoder.Encode(source, stream, options);

9
src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero1TiffColor.cs

@ -8,6 +8,7 @@ namespace ImageSharp.Formats.Tiff
using System;
using System.Runtime.CompilerServices;
using ImageSharp;
using ImageSharp.PixelFormats;
/// <summary>
/// Implements the 'WhiteIsZero' photometric interpretation (optimised for bilevel images).
@ -17,7 +18,7 @@ namespace ImageSharp.Formats.Tiff
/// <summary>
/// Decodes pixel data using the current photometric interpretation.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="data">The buffer to read image data from.</param>
/// <param name="pixels">The image buffer to write pixels to.</param>
/// <param name="left">The x-coordinate of the left-hand side of the image block.</param>
@ -25,10 +26,10 @@ namespace ImageSharp.Formats.Tiff
/// <param name="width">The width of the image block.</param>
/// <param name="height">The height of the image block.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Decode<TColor>(byte[] data, PixelAccessor<TColor> pixels, int left, int top, int width, int height)
where TColor : struct, IPixel<TColor>
public static void Decode<TPixel>(byte[] data, PixelAccessor<TPixel> pixels, int left, int top, int width, int height)
where TPixel : struct, IPixel<TPixel>
{
TColor color = default(TColor);
TPixel color = default(TPixel);
uint offset = 0;

9
src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero4TiffColor.cs

@ -7,6 +7,7 @@ namespace ImageSharp.Formats.Tiff
{
using System.Runtime.CompilerServices;
using ImageSharp;
using ImageSharp.PixelFormats;
/// <summary>
/// Implements the 'WhiteIsZero' photometric interpretation (optimised for 4-bit grayscale images).
@ -16,7 +17,7 @@ namespace ImageSharp.Formats.Tiff
/// <summary>
/// Decodes pixel data using the current photometric interpretation.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="data">The buffer to read image data from.</param>
/// <param name="pixels">The image buffer to write pixels to.</param>
/// <param name="left">The x-coordinate of the left-hand side of the image block.</param>
@ -24,10 +25,10 @@ namespace ImageSharp.Formats.Tiff
/// <param name="width">The width of the image block.</param>
/// <param name="height">The height of the image block.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Decode<TColor>(byte[] data, PixelAccessor<TColor> pixels, int left, int top, int width, int height)
where TColor : struct, IPixel<TColor>
public static void Decode<TPixel>(byte[] data, PixelAccessor<TPixel> pixels, int left, int top, int width, int height)
where TPixel : struct, IPixel<TPixel>
{
TColor color = default(TColor);
TPixel color = default(TPixel);
uint offset = 0;
bool isOddWidth = (width & 1) == 1;

9
src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero8TiffColor.cs

@ -7,6 +7,7 @@ namespace ImageSharp.Formats.Tiff
{
using System.Runtime.CompilerServices;
using ImageSharp;
using ImageSharp.PixelFormats;
/// <summary>
/// Implements the 'WhiteIsZero' photometric interpretation (optimised for 8-bit grayscale images).
@ -16,7 +17,7 @@ namespace ImageSharp.Formats.Tiff
/// <summary>
/// Decodes pixel data using the current photometric interpretation.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="data">The buffer to read image data from.</param>
/// <param name="pixels">The image buffer to write pixels to.</param>
/// <param name="left">The x-coordinate of the left-hand side of the image block.</param>
@ -24,10 +25,10 @@ namespace ImageSharp.Formats.Tiff
/// <param name="width">The width of the image block.</param>
/// <param name="height">The height of the image block.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Decode<TColor>(byte[] data, PixelAccessor<TColor> pixels, int left, int top, int width, int height)
where TColor : struct, IPixel<TColor>
public static void Decode<TPixel>(byte[] data, PixelAccessor<TPixel> pixels, int left, int top, int width, int height)
where TPixel : struct, IPixel<TPixel>
{
TColor color = default(TColor);
TPixel color = default(TPixel);
uint offset = 0;

7
src/ImageSharp/Formats/Tiff/TiffDecoder.cs

@ -6,6 +6,7 @@
namespace ImageSharp.Formats
{
using System.IO;
using ImageSharp.PixelFormats;
/// <summary>
/// Image decoder for generating an image out of a TIFF stream.
@ -13,14 +14,14 @@ namespace ImageSharp.Formats
public class TiffDecoder : IImageDecoder
{
/// <inheritdoc/>
public Image<TColor> Decode<TColor>(Configuration configuration, Stream stream, IDecoderOptions options)
where TColor : struct, IPixel<TColor>
public Image<TPixel> Decode<TPixel>(Configuration configuration, Stream stream, IDecoderOptions options)
where TPixel : struct, IPixel<TPixel>
{
Guard.NotNull(stream, "stream");
using (TiffDecoderCore decoder = new TiffDecoderCore(options, configuration))
{
return decoder.Decode<TColor>(stream);
return decoder.Decode<TPixel>(stream);
}
}
}

93
src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs

@ -10,6 +10,7 @@ namespace ImageSharp.Formats
using System.IO;
using System.Text;
using ImageSharp.Formats.Tiff;
using ImageSharp.PixelFormats;
/// <summary>
/// Performs the tiff decoding operation.
@ -82,17 +83,17 @@ namespace ImageSharp.Formats
/// Decodes the image from the specified <see cref="Stream"/> and sets
/// the data to image.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="stream">The stream, where the image should be.</param>
/// <returns>The decoded image.</returns>
public Image<TColor> Decode<TColor>(Stream stream)
where TColor : struct, IPixel<TColor>
public Image<TPixel> Decode<TPixel>(Stream stream)
where TPixel : struct, IPixel<TPixel>
{
this.InputStream = stream;
uint firstIfdOffset = this.ReadHeader();
TiffIfd firstIfd = this.ReadIfd(firstIfdOffset);
Image<TColor> image = this.DecodeImage<TColor>(firstIfd);
Image<TPixel> image = this.DecodeImage<TPixel>(firstIfd);
return image;
}
@ -175,11 +176,11 @@ namespace ImageSharp.Formats
/// <summary>
/// Decodes the image data from a specified IFD.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="ifd">The IFD to read the image from.</param>
/// <returns>The decoded image.</returns>
public Image<TColor> DecodeImage<TColor>(TiffIfd ifd)
where TColor : struct, IPixel<TColor>
public Image<TPixel> DecodeImage<TPixel>(TiffIfd ifd)
where TPixel : struct, IPixel<TPixel>
{
if (!ifd.TryGetIfdEntry(TiffTags.ImageLength, out TiffIfdEntry imageLengthEntry)
|| !ifd.TryGetIfdEntry(TiffTags.ImageWidth, out TiffIfdEntry imageWidthEntry))
@ -190,7 +191,7 @@ namespace ImageSharp.Formats
int width = (int)this.ReadUnsignedInteger(ref imageWidthEntry);
int height = (int)this.ReadUnsignedInteger(ref imageLengthEntry);
Image<TColor> image = Image.Create<TColor>(width, height, this.configuration);
Image<TPixel> image = new Image<TPixel>(this.configuration, width, height);
TiffResolutionUnit resolutionUnit = TiffResolutionUnit.Inch;
if (ifd.TryGetIfdEntry(TiffTags.ResolutionUnit, out TiffIfdEntry resolutionUnitEntry))
@ -224,46 +225,12 @@ namespace ImageSharp.Formats
int rowsPerStrip = (int)this.ReadUnsignedInteger(ref rowsPerStripEntry);
uint[] stripOffsets = this.ReadUnsignedIntegerArray(ref stripOffsetsEntry);
uint[] stripByteCounts = this.ReadUnsignedIntegerArray(ref stripByteCountsEntry);
DecodeImageStrips(image, rowsPerStrip, stripOffsets, stripByteCounts);
this.DecodeImageStrips(image, rowsPerStrip, stripOffsets, stripByteCounts);
}
return image;
}
/// <summary>
/// Decodes the image data for strip encoded data.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <param name="image">The image to decode data into.</param>
/// <param name="rowsPerStrip">The number of rows per strip of data.</param>
/// <param name="stripOffsets">An array of byte offsets to each strip in the image.</param>
/// <param name="stripByteCounts">An array of the size of each strip (in bytes).</param>
private void DecodeImageStrips<TColor>(Image<TColor> image, int rowsPerStrip, uint[] stripOffsets, uint[] stripByteCounts)
where TColor : struct, IPixel<TColor>
{
int uncompressedStripSize = this.CalculateImageBufferSize(image.Width, rowsPerStrip);
using (PixelAccessor<TColor> pixels = image.Lock())
{
byte[] stripBytes = ArrayPool<byte>.Shared.Rent(uncompressedStripSize);
try
{
for (int i = 0; i < stripOffsets.Length; i++)
{
int stripHeight = i < stripOffsets.Length - 1 || image.Height % rowsPerStrip == 0 ? rowsPerStrip : image.Height % rowsPerStrip;
this.DecompressImageBlock(stripOffsets[i], stripByteCounts[i], stripBytes);
this.ProcessImageBlock(stripBytes, pixels, 0, rowsPerStrip * i, image.Width, stripHeight);
}
}
finally
{
ArrayPool<byte>.Shared.Return(stripBytes);
}
}
}
/// <summary>
/// Determines the TIFF compression and color types, and reads any associated parameters.
/// </summary>
@ -412,15 +379,15 @@ namespace ImageSharp.Formats
/// <summary>
/// Decodes pixel data using the current photometric interpretation.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="data">The buffer to read image data from.</param>
/// <param name="pixels">The image buffer to write pixels to.</param>
/// <param name="left">The x-coordinate of the left-hand side of the image block.</param>
/// <param name="top">The y-coordinate of the top of the image block.</param>
/// <param name="width">The width of the image block.</param>
/// <param name="height">The height of the image block.</param>
public void ProcessImageBlock<TColor>(byte[] data, PixelAccessor<TColor> pixels, int left, int top, int width, int height)
where TColor : struct, IPixel<TColor>
public void ProcessImageBlock<TPixel>(byte[] data, PixelAccessor<TPixel> pixels, int left, int top, int width, int height)
where TPixel : struct, IPixel<TPixel>
{
switch (this.ColorType)
{
@ -984,5 +951,39 @@ namespace ImageSharp.Formats
return BitConverter.ToDouble(buffer, 0);
}
/// <summary>
/// Decodes the image data for strip encoded data.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="image">The image to decode data into.</param>
/// <param name="rowsPerStrip">The number of rows per strip of data.</param>
/// <param name="stripOffsets">An array of byte offsets to each strip in the image.</param>
/// <param name="stripByteCounts">An array of the size of each strip (in bytes).</param>
private void DecodeImageStrips<TPixel>(Image<TPixel> image, int rowsPerStrip, uint[] stripOffsets, uint[] stripByteCounts)
where TPixel : struct, IPixel<TPixel>
{
int uncompressedStripSize = this.CalculateImageBufferSize(image.Width, rowsPerStrip);
using (PixelAccessor<TPixel> pixels = image.Lock())
{
byte[] stripBytes = ArrayPool<byte>.Shared.Rent(uncompressedStripSize);
try
{
for (int i = 0; i < stripOffsets.Length; i++)
{
int stripHeight = i < stripOffsets.Length - 1 || image.Height % rowsPerStrip == 0 ? rowsPerStrip : image.Height % rowsPerStrip;
this.DecompressImageBlock(stripOffsets[i], stripByteCounts[i], stripBytes);
this.ProcessImageBlock(stripBytes, pixels, 0, rowsPerStrip * i, image.Width, stripHeight);
}
}
finally
{
ArrayPool<byte>.Shared.Return(stripBytes);
}
}
}
}
}

15
src/ImageSharp/Formats/Tiff/TiffEncoder.cs

@ -7,6 +7,7 @@ namespace ImageSharp.Formats
{
using System;
using System.IO;
using ImageSharp.PixelFormats;
/// <summary>
/// Encoder for writing the data image to a stream in TIFF format.
@ -14,8 +15,8 @@ namespace ImageSharp.Formats
public class TiffEncoder : IImageEncoder
{
/// <inheritdoc/>
public void Encode<TColor>(Image<TColor> image, Stream stream, IEncoderOptions options)
where TColor : struct, IPixel<TColor>
public void Encode<TPixel>(Image<TPixel> image, Stream stream, IEncoderOptions options)
where TPixel : struct, IPixel<TPixel>
{
ITiffEncoderOptions tiffOptions = TiffEncoderOptions.Create(options);
@ -23,14 +24,14 @@ namespace ImageSharp.Formats
}
/// <summary>
/// Encodes the image to the specified stream from the <see cref="Image{TColor}"/>.
/// Encodes the image to the specified stream from the <see cref="Image{TPixel}"/>.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <param name="image">The <see cref="Image{TColor}"/> to encode from.</param>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="image">The <see cref="Image{TPixel}"/> to encode from.</param>
/// <param name="stream">The <see cref="Stream"/> to encode the image data to.</param>
/// <param name="options">The options for the encoder.</param>
public void Encode<TColor>(Image<TColor> image, Stream stream, ITiffEncoderOptions options)
where TColor : struct, IPixel<TColor>
public void Encode<TPixel>(Image<TPixel> image, Stream stream, ITiffEncoderOptions options)
where TPixel : struct, IPixel<TPixel>
{
throw new NotImplementedException();
}

14
tests/ImageSharp.Formats.Tiff.Tests/Formats/Tiff/PhotometricInterpretation/PhotometricInterpretationTestBase.cs

@ -10,16 +10,16 @@ namespace ImageSharp.Tests
public abstract class PhotometricInterpretationTestBase
{
public static Color[][] Offset(Color[][] input, int xOffset, int yOffset, int width, int height)
public static Rgba32[][] Offset(Rgba32[][] input, int xOffset, int yOffset, int width, int height)
{
int inputHeight = input.Length;
int inputWidth = input[0].Length;
Color[][] output = new Color[height][];
Rgba32[][] output = new Rgba32[height][];
for (int y = 0; y < output.Length; y++)
{
output[y] = new Color[width];
output[y] = new Rgba32[width];
}
for (int y = 0; y < inputHeight; y++)
@ -33,18 +33,18 @@ namespace ImageSharp.Tests
return output;
}
public static void AssertDecode(Color[][] expectedResult, Action<PixelAccessor<Color>> decodeAction)
public static void AssertDecode(Rgba32[][] expectedResult, Action<PixelAccessor<Rgba32>> decodeAction)
{
int resultWidth = expectedResult[0].Length;
int resultHeight = expectedResult.Length;
Image image = new Image(resultWidth, resultHeight);
Image<Rgba32> image = new Image<Rgba32>(resultWidth, resultHeight);
using (PixelAccessor<Color> pixels = image.Lock())
using (PixelAccessor<Rgba32> pixels = image.Lock())
{
decodeAction(pixels);
}
using (PixelAccessor<Color> pixels = image.Lock())
using (PixelAccessor<Rgba32> pixels = image.Lock())
{
for (int y = 0; y < resultHeight; y++)
{

32
tests/ImageSharp.Formats.Tiff.Tests/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColorTests.cs

@ -12,21 +12,21 @@ namespace ImageSharp.Tests
public class WhiteIsZeroTiffColorTests : PhotometricInterpretationTestBase
{
private static Color Gray000 = new Color(255, 255, 255, 255);
private static Color Gray128 = new Color(127, 127, 127, 255);
private static Color Gray255 = new Color(0, 0, 0, 255);
private static Color Gray0 = new Color(255, 255, 255, 255);
private static Color Gray8 = new Color(119, 119, 119, 255);
private static Color GrayF = new Color(0, 0, 0, 255);
private static Color Bit0 = new Color(255, 255, 255, 255);
private static Color Bit1 = new Color(0, 0, 0, 255);
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 byte[] Bilevel_Bytes4x4 = new byte[] { 0b01010000,
0b11110000,
0b01110000,
0b10010000 };
private static Color[][] Bilevel_Result4x4 = new[] { new[] { Bit0, Bit1, Bit0, Bit1 },
private static Rgba32[][] Bilevel_Result4x4 = new[] { new[] { Bit0, Bit1, Bit0, Bit1 },
new[] { Bit1, Bit1, Bit1, Bit1 },
new[] { Bit0, Bit1, Bit1, Bit1 },
new[] { Bit1, Bit0, Bit0, Bit1 }};
@ -36,7 +36,7 @@ namespace ImageSharp.Tests
0b01101001, 0b10100000,
0b10010000, 0b01100000};
private static Color[][] Bilevel_Result12x4 = new[] { new[] { Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1 },
private static 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 }};
@ -46,7 +46,7 @@ namespace ImageSharp.Tests
0x08, 0x8F,
0xF0, 0xF8 };
private static Color[][] Grayscale4_Result4x4 = new[] { new[] { Gray8, GrayF, Gray0, GrayF },
private static Rgba32[][] Grayscale4_Result4x4 = new[] { new[] { Gray8, GrayF, Gray0, GrayF },
new[] { GrayF, GrayF, GrayF, GrayF },
new[] { Gray0, Gray8, Gray8, GrayF },
new[] { GrayF, Gray0, GrayF, Gray8 }};
@ -56,7 +56,7 @@ namespace ImageSharp.Tests
0x08, 0x80,
0xF0, 0xF0 };
private static Color[][] Grayscale4_Result3x4 = new[] { new[] { Gray8, GrayF, Gray0 },
private static Rgba32[][] Grayscale4_Result3x4 = new[] { new[] { Gray8, GrayF, Gray0 },
new[] { GrayF, GrayF, GrayF },
new[] { Gray0, Gray8, Gray8 },
new[] { GrayF, Gray0, GrayF }};
@ -66,7 +66,7 @@ namespace ImageSharp.Tests
000, 128, 128, 255,
255, 000, 255, 128 };
private static Color[][] Grayscale8_Result4x4 = new[] { new[] { Gray128, Gray255, Gray000, Gray255 },
private static Rgba32[][] Grayscale8_Result4x4 = new[] { new[] { Gray128, Gray255, Gray000, Gray255 },
new[] { Gray255, Gray255, Gray255, Gray255 },
new[] { Gray000, Gray128, Gray128, Gray255 },
new[] { Gray255, Gray000, Gray255, Gray128 }};
@ -121,7 +121,7 @@ namespace ImageSharp.Tests
[Theory]
[MemberData(nameof(Bilevel_Data))]
public void Decode_WritesPixelData_Bilevel(byte[] inputData, int bitsPerSample, int left, int top, int width, int height, Color[][] expectedResult)
public void Decode_WritesPixelData_Bilevel(byte[] inputData, int bitsPerSample, int left, int top, int width, int height, Rgba32[][] expectedResult)
{
AssertDecode(expectedResult, pixels =>
{
@ -131,7 +131,7 @@ namespace ImageSharp.Tests
[Theory]
[MemberData(nameof(Grayscale4_Data))]
public void Decode_WritesPixelData_4Bit(byte[] inputData, int bitsPerSample, int left, int top, int width, int height, Color[][] expectedResult)
public void Decode_WritesPixelData_4Bit(byte[] inputData, int bitsPerSample, int left, int top, int width, int height, Rgba32[][] expectedResult)
{
AssertDecode(expectedResult, pixels =>
{
@ -141,7 +141,7 @@ namespace ImageSharp.Tests
[Theory]
[MemberData(nameof(Grayscale8_Data))]
public void Decode_WritesPixelData_8Bit(byte[] inputData, int bitsPerSample, int left, int top, int width, int height, Color[][] expectedResult)
public void Decode_WritesPixelData_8Bit(byte[] inputData, int bitsPerSample, int left, int top, int width, int height, Rgba32[][] expectedResult)
{
AssertDecode(expectedResult, pixels =>
{

2
tests/ImageSharp.Formats.Tiff.Tests/Formats/Tiff/TiffDecoderHeaderTests.cs

@ -111,7 +111,7 @@ namespace ImageSharp.Tests
private void TestDecode(TiffDecoder decoder, Stream stream)
{
Configuration.Default.AddImageFormat(new TiffFormat());
Image<Color> image = decoder.Decode<Color>(Configuration.Default, stream, null);
Image<Rgba32> image = decoder.Decode<Rgba32>(Configuration.Default, stream, null);
}
}
}

8
tests/ImageSharp.Formats.Tiff.Tests/Formats/Tiff/TiffDecoderImageTests.cs

@ -31,7 +31,7 @@ namespace ImageSharp.Tests
TiffDecoderCore decoder = new TiffDecoderCore(stream, isLittleEndian, null, null);
TiffIfd ifd = decoder.ReadIfd(0);
Image<Color> image = decoder.DecodeImage<Color>(ifd);
Image<Rgba32> image = decoder.DecodeImage<Rgba32>(ifd);
Assert.Equal(ImageWidth, image.Width);
Assert.Equal(ImageHeight, image.Height);
@ -82,7 +82,7 @@ namespace ImageSharp.Tests
TiffDecoderCore decoder = new TiffDecoderCore(stream, isLittleEndian, null, null);
TiffIfd ifd = decoder.ReadIfd(0);
Image<Color> image = decoder.DecodeImage<Color>(ifd);
Image<Rgba32> image = decoder.DecodeImage<Rgba32>(ifd);
Assert.Equal(expectedHorizonalResolution, image.MetaData.HorizontalResolution, 10);
Assert.Equal(expectedVerticalResolution, image.MetaData.VerticalResolution, 10);
@ -99,7 +99,7 @@ namespace ImageSharp.Tests
TiffDecoderCore decoder = new TiffDecoderCore(stream, isLittleEndian, null, null);
TiffIfd ifd = decoder.ReadIfd(0);
var e = Assert.Throws<ImageFormatException>(() => decoder.DecodeImage<Color>(ifd));
var e = Assert.Throws<ImageFormatException>(() => decoder.DecodeImage<Rgba32>(ifd));
Assert.Equal("The TIFF IFD does not specify the image dimensions.", e.Message);
}
@ -115,7 +115,7 @@ namespace ImageSharp.Tests
TiffDecoderCore decoder = new TiffDecoderCore(stream, isLittleEndian, null, null);
TiffIfd ifd = decoder.ReadIfd(0);
var e = Assert.Throws<ImageFormatException>(() => decoder.DecodeImage<Color>(ifd));
var e = Assert.Throws<ImageFormatException>(() => decoder.DecodeImage<Rgba32>(ifd));
Assert.Equal("The TIFF IFD does not specify the image dimensions.", e.Message);
}

Loading…
Cancel
Save