@@ -129,8 +129,8 @@ public void IsNotBoundToSinglePixelType<TPixel>(TestImageProvider<TPixel> provid
129129 PngFilterMethod . Adaptive ,
130130 PngBitDepth . Bit8 ,
131131 interlaceMode ,
132- appendPixelType : true ,
133- appendPngColorType : true ) ;
132+ appendPngColorType : true ,
133+ appendPixelType : true ) ;
134134 }
135135 }
136136
@@ -321,7 +321,7 @@ public void WritesFileMarker<TPixel>(TestImageProvider<TPixel> provider)
321321 where TPixel : unmanaged, IPixel < TPixel >
322322 {
323323 using Image < TPixel > image = provider . GetImage ( ) ;
324- using var ms = new MemoryStream ( ) ;
324+ using MemoryStream ms = new ( ) ;
325325 image . Save ( ms , PngEncoder ) ;
326326
327327 byte [ ] data = ms . ToArray ( ) . Take ( 8 ) . ToArray ( ) ;
@@ -344,13 +344,13 @@ public void WritesFileMarker<TPixel>(TestImageProvider<TPixel> provider)
344344 [ MemberData ( nameof ( RatioFiles ) ) ]
345345 public void Encode_PreserveRatio ( string imagePath , int xResolution , int yResolution , PixelResolutionUnit resolutionUnit )
346346 {
347- var testFile = TestFile . Create ( imagePath ) ;
347+ TestFile testFile = TestFile . Create ( imagePath ) ;
348348 using Image < Rgba32 > input = testFile . CreateRgba32Image ( ) ;
349- using var memStream = new MemoryStream ( ) ;
349+ using MemoryStream memStream = new ( ) ;
350350 input . Save ( memStream , PngEncoder ) ;
351351
352352 memStream . Position = 0 ;
353- using var output = Image . Load < Rgba32 > ( memStream ) ;
353+ using Image < Rgba32 > output = Image . Load < Rgba32 > ( memStream ) ;
354354 ImageMetadata meta = output . Metadata ;
355355 Assert . Equal ( xResolution , meta . HorizontalResolution ) ;
356356 Assert . Equal ( yResolution , meta . VerticalResolution ) ;
@@ -361,13 +361,13 @@ public void Encode_PreserveRatio(string imagePath, int xResolution, int yResolut
361361 [ MemberData ( nameof ( PngBitDepthFiles ) ) ]
362362 public void Encode_PreserveBits ( string imagePath , PngBitDepth pngBitDepth )
363363 {
364- var testFile = TestFile . Create ( imagePath ) ;
364+ TestFile testFile = TestFile . Create ( imagePath ) ;
365365 using Image < Rgba32 > input = testFile . CreateRgba32Image ( ) ;
366- using var memStream = new MemoryStream ( ) ;
366+ using MemoryStream memStream = new ( ) ;
367367 input . Save ( memStream , PngEncoder ) ;
368368
369369 memStream . Position = 0 ;
370- using var output = Image . Load < Rgba32 > ( memStream ) ;
370+ using Image < Rgba32 > output = Image . Load < Rgba32 > ( memStream ) ;
371371 PngMetadata meta = output . Metadata . GetPngMetadata ( ) ;
372372
373373 Assert . Equal ( pngBitDepth , meta . BitDepth ) ;
@@ -380,8 +380,8 @@ public void Encode_PreserveBits(string imagePath, PngBitDepth pngBitDepth)
380380 public void Encode_WithPngTransparentColorBehaviorClear_Works ( PngColorType colorType )
381381 {
382382 // arrange
383- var image = new Image < Rgba32 > ( 50 , 50 ) ;
384- var encoder = new PngEncoder ( )
383+ Image < Rgba32 > image = new ( 50 , 50 ) ;
384+ PngEncoder encoder = new ( )
385385 {
386386 TransparentColorMode = PngTransparentColorMode . Clear ,
387387 ColorType = colorType
@@ -391,7 +391,7 @@ public void Encode_WithPngTransparentColorBehaviorClear_Works(PngColorType color
391391 {
392392 for ( int y = 0 ; y < image . Height ; y ++ )
393393 {
394- System . Span < Rgba32 > rowSpan = accessor . GetRowSpan ( y ) ;
394+ Span < Rgba32 > rowSpan = accessor . GetRowSpan ( y ) ;
395395
396396 // Half of the test image should be transparent.
397397 if ( y > 25 )
@@ -407,12 +407,12 @@ public void Encode_WithPngTransparentColorBehaviorClear_Works(PngColorType color
407407 } ) ;
408408
409409 // act
410- using var memStream = new MemoryStream ( ) ;
410+ using MemoryStream memStream = new ( ) ;
411411 image . Save ( memStream , encoder ) ;
412412
413413 // assert
414414 memStream . Position = 0 ;
415- using var actual = Image . Load < Rgba32 > ( memStream ) ;
415+ using Image < Rgba32 > actual = Image . Load < Rgba32 > ( memStream ) ;
416416 Rgba32 expectedColor = Color . Blue ;
417417 if ( colorType is PngColorType . Grayscale or PngColorType . GrayscaleWithAlpha )
418418 {
@@ -424,7 +424,7 @@ public void Encode_WithPngTransparentColorBehaviorClear_Works(PngColorType color
424424 {
425425 for ( int y = 0 ; y < accessor . Height ; y ++ )
426426 {
427- System . Span < Rgba32 > rowSpan = accessor . GetRowSpan ( y ) ;
427+ Span < Rgba32 > rowSpan = accessor . GetRowSpan ( y ) ;
428428
429429 if ( y > 25 )
430430 {
@@ -443,15 +443,15 @@ public void Encode_WithPngTransparentColorBehaviorClear_Works(PngColorType color
443443 [ MemberData ( nameof ( PngTrnsFiles ) ) ]
444444 public void Encode_PreserveTrns ( string imagePath , PngBitDepth pngBitDepth , PngColorType pngColorType )
445445 {
446- var testFile = TestFile . Create ( imagePath ) ;
446+ TestFile testFile = TestFile . Create ( imagePath ) ;
447447 using Image < Rgba32 > input = testFile . CreateRgba32Image ( ) ;
448448 PngMetadata inMeta = input . Metadata . GetPngMetadata ( ) ;
449449 Assert . True ( inMeta . HasTransparency ) ;
450450
451- using var memStream = new MemoryStream ( ) ;
451+ using MemoryStream memStream = new ( ) ;
452452 input . Save ( memStream , PngEncoder ) ;
453453 memStream . Position = 0 ;
454- using var output = Image . Load < Rgba32 > ( memStream ) ;
454+ using Image < Rgba32 > output = Image . Load < Rgba32 > ( memStream ) ;
455455 PngMetadata outMeta = output . Metadata . GetPngMetadata ( ) ;
456456 Assert . True ( outMeta . HasTransparency ) ;
457457
@@ -501,8 +501,8 @@ public void Encode_WorksWithDiscontiguousBuffers<TPixel>(TestImageProvider<TPixe
501501 PngFilterMethod . Adaptive ,
502502 PngBitDepth . Bit8 ,
503503 interlaceMode ,
504- appendPixelType : true ,
505- appendPngColorType : true ) ;
504+ appendPngColorType : true ,
505+ appendPixelType : true ) ;
506506 }
507507 }
508508
@@ -523,8 +523,8 @@ static void RunTest(string serialized)
523523 PngFilterMethod . Adaptive ,
524524 PngBitDepth . Bit8 ,
525525 interlaceMode ,
526- appendPixelType : true ,
527- appendPngColorType : true ) ;
526+ appendPngColorType : true ,
527+ appendPixelType : true ) ;
528528 }
529529 }
530530
@@ -538,13 +538,27 @@ static void RunTest(string serialized)
538538 public void EncodeFixesInvalidOptions ( )
539539 {
540540 // https://github.com/SixLabors/ImageSharp/issues/935
541- using var ms = new MemoryStream ( ) ;
542- var testFile = TestFile . Create ( TestImages . Png . Issue935 ) ;
541+ using MemoryStream ms = new ( ) ;
542+ TestFile testFile = TestFile . Create ( TestImages . Png . Issue935 ) ;
543543 using Image < Rgba32 > image = testFile . CreateRgba32Image ( PngDecoder . Instance ) ;
544544
545545 image . Save ( ms , new PngEncoder { ColorType = PngColorType . RgbWithAlpha } ) ;
546546 }
547547
548+ // https://github.com/SixLabors/ImageSharp/issues/2469
549+ [ Theory ]
550+ [ WithFile ( TestImages . Png . Issue2469 , PixelTypes . Rgba32 ) ]
551+ public void Issue2469_Quantized_Encode_Artifacts < TPixel > ( TestImageProvider < TPixel > provider )
552+ where TPixel : unmanaged, IPixel < TPixel >
553+ {
554+ using Image < TPixel > image = provider . GetImage ( PngDecoder . Instance ) ;
555+ PngEncoder encoder = new ( ) { BitDepth = PngBitDepth . Bit8 , ColorType = PngColorType . Palette } ;
556+
557+ string actualOutputFile = provider . Utility . SaveTestOutputFile ( image , "png" , encoder ) ;
558+ using Image < Rgba32 > encoded = Image . Load < Rgba32 > ( actualOutputFile ) ;
559+ encoded . CompareToReferenceOutput ( ImageComparer . Exact , provider ) ;
560+ }
561+
548562 private static void TestPngEncoderCore < TPixel > (
549563 TestImageProvider < TPixel > provider ,
550564 PngColorType pngColorType ,
@@ -563,7 +577,7 @@ private static void TestPngEncoderCore<TPixel>(
563577 where TPixel : unmanaged, IPixel < TPixel >
564578 {
565579 using Image < TPixel > image = provider . GetImage ( ) ;
566- var encoder = new PngEncoder
580+ PngEncoder encoder = new ( )
567581 {
568582 ColorType = pngColorType ,
569583 FilterMethod = pngFilterMethod ,
0 commit comments