@@ -32,21 +32,31 @@ public class PngEncoderTests
3232 PngColorType . GrayscaleWithAlpha ,
3333 } ;
3434
35+ public static readonly TheoryData < PngFilterMethod > PngFilterMethods = new TheoryData < PngFilterMethod >
36+ {
37+ PngFilterMethod . None ,
38+ PngFilterMethod . Sub ,
39+ PngFilterMethod . Up ,
40+ PngFilterMethod . Average ,
41+ PngFilterMethod . Paeth ,
42+ PngFilterMethod . Adaptive
43+ } ;
44+
3545 /// <summary>
3646 /// All types except Palette
3747 /// </summary>
3848 public static readonly TheoryData < int > CompressionLevels = new TheoryData < int >
39- {
49+ {
4050 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9
4151 } ;
4252
4353 public static readonly TheoryData < int > PaletteSizes = new TheoryData < int >
44- {
54+ {
4555 30 , 55 , 100 , 201 , 255
4656 } ;
4757
4858 public static readonly TheoryData < int > PaletteLargeOnly = new TheoryData < int >
49- {
59+ {
5060 80 , 100 , 120 , 230
5161 } ;
5262
@@ -60,31 +70,39 @@ public class PngEncoderTests
6070 public void WorksWithDifferentSizes < TPixel > ( TestImageProvider < TPixel > provider , PngColorType pngColorType )
6171 where TPixel : struct , IPixel < TPixel >
6272 {
63- TestPngEncoderCore ( provider , pngColorType , appendPngColorType : true ) ;
73+ TestPngEncoderCore ( provider , pngColorType , PngFilterMethod . Adaptive , appendPngColorType : true ) ;
6474 }
6575
6676 [ Theory ]
6777 [ WithTestPatternImages ( nameof ( PngColorTypes ) , 24 , 24 , PixelTypes . Rgba32 | PixelTypes . Bgra32 | PixelTypes . Rgb24 ) ]
6878 public void IsNotBoundToSinglePixelType < TPixel > ( TestImageProvider < TPixel > provider , PngColorType pngColorType )
6979 where TPixel : struct , IPixel < TPixel >
7080 {
71- TestPngEncoderCore ( provider , pngColorType , appendPixelType : true , appendPngColorType : true ) ;
81+ TestPngEncoderCore ( provider , pngColorType , PngFilterMethod . Adaptive , appendPixelType : true , appendPngColorType : true ) ;
82+ }
83+
84+ [ Theory ]
85+ [ WithTestPatternImages ( nameof ( PngFilterMethods ) , 24 , 24 , PixelTypes . Rgba32 ) ]
86+ public void WorksWithAllFilterMethods < TPixel > ( TestImageProvider < TPixel > provider , PngFilterMethod pngFilterMethod )
87+ where TPixel : struct , IPixel < TPixel >
88+ {
89+ TestPngEncoderCore ( provider , PngColorType . RgbWithAlpha , pngFilterMethod , appendPngFilterMethod : true ) ;
7290 }
7391
7492 [ Theory ]
7593 [ WithTestPatternImages ( nameof ( CompressionLevels ) , 24 , 24 , PixelTypes . Rgba32 ) ]
7694 public void WorksWithAllCompressionLevels < TPixel > ( TestImageProvider < TPixel > provider , int compressionLevel )
7795 where TPixel : struct , IPixel < TPixel >
7896 {
79- TestPngEncoderCore ( provider , PngColorType . RgbWithAlpha , compressionLevel , appendCompressionLevel : true ) ;
97+ TestPngEncoderCore ( provider , PngColorType . RgbWithAlpha , PngFilterMethod . Adaptive , compressionLevel , appendCompressionLevel : true ) ;
8098 }
8199
82100 [ Theory ]
83101 [ WithFile ( TestImages . Png . Palette8Bpp , nameof ( PaletteLargeOnly ) , PixelTypes . Rgba32 ) ]
84102 public void PaletteColorType_WuQuantizer < TPixel > ( TestImageProvider < TPixel > provider , int paletteSize )
85103 where TPixel : struct , IPixel < TPixel >
86104 {
87- TestPngEncoderCore ( provider , PngColorType . Palette , paletteSize : paletteSize , appendPaletteSize : true ) ;
105+ TestPngEncoderCore ( provider , PngColorType . Palette , PngFilterMethod . Adaptive , paletteSize : paletteSize , appendPaletteSize : true ) ;
88106 }
89107
90108 private static bool HasAlpha ( PngColorType pngColorType ) =>
@@ -93,9 +111,11 @@ private static bool HasAlpha(PngColorType pngColorType) =>
93111 private static void TestPngEncoderCore < TPixel > (
94112 TestImageProvider < TPixel > provider ,
95113 PngColorType pngColorType ,
114+ PngFilterMethod pngFilterMethod ,
96115 int compressionLevel = 6 ,
97116 int paletteSize = 255 ,
98117 bool appendPngColorType = false ,
118+ bool appendPngFilterMethod = false ,
99119 bool appendPixelType = false ,
100120 bool appendCompressionLevel = false ,
101121 bool appendPaletteSize = false )
@@ -111,14 +131,16 @@ private static void TestPngEncoderCore<TPixel>(
111131 var encoder = new PngEncoder
112132 {
113133 PngColorType = pngColorType ,
134+ PngFilterMethod = pngFilterMethod ,
114135 CompressionLevel = compressionLevel ,
115136 Quantizer = new WuQuantizer ( paletteSize )
116137 } ;
117138
118- string pngColorTypeInfo = appendPngColorType ? pngColorType . ToString ( ) : "" ;
119- string compressionLevelInfo = appendCompressionLevel ? $ "_C{ compressionLevel } " : "" ;
120- string paletteSizeInfo = appendPaletteSize ? $ "_PaletteSize-{ paletteSize } " : "" ;
121- string debugInfo = $ "{ pngColorTypeInfo } { compressionLevelInfo } { paletteSizeInfo } ";
139+ string pngColorTypeInfo = appendPngColorType ? pngColorType . ToString ( ) : string . Empty ;
140+ string pngFilterMethodInfo = appendPngFilterMethod ? pngFilterMethod . ToString ( ) : string . Empty ;
141+ string compressionLevelInfo = appendCompressionLevel ? $ "_C{ compressionLevel } " : string . Empty ;
142+ string paletteSizeInfo = appendPaletteSize ? $ "_PaletteSize-{ paletteSize } " : string . Empty ;
143+ string debugInfo = $ "{ pngColorTypeInfo } { pngFilterMethodInfo } { compressionLevelInfo } { paletteSizeInfo } ";
122144 //string referenceInfo = $"{pngColorTypeInfo}";
123145
124146 // Does DebugSave & load reference CompareToReferenceInput():
0 commit comments