Skip to content

Commit bd9e1ee

Browse files
committed
Added unit tests and 16 bit grayscale images
1 parent a1a2cec commit bd9e1ee

File tree

6 files changed

+19
-8
lines changed

6 files changed

+19
-8
lines changed

tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public void ThrowsNotSupported<TPixel>(TestImageProvider<TPixel> provider)
2727
[InlineData(RgbUncompressed, 24, 256, 256, 300, 300, PixelResolutionUnit.PixelsPerInch)]
2828
[InlineData(SmallRgbDeflate, 24, 32, 32, 96, 96, PixelResolutionUnit.PixelsPerInch)]
2929
[InlineData(Calliphora_GrayscaleUncompressed, 8, 200, 298, 96, 96, PixelResolutionUnit.PixelsPerInch)]
30+
[InlineData(Calliphora_GrayscaleUncompressed16Bit, 16, 200, 298, 96, 96, PixelResolutionUnit.PixelsPerInch)]
3031
[InlineData(Flower4BitPalette, 4, 73, 43, 72, 72, PixelResolutionUnit.PixelsPerInch)]
3132
public void Identify(string imagePath, int expectedPixelSize, int expectedWidth, int expectedHeight, double expectedHResolution, double expectedVResolution, PixelResolutionUnit expectedResolutionUnit)
3233
{
@@ -64,6 +65,7 @@ public void ByteOrder(string imagePath, ByteOrder expectedByteOrder)
6465
[Theory]
6566
[WithFile(RgbUncompressed, PixelTypes.Rgba32)]
6667
[WithFile(Calliphora_GrayscaleUncompressed, PixelTypes.Rgba32)]
68+
[WithFile(Calliphora_GrayscaleUncompressed16Bit, PixelTypes.Rgba32)]
6769
[WithFile(Calliphora_RgbUncompressed, PixelTypes.Rgba32)]
6870
[WithFile(Calliphora_BiColorUncompressed, PixelTypes.Rgba32)]
6971
public void TiffDecoder_CanDecode_Uncompressed<TPixel>(TestImageProvider<TPixel> provider)

tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public void EncoderOptions_SetPhotometricInterpretationAndCompression_Works(
169169
[Theory]
170170
[WithFile(Calliphora_BiColorUncompressed, PixelTypes.Rgba32, TiffBitsPerPixel.Bit1)]
171171
[WithFile(GrayscaleUncompressed, PixelTypes.Rgba32, TiffBitsPerPixel.Bit8)]
172-
[WithFile(GrayscaleUncompressed, PixelTypes.L16, TiffBitsPerPixel.Bit16)]
172+
[WithFile(GrayscaleUncompressed16Bit, PixelTypes.L16, TiffBitsPerPixel.Bit16)]
173173
[WithFile(RgbUncompressed, PixelTypes.Rgba32, TiffBitsPerPixel.Bit24)]
174174
[WithFile(Rgb4BitPalette, PixelTypes.Rgba32, TiffBitsPerPixel.Bit4)]
175175
[WithFile(RgbPalette, PixelTypes.Rgba32, TiffBitsPerPixel.Bit8)]
@@ -417,32 +417,32 @@ public void TiffEncoder_EncodeColorPalette_WithLzwCompressionAndPredictor_Works<
417417
TestTiffEncoderCore(provider, TiffBitsPerPixel.Bit8, TiffPhotometricInterpretation.PaletteColor, TiffCompression.Lzw, TiffPredictor.Horizontal, useExactComparer: false, compareTolerance: 0.001f);
418418

419419
[Theory]
420-
[WithFile(Calliphora_GrayscaleUncompressed, PixelTypes.Rgba32)]
420+
[WithFile(Calliphora_GrayscaleUncompressed16Bit, PixelTypes.Rgba32)]
421421
public void TiffEncoder_EncodeGray16_Works<TPixel>(TestImageProvider<TPixel> provider)
422422
where TPixel : unmanaged, IPixel<TPixel> => TestTiffEncoderCore(provider, TiffBitsPerPixel.Bit16, TiffPhotometricInterpretation.BlackIsZero);
423423

424424
[Theory]
425-
[WithFile(Calliphora_GrayscaleUncompressed, PixelTypes.Rgba32)]
425+
[WithFile(Calliphora_GrayscaleUncompressed16Bit, PixelTypes.Rgba32)]
426426
public void TiffEncoder_EncodeGray16_WithDeflateCompression_Works<TPixel>(TestImageProvider<TPixel> provider)
427427
where TPixel : unmanaged, IPixel<TPixel> => TestTiffEncoderCore(provider, TiffBitsPerPixel.Bit16, TiffPhotometricInterpretation.BlackIsZero, TiffCompression.Deflate);
428428

429429
[Theory]
430-
[WithFile(Calliphora_GrayscaleUncompressed, PixelTypes.Rgba32)]
430+
[WithFile(Calliphora_GrayscaleUncompressed16Bit, PixelTypes.Rgba32)]
431431
public void TiffEncoder_EncodeGray16_WithDeflateCompressionAndPredictor_Works<TPixel>(TestImageProvider<TPixel> provider)
432432
where TPixel : unmanaged, IPixel<TPixel> => TestTiffEncoderCore(provider, TiffBitsPerPixel.Bit16, TiffPhotometricInterpretation.BlackIsZero, TiffCompression.Deflate, TiffPredictor.Horizontal);
433433

434434
[Theory]
435-
[WithFile(Calliphora_GrayscaleUncompressed, PixelTypes.Rgba32)]
435+
[WithFile(Calliphora_GrayscaleUncompressed16Bit, PixelTypes.Rgba32)]
436436
public void TiffEncoder_EncodeGray16_WithLzwCompression_Works<TPixel>(TestImageProvider<TPixel> provider)
437437
where TPixel : unmanaged, IPixel<TPixel> => TestTiffEncoderCore(provider, TiffBitsPerPixel.Bit16, TiffPhotometricInterpretation.BlackIsZero, TiffCompression.Lzw);
438438

439439
[Theory]
440-
[WithFile(Calliphora_GrayscaleUncompressed, PixelTypes.Rgba32)]
440+
[WithFile(Calliphora_GrayscaleUncompressed16Bit, PixelTypes.Rgba32)]
441441
public void TiffEncoder_EncodeGray16_WithLzwCompressionAndPredictor_Works<TPixel>(TestImageProvider<TPixel> provider)
442442
where TPixel : unmanaged, IPixel<TPixel> => TestTiffEncoderCore(provider, TiffBitsPerPixel.Bit16, TiffPhotometricInterpretation.BlackIsZero, TiffCompression.Lzw, TiffPredictor.Horizontal);
443443

444444
[Theory]
445-
[WithFile(Calliphora_GrayscaleUncompressed, PixelTypes.Rgba32)]
445+
[WithFile(Calliphora_GrayscaleUncompressed16Bit, PixelTypes.Rgba32)]
446446
public void TiffEncoder_EncodeGray16_WithPackBitsCompression_Works<TPixel>(TestImageProvider<TPixel> provider)
447447
where TPixel : unmanaged, IPixel<TPixel> => TestTiffEncoderCore(provider, TiffBitsPerPixel.Bit16, TiffPhotometricInterpretation.BlackIsZero, TiffCompression.PackBits);
448448

@@ -513,7 +513,7 @@ public void TiffEncoder_EncodeBiColor_WithModifiedHuffmanCompression_BlackIsZero
513513

514514
[Theory]
515515
[WithFile(GrayscaleUncompressed, PixelTypes.L8, TiffPhotometricInterpretation.BlackIsZero, TiffCompression.PackBits)]
516-
[WithFile(GrayscaleUncompressed, PixelTypes.L16, TiffPhotometricInterpretation.BlackIsZero, TiffCompression.PackBits)]
516+
[WithFile(GrayscaleUncompressed16Bit, PixelTypes.L16, TiffPhotometricInterpretation.BlackIsZero, TiffCompression.PackBits)]
517517
[WithFile(RgbUncompressed, PixelTypes.Rgba32, TiffPhotometricInterpretation.Rgb, TiffCompression.Deflate)]
518518
[WithFile(RgbUncompressed, PixelTypes.Rgb24, TiffPhotometricInterpretation.Rgb, TiffCompression.None)]
519519
[WithFile(RgbUncompressed, PixelTypes.Rgba32, TiffPhotometricInterpretation.Rgb, TiffCompression.None)]

tests/ImageSharp.Tests/Formats/Tiff/TiffMetadataTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ private static void VerifyExpectedTiffFrameMetaDataIsPresent(TiffFrameMetadata f
7575
[Theory]
7676
[InlineData(Calliphora_BiColorUncompressed, 1)]
7777
[InlineData(GrayscaleUncompressed, 8)]
78+
[InlineData(GrayscaleUncompressed16Bit, 16)]
7879
[InlineData(RgbUncompressed, 24)]
7980
public void Identify_DetectsCorrectBitPerPixel(string imagePath, int expectedBitsPerPixel)
8081
{

tests/ImageSharp.Tests/TestImages.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,7 @@ public static class Tiff
767767
public const string Calliphora_GrayscaleDeflate_Predictor = "Tiff/Calliphora_gray_deflate_predictor.tiff";
768768
public const string Calliphora_GrayscaleLzw_Predictor = "Tiff/Calliphora_gray_lzw_predictor.tiff";
769769
public const string Calliphora_GrayscaleDeflate = "Tiff/Calliphora_gray_deflate.tiff";
770+
public const string Calliphora_GrayscaleUncompressed16Bit = "Tiff/Calliphora_grayscale_uncompressed_16bit.tiff";
770771
public const string Calliphora_RgbDeflate_Predictor = "Tiff/Calliphora_rgb_deflate_predictor.tiff";
771772
public const string Calliphora_RgbJpeg = "Tiff/Calliphora_rgb_jpeg.tiff";
772773
public const string Calliphora_PaletteUncompressed = "Tiff/Calliphora_palette_uncompressed.tiff";
@@ -798,6 +799,7 @@ public static class Tiff
798799

799800
public const string GrayscaleDeflateMultistrip = "Tiff/grayscale_deflate_multistrip.tiff";
800801
public const string GrayscaleUncompressed = "Tiff/grayscale_uncompressed.tiff";
802+
public const string GrayscaleUncompressed16Bit = "Tiff/grayscale_uncompressed_16bit.tiff";
801803
public const string GrayscaleJpegCompressed = "Tiff/JpegCompressedGray.tiff";
802804
public const string PaletteDeflateMultistrip = "Tiff/palette_grayscale_deflate_multistrip.tiff";
803805
public const string PaletteUncompressed = "Tiff/palette_uncompressed.tiff";
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:42077e6e0d0e7e32bdc0dadb837aad03fd4ae9ceff158bdf213ea9b76dbc36f1
3+
size 119601
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:49de8d78dc22c4c7e62b0c02ae409550c0247c49ec4685162a0fe986d3280aa7
3+
size 131294

0 commit comments

Comments
 (0)