@@ -99,6 +99,9 @@ public static readonly TheoryData<PngCompressionLevel> CompressionLevels
99
99
{ TestImages . Png . Ratio4x1 , 4 , 1 , PixelResolutionUnit . AspectRatio }
100
100
} ;
101
101
102
+ [ Fact ]
103
+ public void PngEncoderDefaultInstanceHasNullQuantizer ( ) => Assert . Null ( PngEncoder . Quantizer ) ;
104
+
102
105
[ Theory ]
103
106
[ WithFile ( TestImages . Png . Palette8Bpp , nameof ( PngColorTypes ) , PixelTypes . Rgba32 ) ]
104
107
[ WithTestPatternImages ( nameof ( PngColorTypes ) , 48 , 24 , PixelTypes . Rgba32 ) ]
@@ -129,8 +132,8 @@ public void IsNotBoundToSinglePixelType<TPixel>(TestImageProvider<TPixel> provid
129
132
PngFilterMethod . Adaptive ,
130
133
PngBitDepth . Bit8 ,
131
134
interlaceMode ,
132
- appendPixelType : true ,
133
- appendPngColorType : true ) ;
135
+ appendPngColorType : true ,
136
+ appendPixelType : true ) ;
134
137
}
135
138
}
136
139
@@ -321,7 +324,7 @@ public void WritesFileMarker<TPixel>(TestImageProvider<TPixel> provider)
321
324
where TPixel : unmanaged, IPixel < TPixel >
322
325
{
323
326
using Image < TPixel > image = provider . GetImage ( ) ;
324
- using var ms = new MemoryStream ( ) ;
327
+ using MemoryStream ms = new ( ) ;
325
328
image . Save ( ms , PngEncoder ) ;
326
329
327
330
byte [ ] data = ms . ToArray ( ) . Take ( 8 ) . ToArray ( ) ;
@@ -344,13 +347,13 @@ public void WritesFileMarker<TPixel>(TestImageProvider<TPixel> provider)
344
347
[ MemberData ( nameof ( RatioFiles ) ) ]
345
348
public void Encode_PreserveRatio ( string imagePath , int xResolution , int yResolution , PixelResolutionUnit resolutionUnit )
346
349
{
347
- var testFile = TestFile . Create ( imagePath ) ;
350
+ TestFile testFile = TestFile . Create ( imagePath ) ;
348
351
using Image < Rgba32 > input = testFile . CreateRgba32Image ( ) ;
349
- using var memStream = new MemoryStream ( ) ;
352
+ using MemoryStream memStream = new ( ) ;
350
353
input . Save ( memStream , PngEncoder ) ;
351
354
352
355
memStream . Position = 0 ;
353
- using var output = Image . Load < Rgba32 > ( memStream ) ;
356
+ using Image < Rgba32 > output = Image . Load < Rgba32 > ( memStream ) ;
354
357
ImageMetadata meta = output . Metadata ;
355
358
Assert . Equal ( xResolution , meta . HorizontalResolution ) ;
356
359
Assert . Equal ( yResolution , meta . VerticalResolution ) ;
@@ -361,13 +364,13 @@ public void Encode_PreserveRatio(string imagePath, int xResolution, int yResolut
361
364
[ MemberData ( nameof ( PngBitDepthFiles ) ) ]
362
365
public void Encode_PreserveBits ( string imagePath , PngBitDepth pngBitDepth )
363
366
{
364
- var testFile = TestFile . Create ( imagePath ) ;
367
+ TestFile testFile = TestFile . Create ( imagePath ) ;
365
368
using Image < Rgba32 > input = testFile . CreateRgba32Image ( ) ;
366
- using var memStream = new MemoryStream ( ) ;
369
+ using MemoryStream memStream = new ( ) ;
367
370
input . Save ( memStream , PngEncoder ) ;
368
371
369
372
memStream . Position = 0 ;
370
- using var output = Image . Load < Rgba32 > ( memStream ) ;
373
+ using Image < Rgba32 > output = Image . Load < Rgba32 > ( memStream ) ;
371
374
PngMetadata meta = output . Metadata . GetPngMetadata ( ) ;
372
375
373
376
Assert . Equal ( pngBitDepth , meta . BitDepth ) ;
@@ -380,8 +383,8 @@ public void Encode_PreserveBits(string imagePath, PngBitDepth pngBitDepth)
380
383
public void Encode_WithPngTransparentColorBehaviorClear_Works ( PngColorType colorType )
381
384
{
382
385
// 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 ( )
385
388
{
386
389
TransparentColorMode = PngTransparentColorMode . Clear ,
387
390
ColorType = colorType
@@ -391,7 +394,7 @@ public void Encode_WithPngTransparentColorBehaviorClear_Works(PngColorType color
391
394
{
392
395
for ( int y = 0 ; y < image . Height ; y ++ )
393
396
{
394
- System . Span < Rgba32 > rowSpan = accessor . GetRowSpan ( y ) ;
397
+ Span < Rgba32 > rowSpan = accessor . GetRowSpan ( y ) ;
395
398
396
399
// Half of the test image should be transparent.
397
400
if ( y > 25 )
@@ -407,12 +410,12 @@ public void Encode_WithPngTransparentColorBehaviorClear_Works(PngColorType color
407
410
} ) ;
408
411
409
412
// act
410
- using var memStream = new MemoryStream ( ) ;
413
+ using MemoryStream memStream = new ( ) ;
411
414
image . Save ( memStream , encoder ) ;
412
415
413
416
// assert
414
417
memStream . Position = 0 ;
415
- using var actual = Image . Load < Rgba32 > ( memStream ) ;
418
+ using Image < Rgba32 > actual = Image . Load < Rgba32 > ( memStream ) ;
416
419
Rgba32 expectedColor = Color . Blue ;
417
420
if ( colorType is PngColorType . Grayscale or PngColorType . GrayscaleWithAlpha )
418
421
{
@@ -424,7 +427,7 @@ public void Encode_WithPngTransparentColorBehaviorClear_Works(PngColorType color
424
427
{
425
428
for ( int y = 0 ; y < accessor . Height ; y ++ )
426
429
{
427
- System . Span < Rgba32 > rowSpan = accessor . GetRowSpan ( y ) ;
430
+ Span < Rgba32 > rowSpan = accessor . GetRowSpan ( y ) ;
428
431
429
432
if ( y > 25 )
430
433
{
@@ -443,15 +446,15 @@ public void Encode_WithPngTransparentColorBehaviorClear_Works(PngColorType color
443
446
[ MemberData ( nameof ( PngTrnsFiles ) ) ]
444
447
public void Encode_PreserveTrns ( string imagePath , PngBitDepth pngBitDepth , PngColorType pngColorType )
445
448
{
446
- var testFile = TestFile . Create ( imagePath ) ;
449
+ TestFile testFile = TestFile . Create ( imagePath ) ;
447
450
using Image < Rgba32 > input = testFile . CreateRgba32Image ( ) ;
448
451
PngMetadata inMeta = input . Metadata . GetPngMetadata ( ) ;
449
452
Assert . True ( inMeta . HasTransparency ) ;
450
453
451
- using var memStream = new MemoryStream ( ) ;
454
+ using MemoryStream memStream = new ( ) ;
452
455
input . Save ( memStream , PngEncoder ) ;
453
456
memStream . Position = 0 ;
454
- using var output = Image . Load < Rgba32 > ( memStream ) ;
457
+ using Image < Rgba32 > output = Image . Load < Rgba32 > ( memStream ) ;
455
458
PngMetadata outMeta = output . Metadata . GetPngMetadata ( ) ;
456
459
Assert . True ( outMeta . HasTransparency ) ;
457
460
@@ -501,8 +504,8 @@ public void Encode_WorksWithDiscontiguousBuffers<TPixel>(TestImageProvider<TPixe
501
504
PngFilterMethod . Adaptive ,
502
505
PngBitDepth . Bit8 ,
503
506
interlaceMode ,
504
- appendPixelType : true ,
505
- appendPngColorType : true ) ;
507
+ appendPngColorType : true ,
508
+ appendPixelType : true ) ;
506
509
}
507
510
}
508
511
@@ -523,8 +526,8 @@ static void RunTest(string serialized)
523
526
PngFilterMethod . Adaptive ,
524
527
PngBitDepth . Bit8 ,
525
528
interlaceMode ,
526
- appendPixelType : true ,
527
- appendPngColorType : true ) ;
529
+ appendPngColorType : true ,
530
+ appendPixelType : true ) ;
528
531
}
529
532
}
530
533
@@ -538,8 +541,8 @@ static void RunTest(string serialized)
538
541
public void EncodeFixesInvalidOptions ( )
539
542
{
540
543
// 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 ) ;
543
546
using Image < Rgba32 > image = testFile . CreateRgba32Image ( PngDecoder . Instance ) ;
544
547
545
548
image . Save ( ms , new PngEncoder { ColorType = PngColorType . RgbWithAlpha } ) ;
@@ -563,7 +566,7 @@ private static void TestPngEncoderCore<TPixel>(
563
566
where TPixel : unmanaged, IPixel < TPixel >
564
567
{
565
568
using Image < TPixel > image = provider . GetImage ( ) ;
566
- var encoder = new PngEncoder
569
+ PngEncoder encoder = new ( )
567
570
{
568
571
ColorType = pngColorType ,
569
572
FilterMethod = pngFilterMethod ,
@@ -581,7 +584,7 @@ private static void TestPngEncoderCore<TPixel>(
581
584
string pngBitDepthInfo = appendPngBitDepth ? bitDepth . ToString ( ) : string . Empty ;
582
585
string pngInterlaceModeInfo = interlaceMode != PngInterlaceMode . None ? $ "_{ interlaceMode } " : string . Empty ;
583
586
584
- string debugInfo = $ " { pngColorTypeInfo } { pngFilterMethodInfo } { compressionLevelInfo } { paletteSizeInfo } { pngBitDepthInfo } { pngInterlaceModeInfo } " ;
587
+ string debugInfo = pngColorTypeInfo + pngFilterMethodInfo + compressionLevelInfo + paletteSizeInfo + pngBitDepthInfo + pngInterlaceModeInfo ;
585
588
586
589
string actualOutputFile = provider . Utility . SaveTestOutputFile ( image , "png" , encoder , debugInfo , appendPixelType ) ;
587
590
0 commit comments