@@ -12,74 +12,66 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Quantization;
1212[ Trait ( "Category" , "Processors" ) ]
1313public class QuantizerTests
1414{
15- /// <summary>
16- /// Something is causing tests to fail on NETFX in CI.
17- /// Could be a JIT error as everything runs well and is identical to .NET Core output.
18- /// Not worth investigating for now.
19- /// <see href="https://github.com/SixLabors/ImageSharp/pull/1114/checks?check_run_id=448891164#step:11:631"/>
20- /// </summary>
21- private static readonly bool SkipAllQuantizerTests = TestEnvironment . IsFramework ;
22-
2315 public static readonly string [ ] CommonTestImages =
2416 {
2517 TestImages . Png . CalliphoraPartial ,
2618 TestImages . Png . Bike
2719 } ;
2820
29- private static readonly QuantizerOptions NoDitherOptions = new QuantizerOptions { Dither = null } ;
30- private static readonly QuantizerOptions DiffuserDitherOptions = new QuantizerOptions { Dither = KnownDitherings . FloydSteinberg } ;
31- private static readonly QuantizerOptions OrderedDitherOptions = new QuantizerOptions { Dither = KnownDitherings . Bayer8x8 } ;
21+ private static readonly QuantizerOptions NoDitherOptions = new ( ) { Dither = null } ;
22+ private static readonly QuantizerOptions DiffuserDitherOptions = new ( ) { Dither = KnownDitherings . FloydSteinberg } ;
23+ private static readonly QuantizerOptions OrderedDitherOptions = new ( ) { Dither = KnownDitherings . Bayer8x8 } ;
3224
33- private static readonly QuantizerOptions Diffuser0_ScaleDitherOptions = new QuantizerOptions
25+ private static readonly QuantizerOptions Diffuser0_ScaleDitherOptions = new ( )
3426 {
3527 Dither = KnownDitherings . FloydSteinberg ,
3628 DitherScale = 0F
3729 } ;
3830
39- private static readonly QuantizerOptions Diffuser0_25_ScaleDitherOptions = new QuantizerOptions
31+ private static readonly QuantizerOptions Diffuser0_25_ScaleDitherOptions = new ( )
4032 {
4133 Dither = KnownDitherings . FloydSteinberg ,
4234 DitherScale = .25F
4335 } ;
4436
45- private static readonly QuantizerOptions Diffuser0_5_ScaleDitherOptions = new QuantizerOptions
37+ private static readonly QuantizerOptions Diffuser0_5_ScaleDitherOptions = new ( )
4638 {
4739 Dither = KnownDitherings . FloydSteinberg ,
4840 DitherScale = .5F
4941 } ;
5042
51- private static readonly QuantizerOptions Diffuser0_75_ScaleDitherOptions = new QuantizerOptions
43+ private static readonly QuantizerOptions Diffuser0_75_ScaleDitherOptions = new ( )
5244 {
5345 Dither = KnownDitherings . FloydSteinberg ,
5446 DitherScale = .75F
5547 } ;
5648
57- private static readonly QuantizerOptions Ordered0_ScaleDitherOptions = new QuantizerOptions
49+ private static readonly QuantizerOptions Ordered0_ScaleDitherOptions = new ( )
5850 {
5951 Dither = KnownDitherings . Bayer8x8 ,
6052 DitherScale = 0F
6153 } ;
6254
63- private static readonly QuantizerOptions Ordered0_25_ScaleDitherOptions = new QuantizerOptions
55+ private static readonly QuantizerOptions Ordered0_25_ScaleDitherOptions = new ( )
6456 {
6557 Dither = KnownDitherings . Bayer8x8 ,
6658 DitherScale = .25F
6759 } ;
6860
69- private static readonly QuantizerOptions Ordered0_5_ScaleDitherOptions = new QuantizerOptions
61+ private static readonly QuantizerOptions Ordered0_5_ScaleDitherOptions = new ( )
7062 {
7163 Dither = KnownDitherings . Bayer8x8 ,
7264 DitherScale = .5F
7365 } ;
7466
75- private static readonly QuantizerOptions Ordered0_75_ScaleDitherOptions = new QuantizerOptions
67+ private static readonly QuantizerOptions Ordered0_75_ScaleDitherOptions = new ( )
7668 {
7769 Dither = KnownDitherings . Bayer8x8 ,
7870 DitherScale = .75F
7971 } ;
8072
8173 public static readonly TheoryData < IQuantizer > Quantizers
82- = new TheoryData < IQuantizer >
74+ = new ( )
8375 {
8476 // Known uses error diffusion by default.
8577 KnownQuantizers . Octree ,
@@ -97,7 +89,7 @@ public static readonly TheoryData<IQuantizer> Quantizers
9789 } ;
9890
9991 public static readonly TheoryData < IQuantizer > DitherScaleQuantizers
100- = new TheoryData < IQuantizer >
92+ = new ( )
10193 {
10294 new OctreeQuantizer ( Diffuser0_ScaleDitherOptions ) ,
10395 new WebSafePaletteQuantizer ( Diffuser0_ScaleDitherOptions ) ,
@@ -151,7 +143,7 @@ public static readonly TheoryData<IQuantizer> DitherScaleQuantizers
151143 } ;
152144
153145 public static readonly TheoryData < IDither > DefaultInstanceDitherers
154- = new TheoryData < IDither >
146+ = new ( )
155147 {
156148 default ( ErrorDither ) ,
157149 default ( OrderedDither )
@@ -164,11 +156,6 @@ public static readonly TheoryData<IDither> DefaultInstanceDitherers
164156 public void ApplyQuantizationInBox < TPixel > ( TestImageProvider < TPixel > provider , IQuantizer quantizer )
165157 where TPixel : unmanaged, IPixel < TPixel >
166158 {
167- if ( SkipAllQuantizerTests )
168- {
169- return ;
170- }
171-
172159 string quantizerName = quantizer . GetType ( ) . Name ;
173160 string ditherName = quantizer . Options . Dither ? . GetType ( ) ? . Name ?? "NoDither" ;
174161 string testOutputDetails = $ "{ quantizerName } _{ ditherName } ";
@@ -185,11 +172,6 @@ public void ApplyQuantizationInBox<TPixel>(TestImageProvider<TPixel> provider, I
185172 public void ApplyQuantization < TPixel > ( TestImageProvider < TPixel > provider , IQuantizer quantizer )
186173 where TPixel : unmanaged, IPixel < TPixel >
187174 {
188- if ( SkipAllQuantizerTests )
189- {
190- return ;
191- }
192-
193175 string quantizerName = quantizer . GetType ( ) . Name ;
194176 string ditherName = quantizer . Options . Dither ? . GetType ( ) ? . Name ?? "NoDither" ;
195177 string testOutputDetails = $ "{ quantizerName } _{ ditherName } ";
@@ -206,11 +188,6 @@ public void ApplyQuantization<TPixel>(TestImageProvider<TPixel> provider, IQuant
206188 public void ApplyQuantizationWithDitheringScale < TPixel > ( TestImageProvider < TPixel > provider , IQuantizer quantizer )
207189 where TPixel : unmanaged, IPixel < TPixel >
208190 {
209- if ( SkipAllQuantizerTests )
210- {
211- return ;
212- }
213-
214191 string quantizerName = quantizer . GetType ( ) . Name ;
215192 string ditherName = quantizer . Options . Dither . GetType ( ) . Name ;
216193 float ditherScale = quantizer . Options . DitherScale ;
@@ -229,8 +206,8 @@ public void ShouldThrowForDefaultDitherInstance(IDither dither)
229206 {
230207 void Command ( )
231208 {
232- using var image = new Image < Rgba32 > ( 10 , 10 ) ;
233- var quantizer = new WebSafePaletteQuantizer ( ) ;
209+ using Image < Rgba32 > image = new ( 10 , 10 ) ;
210+ WebSafePaletteQuantizer quantizer = new ( ) ;
234211 quantizer . Options . Dither = dither ;
235212 image . Mutate ( x => x . Quantize ( quantizer ) ) ;
236213 }
0 commit comments