@@ -17,6 +17,7 @@ public class TiffEncoderTests : TiffEncoderBaseTester
17
17
[ InlineData ( TiffPhotometricInterpretation . PaletteColor , TiffBitsPerPixel . Bit8 ) ]
18
18
[ InlineData ( TiffPhotometricInterpretation . BlackIsZero , TiffBitsPerPixel . Bit8 ) ]
19
19
[ InlineData ( TiffPhotometricInterpretation . WhiteIsZero , TiffBitsPerPixel . Bit8 ) ]
20
+ [ InlineData ( TiffPhotometricInterpretation . BlackIsZero , TiffBitsPerPixel . Bit16 ) ]
20
21
//// Unsupported TiffPhotometricInterpretation should default to 24 bits
21
22
[ InlineData ( TiffPhotometricInterpretation . CieLab , TiffBitsPerPixel . Bit24 ) ]
22
23
[ InlineData ( TiffPhotometricInterpretation . ColorFilterArray , TiffBitsPerPixel . Bit24 ) ]
@@ -28,7 +29,9 @@ public void EncoderOptions_SetPhotometricInterpretation_Works(TiffPhotometricInt
28
29
{
29
30
// arrange
30
31
var tiffEncoder = new TiffEncoder { PhotometricInterpretation = photometricInterpretation } ;
31
- using Image input = new Image < Rgb24 > ( 10 , 10 ) ;
32
+ using Image input = expectedBitsPerPixel is TiffBitsPerPixel . Bit16
33
+ ? new Image < L16 > ( 10 , 10 )
34
+ : new Image < Rgb24 > ( 10 , 10 ) ;
32
35
using var memStream = new MemoryStream ( ) ;
33
36
34
37
// act
@@ -44,6 +47,7 @@ public void EncoderOptions_SetPhotometricInterpretation_Works(TiffPhotometricInt
44
47
45
48
[ Theory ]
46
49
[ InlineData ( TiffBitsPerPixel . Bit24 ) ]
50
+ [ InlineData ( TiffBitsPerPixel . Bit16 ) ]
47
51
[ InlineData ( TiffBitsPerPixel . Bit8 ) ]
48
52
[ InlineData ( TiffBitsPerPixel . Bit4 ) ]
49
53
[ InlineData ( TiffBitsPerPixel . Bit1 ) ]
@@ -117,14 +121,17 @@ public void EncoderOptions_WithInvalidCompressionAndPixelTypeCombination_Default
117
121
[ Theory ]
118
122
[ InlineData ( null , TiffCompression . Deflate , TiffBitsPerPixel . Bit24 , TiffCompression . Deflate ) ]
119
123
[ InlineData ( TiffPhotometricInterpretation . Rgb , TiffCompression . Deflate , TiffBitsPerPixel . Bit24 , TiffCompression . Deflate ) ]
124
+ [ InlineData ( TiffPhotometricInterpretation . BlackIsZero , TiffCompression . Deflate , TiffBitsPerPixel . Bit16 , TiffCompression . Deflate ) ]
120
125
[ InlineData ( TiffPhotometricInterpretation . BlackIsZero , TiffCompression . Deflate , TiffBitsPerPixel . Bit8 , TiffCompression . Deflate ) ]
121
126
[ InlineData ( TiffPhotometricInterpretation . PaletteColor , TiffCompression . Deflate , TiffBitsPerPixel . Bit8 , TiffCompression . Deflate ) ]
122
127
[ InlineData ( null , TiffCompression . PackBits , TiffBitsPerPixel . Bit24 , TiffCompression . PackBits ) ]
123
128
[ InlineData ( TiffPhotometricInterpretation . Rgb , TiffCompression . PackBits , TiffBitsPerPixel . Bit24 , TiffCompression . PackBits ) ]
124
- [ InlineData ( TiffPhotometricInterpretation . PaletteColor , TiffCompression . PackBits , TiffBitsPerPixel . Bit8 , TiffCompression . PackBits ) ]
129
+ [ InlineData ( TiffPhotometricInterpretation . BlackIsZero , TiffCompression . PackBits , TiffBitsPerPixel . Bit16 , TiffCompression . PackBits ) ]
125
130
[ InlineData ( TiffPhotometricInterpretation . BlackIsZero , TiffCompression . PackBits , TiffBitsPerPixel . Bit8 , TiffCompression . PackBits ) ]
131
+ [ InlineData ( TiffPhotometricInterpretation . PaletteColor , TiffCompression . PackBits , TiffBitsPerPixel . Bit8 , TiffCompression . PackBits ) ]
126
132
[ InlineData ( null , TiffCompression . Lzw , TiffBitsPerPixel . Bit24 , TiffCompression . Lzw ) ]
127
133
[ InlineData ( TiffPhotometricInterpretation . Rgb , TiffCompression . Lzw , TiffBitsPerPixel . Bit24 , TiffCompression . Lzw ) ]
134
+ [ InlineData ( TiffPhotometricInterpretation . BlackIsZero , TiffCompression . Lzw , TiffBitsPerPixel . Bit16 , TiffCompression . Lzw ) ]
128
135
[ InlineData ( TiffPhotometricInterpretation . BlackIsZero , TiffCompression . Lzw , TiffBitsPerPixel . Bit8 , TiffCompression . Lzw ) ]
129
136
[ InlineData ( TiffPhotometricInterpretation . PaletteColor , TiffCompression . Lzw , TiffBitsPerPixel . Bit8 , TiffCompression . Lzw ) ]
130
137
[ InlineData ( TiffPhotometricInterpretation . BlackIsZero , TiffCompression . CcittGroup3Fax , TiffBitsPerPixel . Bit1 , TiffCompression . CcittGroup3Fax ) ]
@@ -143,7 +150,9 @@ public void EncoderOptions_SetPhotometricInterpretationAndCompression_Works(
143
150
{
144
151
// arrange
145
152
var tiffEncoder = new TiffEncoder { PhotometricInterpretation = photometricInterpretation , Compression = compression } ;
146
- using Image input = new Image < Rgb24 > ( 10 , 10 ) ;
153
+ using Image input = expectedBitsPerPixel is TiffBitsPerPixel . Bit16
154
+ ? new Image < L16 > ( 10 , 10 )
155
+ : new Image < Rgb24 > ( 10 , 10 ) ;
147
156
using var memStream = new MemoryStream ( ) ;
148
157
149
158
// act
@@ -160,6 +169,7 @@ public void EncoderOptions_SetPhotometricInterpretationAndCompression_Works(
160
169
[ Theory ]
161
170
[ WithFile ( Calliphora_BiColorUncompressed , PixelTypes . Rgba32 , TiffBitsPerPixel . Bit1 ) ]
162
171
[ WithFile ( GrayscaleUncompressed , PixelTypes . Rgba32 , TiffBitsPerPixel . Bit8 ) ]
172
+ [ WithFile ( GrayscaleUncompressed16Bit , PixelTypes . L16 , TiffBitsPerPixel . Bit16 ) ]
163
173
[ WithFile ( RgbUncompressed , PixelTypes . Rgba32 , TiffBitsPerPixel . Bit24 ) ]
164
174
[ WithFile ( Rgb4BitPalette , PixelTypes . Rgba32 , TiffBitsPerPixel . Bit4 ) ]
165
175
[ WithFile ( RgbPalette , PixelTypes . Rgba32 , TiffBitsPerPixel . Bit8 ) ]
@@ -406,6 +416,36 @@ public void TiffEncoder_EncodeColorPalette_WithLzwCompressionAndPredictor_Works<
406
416
where TPixel : unmanaged, IPixel < TPixel > =>
407
417
TestTiffEncoderCore ( provider , TiffBitsPerPixel . Bit8 , TiffPhotometricInterpretation . PaletteColor , TiffCompression . Lzw , TiffPredictor . Horizontal , useExactComparer : false , compareTolerance : 0.001f ) ;
408
418
419
+ [ Theory ]
420
+ [ WithFile ( Calliphora_GrayscaleUncompressed16Bit , PixelTypes . Rgba32 ) ]
421
+ public void TiffEncoder_EncodeGray16_Works < TPixel > ( TestImageProvider < TPixel > provider )
422
+ where TPixel : unmanaged, IPixel < TPixel > => TestTiffEncoderCore ( provider , TiffBitsPerPixel . Bit16 , TiffPhotometricInterpretation . BlackIsZero ) ;
423
+
424
+ [ Theory ]
425
+ [ WithFile ( Calliphora_GrayscaleUncompressed16Bit , PixelTypes . Rgba32 ) ]
426
+ public void TiffEncoder_EncodeGray16_WithDeflateCompression_Works < TPixel > ( TestImageProvider < TPixel > provider )
427
+ where TPixel : unmanaged, IPixel < TPixel > => TestTiffEncoderCore ( provider , TiffBitsPerPixel . Bit16 , TiffPhotometricInterpretation . BlackIsZero , TiffCompression . Deflate ) ;
428
+
429
+ [ Theory ]
430
+ [ WithFile ( Calliphora_GrayscaleUncompressed16Bit , PixelTypes . Rgba32 ) ]
431
+ public void TiffEncoder_EncodeGray16_WithDeflateCompressionAndPredictor_Works < TPixel > ( TestImageProvider < TPixel > provider )
432
+ where TPixel : unmanaged, IPixel < TPixel > => TestTiffEncoderCore ( provider , TiffBitsPerPixel . Bit16 , TiffPhotometricInterpretation . BlackIsZero , TiffCompression . Deflate , TiffPredictor . Horizontal ) ;
433
+
434
+ [ Theory ]
435
+ [ WithFile ( Calliphora_GrayscaleUncompressed16Bit , PixelTypes . Rgba32 ) ]
436
+ public void TiffEncoder_EncodeGray16_WithLzwCompression_Works < TPixel > ( TestImageProvider < TPixel > provider )
437
+ where TPixel : unmanaged, IPixel < TPixel > => TestTiffEncoderCore ( provider , TiffBitsPerPixel . Bit16 , TiffPhotometricInterpretation . BlackIsZero , TiffCompression . Lzw ) ;
438
+
439
+ [ Theory ]
440
+ [ WithFile ( Calliphora_GrayscaleUncompressed16Bit , PixelTypes . Rgba32 ) ]
441
+ public void TiffEncoder_EncodeGray16_WithLzwCompressionAndPredictor_Works < TPixel > ( TestImageProvider < TPixel > provider )
442
+ where TPixel : unmanaged, IPixel < TPixel > => TestTiffEncoderCore ( provider , TiffBitsPerPixel . Bit16 , TiffPhotometricInterpretation . BlackIsZero , TiffCompression . Lzw , TiffPredictor . Horizontal ) ;
443
+
444
+ [ Theory ]
445
+ [ WithFile ( Calliphora_GrayscaleUncompressed16Bit , PixelTypes . Rgba32 ) ]
446
+ public void TiffEncoder_EncodeGray16_WithPackBitsCompression_Works < TPixel > ( TestImageProvider < TPixel > provider )
447
+ where TPixel : unmanaged, IPixel < TPixel > => TestTiffEncoderCore ( provider , TiffBitsPerPixel . Bit16 , TiffPhotometricInterpretation . BlackIsZero , TiffCompression . PackBits ) ;
448
+
409
449
[ Theory ]
410
450
[ WithFile ( Calliphora_BiColorUncompressed , PixelTypes . Rgba32 ) ]
411
451
public void TiffEncoder_EncodeBiColor_BlackIsZero_Works < TPixel > ( TestImageProvider < TPixel > provider )
@@ -473,6 +513,7 @@ public void TiffEncoder_EncodeBiColor_WithModifiedHuffmanCompression_BlackIsZero
473
513
474
514
[ Theory ]
475
515
[ WithFile ( GrayscaleUncompressed , PixelTypes . L8 , TiffPhotometricInterpretation . BlackIsZero , TiffCompression . PackBits ) ]
516
+ [ WithFile ( GrayscaleUncompressed16Bit , PixelTypes . L16 , TiffPhotometricInterpretation . BlackIsZero , TiffCompression . PackBits ) ]
476
517
[ WithFile ( RgbUncompressed , PixelTypes . Rgba32 , TiffPhotometricInterpretation . Rgb , TiffCompression . Deflate ) ]
477
518
[ WithFile ( RgbUncompressed , PixelTypes . Rgb24 , TiffPhotometricInterpretation . Rgb , TiffCompression . None ) ]
478
519
[ WithFile ( RgbUncompressed , PixelTypes . Rgba32 , TiffPhotometricInterpretation . Rgb , TiffCompression . None ) ]
0 commit comments