@@ -99,6 +99,9 @@ public static readonly TheoryData<PngCompressionLevel> CompressionLevels
9999 { TestImages . Png . Ratio4x1 , 4 , 1 , PixelResolutionUnit . AspectRatio }
100100 } ;
101101
102+ [ Fact ]
103+ public void PngEncoderDefaultInstanceHasNullQuantizer ( ) => Assert . Null ( PngEncoder . Quantizer ) ;
104+
102105 [ Theory ]
103106 [ WithFile ( TestImages . Png . Palette8Bpp , nameof ( PngColorTypes ) , PixelTypes . Rgba32 ) ]
104107 [ WithTestPatternImages ( nameof ( PngColorTypes ) , 48 , 24 , PixelTypes . Rgba32 ) ]
@@ -129,8 +132,8 @@ public void IsNotBoundToSinglePixelType<TPixel>(TestImageProvider<TPixel> provid
129132 PngFilterMethod . Adaptive ,
130133 PngBitDepth . Bit8 ,
131134 interlaceMode ,
132- appendPixelType : true ,
133- appendPngColorType : true ) ;
135+ appendPngColorType : true ,
136+ appendPixelType : true ) ;
134137 }
135138 }
136139
@@ -321,7 +324,7 @@ public void WritesFileMarker<TPixel>(TestImageProvider<TPixel> provider)
321324 where TPixel : unmanaged, IPixel < TPixel >
322325 {
323326 using Image < TPixel > image = provider . GetImage ( ) ;
324- using var ms = new MemoryStream ( ) ;
327+ using MemoryStream ms = new ( ) ;
325328 image . Save ( ms , PngEncoder ) ;
326329
327330 byte [ ] data = ms . ToArray ( ) . Take ( 8 ) . ToArray ( ) ;
@@ -344,13 +347,13 @@ public void WritesFileMarker<TPixel>(TestImageProvider<TPixel> provider)
344347 [ MemberData ( nameof ( RatioFiles ) ) ]
345348 public void Encode_PreserveRatio ( string imagePath , int xResolution , int yResolution , PixelResolutionUnit resolutionUnit )
346349 {
347- var testFile = TestFile . Create ( imagePath ) ;
350+ TestFile testFile = TestFile . Create ( imagePath ) ;
348351 using Image < Rgba32 > input = testFile . CreateRgba32Image ( ) ;
349- using var memStream = new MemoryStream ( ) ;
352+ using MemoryStream memStream = new ( ) ;
350353 input . Save ( memStream , PngEncoder ) ;
351354
352355 memStream . Position = 0 ;
353- using var output = Image . Load < Rgba32 > ( memStream ) ;
356+ using Image < Rgba32 > output = Image . Load < Rgba32 > ( memStream ) ;
354357 ImageMetadata meta = output . Metadata ;
355358 Assert . Equal ( xResolution , meta . HorizontalResolution ) ;
356359 Assert . Equal ( yResolution , meta . VerticalResolution ) ;
@@ -361,13 +364,13 @@ public void Encode_PreserveRatio(string imagePath, int xResolution, int yResolut
361364 [ MemberData ( nameof ( PngBitDepthFiles ) ) ]
362365 public void Encode_PreserveBits ( string imagePath , PngBitDepth pngBitDepth )
363366 {
364- var testFile = TestFile . Create ( imagePath ) ;
367+ TestFile testFile = TestFile . Create ( imagePath ) ;
365368 using Image < Rgba32 > input = testFile . CreateRgba32Image ( ) ;
366- using var memStream = new MemoryStream ( ) ;
369+ using MemoryStream memStream = new ( ) ;
367370 input . Save ( memStream , PngEncoder ) ;
368371
369372 memStream . Position = 0 ;
370- using var output = Image . Load < Rgba32 > ( memStream ) ;
373+ using Image < Rgba32 > output = Image . Load < Rgba32 > ( memStream ) ;
371374 PngMetadata meta = output . Metadata . GetPngMetadata ( ) ;
372375
373376 Assert . Equal ( pngBitDepth , meta . BitDepth ) ;
@@ -380,8 +383,8 @@ public void Encode_PreserveBits(string imagePath, PngBitDepth pngBitDepth)
380383 public void Encode_WithPngTransparentColorBehaviorClear_Works ( PngColorType colorType )
381384 {
382385 // arrange
383- var image = new Image < Rgba32 > ( 50 , 50 ) ;
384- var encoder = new PngEncoder ( )
386+ Image < Rgba32 > image = new ( 50 , 50 ) ;
387+ PngEncoder encoder = new ( )
385388 {
386389 TransparentColorMode = PngTransparentColorMode . Clear ,
387390 ColorType = colorType
@@ -391,7 +394,7 @@ public void Encode_WithPngTransparentColorBehaviorClear_Works(PngColorType color
391394 {
392395 for ( int y = 0 ; y < image . Height ; y ++ )
393396 {
394- System . Span < Rgba32 > rowSpan = accessor . GetRowSpan ( y ) ;
397+ Span < Rgba32 > rowSpan = accessor . GetRowSpan ( y ) ;
395398
396399 // Half of the test image should be transparent.
397400 if ( y > 25 )
@@ -407,12 +410,12 @@ public void Encode_WithPngTransparentColorBehaviorClear_Works(PngColorType color
407410 } ) ;
408411
409412 // act
410- using var memStream = new MemoryStream ( ) ;
413+ using MemoryStream memStream = new ( ) ;
411414 image . Save ( memStream , encoder ) ;
412415
413416 // assert
414417 memStream . Position = 0 ;
415- using var actual = Image . Load < Rgba32 > ( memStream ) ;
418+ using Image < Rgba32 > actual = Image . Load < Rgba32 > ( memStream ) ;
416419 Rgba32 expectedColor = Color . Blue ;
417420 if ( colorType is PngColorType . Grayscale or PngColorType . GrayscaleWithAlpha )
418421 {
@@ -424,7 +427,7 @@ public void Encode_WithPngTransparentColorBehaviorClear_Works(PngColorType color
424427 {
425428 for ( int y = 0 ; y < accessor . Height ; y ++ )
426429 {
427- System . Span < Rgba32 > rowSpan = accessor . GetRowSpan ( y ) ;
430+ Span < Rgba32 > rowSpan = accessor . GetRowSpan ( y ) ;
428431
429432 if ( y > 25 )
430433 {
@@ -443,15 +446,15 @@ public void Encode_WithPngTransparentColorBehaviorClear_Works(PngColorType color
443446 [ MemberData ( nameof ( PngTrnsFiles ) ) ]
444447 public void Encode_PreserveTrns ( string imagePath , PngBitDepth pngBitDepth , PngColorType pngColorType )
445448 {
446- var testFile = TestFile . Create ( imagePath ) ;
449+ TestFile testFile = TestFile . Create ( imagePath ) ;
447450 using Image < Rgba32 > input = testFile . CreateRgba32Image ( ) ;
448451 PngMetadata inMeta = input . Metadata . GetPngMetadata ( ) ;
449452 Assert . True ( inMeta . HasTransparency ) ;
450453
451- using var memStream = new MemoryStream ( ) ;
454+ using MemoryStream memStream = new ( ) ;
452455 input . Save ( memStream , PngEncoder ) ;
453456 memStream . Position = 0 ;
454- using var output = Image . Load < Rgba32 > ( memStream ) ;
457+ using Image < Rgba32 > output = Image . Load < Rgba32 > ( memStream ) ;
455458 PngMetadata outMeta = output . Metadata . GetPngMetadata ( ) ;
456459 Assert . True ( outMeta . HasTransparency ) ;
457460
@@ -501,8 +504,8 @@ public void Encode_WorksWithDiscontiguousBuffers<TPixel>(TestImageProvider<TPixe
501504 PngFilterMethod . Adaptive ,
502505 PngBitDepth . Bit8 ,
503506 interlaceMode ,
504- appendPixelType : true ,
505- appendPngColorType : true ) ;
507+ appendPngColorType : true ,
508+ appendPixelType : true ) ;
506509 }
507510 }
508511
@@ -523,8 +526,8 @@ static void RunTest(string serialized)
523526 PngFilterMethod . Adaptive ,
524527 PngBitDepth . Bit8 ,
525528 interlaceMode ,
526- appendPixelType : true ,
527- appendPngColorType : true ) ;
529+ appendPngColorType : true ,
530+ appendPixelType : true ) ;
528531 }
529532 }
530533
@@ -538,8 +541,8 @@ static void RunTest(string serialized)
538541 public void EncodeFixesInvalidOptions ( )
539542 {
540543 // https://github.com/SixLabors/ImageSharp/issues/935
541- using var ms = new MemoryStream ( ) ;
542- var testFile = TestFile . Create ( TestImages . Png . Issue935 ) ;
544+ using MemoryStream ms = new ( ) ;
545+ TestFile testFile = TestFile . Create ( TestImages . Png . Issue935 ) ;
543546 using Image < Rgba32 > image = testFile . CreateRgba32Image ( PngDecoder . Instance ) ;
544547
545548 image . Save ( ms , new PngEncoder { ColorType = PngColorType . RgbWithAlpha } ) ;
@@ -563,7 +566,7 @@ private static void TestPngEncoderCore<TPixel>(
563566 where TPixel : unmanaged, IPixel < TPixel >
564567 {
565568 using Image < TPixel > image = provider . GetImage ( ) ;
566- var encoder = new PngEncoder
569+ PngEncoder encoder = new ( )
567570 {
568571 ColorType = pngColorType ,
569572 FilterMethod = pngFilterMethod ,
@@ -581,7 +584,7 @@ private static void TestPngEncoderCore<TPixel>(
581584 string pngBitDepthInfo = appendPngBitDepth ? bitDepth . ToString ( ) : string . Empty ;
582585 string pngInterlaceModeInfo = interlaceMode != PngInterlaceMode . None ? $ "_{ interlaceMode } " : string . Empty ;
583586
584- string debugInfo = $ " { pngColorTypeInfo } { pngFilterMethodInfo } { compressionLevelInfo } { paletteSizeInfo } { pngBitDepthInfo } { pngInterlaceModeInfo } " ;
587+ string debugInfo = pngColorTypeInfo + pngFilterMethodInfo + compressionLevelInfo + paletteSizeInfo + pngBitDepthInfo + pngInterlaceModeInfo ;
585588
586589 string actualOutputFile = provider . Utility . SaveTestOutputFile ( image , "png" , encoder , debugInfo , appendPixelType ) ;
587590
0 commit comments