@@ -21,7 +21,7 @@ namespace SixLabors.ImageSharp.Drawing.Tests.Drawing
2121 [ GroupOutput ( "Drawing" ) ]
2222 public class DrawingRobustnessTests
2323 {
24- [ Theory ( Skip = "For local experiments " ) ]
24+ [ Theory ( Skip = "For local testing " ) ]
2525 [ WithSolidFilledImages ( 32 , 32 , "Black" , PixelTypes . Rgba32 ) ]
2626 public void CompareToSkiaResults_SmallCircle ( TestImageProvider < Rgba32 > provider )
2727 {
@@ -30,7 +30,7 @@ public void CompareToSkiaResults_SmallCircle(TestImageProvider<Rgba32> provider)
3030 CompareToSkiaResultsImpl ( provider , circle ) ;
3131 }
3232
33- [ Theory ( Skip = "For local experiments " ) ]
33+ [ Theory ( Skip = "For local testing " ) ]
3434 [ WithSolidFilledImages ( 64 , 64 , "Black" , PixelTypes . Rgba32 ) ]
3535 public void CompareToSkiaResults_StarCircle ( TestImageProvider < Rgba32 > provider )
3636 {
@@ -77,7 +77,7 @@ private static void CompareToSkiaResultsImpl(TestImageProvider<Rgba32> provider,
7777 throw new Exception ( result . DifferencePercentageString ) ;
7878 }
7979
80- [ Theory ]
80+ [ Theory ( Skip = "For local testing" ) ]
8181 [ WithSolidFilledImages ( 3600 , 2400 , "Black" , PixelTypes . Rgba32 , TestImages . GeoJson . States , 16 , 30 , 30 ) ]
8282 public void LargeGeoJson_Lines ( TestImageProvider < Rgba32 > provider , string geoJsonFile , int aa , float sx , float sy )
8383 {
@@ -104,42 +104,43 @@ public void LargeGeoJson_Lines(TestImageProvider<Rgba32> provider, string geoJso
104104 }
105105
106106 [ Theory ]
107- // [WithSolidFilledImages(3600, 2400, "Black", PixelTypes.Rgba32, TestImages.GeoJson.States, 16, 30, 30, false)]
108- [ WithSolidFilledImages ( 3600 , 2400 , "Black" , PixelTypes . Rgba32 , TestImages . GeoJson . States , 16 , 30 , 30 ) ]
109- [ WithSolidFilledImages ( 7200 , 4800 , "Black" , PixelTypes . Rgba32 , TestImages . GeoJson . States , 16 , 60 , 60 ) ]
110- public void LargeGeoJson_Fill ( TestImageProvider < Rgba32 > provider , string geoJsonFile , int aa , float sx , float sy )
107+ [ WithSolidFilledImages ( 7200 , 3300 , "Black" , PixelTypes . Rgba32 ) ]
108+ public void LargeGeoJson_States_Fill ( TestImageProvider < Rgba32 > provider )
109+ {
110+ using Image < Rgba32 > image = FillGeoJsonPolygons ( provider , TestImages . GeoJson . States , 16 , new Vector2 ( 60 ) , new Vector2 ( 0 , - 1000 ) ) ;
111+ image . DebugSave ( provider , appendPixelTypeToFileName : false , appendSourceFileOrDescription : false ) ;
112+ image . CompareToReferenceOutput ( provider , appendPixelTypeToFileName : false , appendSourceFileOrDescription : false ) ;
113+ }
114+
115+ private Image < Rgba32 > FillGeoJsonPolygons ( TestImageProvider < Rgba32 > provider , string geoJsonFile , int aa , Vector2 scale , Vector2 pixelOffset )
111116 {
112117 string jsonContent = File . ReadAllText ( TestFile . GetInputFileFullPath ( geoJsonFile ) ) ;
113118
114- PointF [ ] [ ] points = PolygonFactory . GetGeoJsonPoints ( jsonContent , Matrix3x2 . CreateScale ( sx , sy ) ) ;
119+ PointF [ ] [ ] points = PolygonFactory . GetGeoJsonPoints ( jsonContent , Matrix3x2 . CreateScale ( scale ) * Matrix3x2 . CreateTranslation ( pixelOffset ) ) ;
115120
116- using Image < Rgba32 > image = provider . GetImage ( ) ;
121+ Image < Rgba32 > image = provider . GetImage ( ) ;
117122 var options = new ShapeGraphicsOptions ( )
118123 {
119124 GraphicsOptions = new GraphicsOptions ( ) { Antialias = aa > 0 , AntialiasSubpixelDepth = aa } ,
120125 } ;
121126 var rnd = new Random ( 42 ) ;
127+ int i = 0 ;
128+ byte [ ] rgb = new byte [ 3 ] ;
122129 foreach ( PointF [ ] loop in points )
123130 {
124- Color color = Color . WebSafePalette . Span [ rnd . Next ( Color . WebSafePalette . Length ) ] ;
131+ rnd . NextBytes ( rgb ) ;
132+
133+ Color color = Color . FromRgb ( rgb [ 0 ] , rgb [ 1 ] , rgb [ 2 ] ) ;
125134 image . Mutate ( c => c . FillPolygon ( options , color , loop ) ) ;
126135 }
127136
128- string details = $ "_{ System . IO . Path . GetFileName ( geoJsonFile ) } _{ sx } x{ sy } _aa{ aa } ";
129-
130- image . DebugSave ( provider ,
131- details ,
132- appendPixelTypeToFileName : false ,
133- appendSourceFileOrDescription : false ) ;
137+ return image ;
134138 }
135139
136140 [ Theory ]
137- [ WithSolidFilledImages ( 10000 , 10000 , "Black" , PixelTypes . Rgba32 , 16 , 0 ) ]
138- // [WithSolidFilledImages(10000, 10000, "Black", PixelTypes.Rgba32, 16, 0, true)]
139- // [WithSolidFilledImages(10000, 10000, "Black", PixelTypes.Rgba32, 16, 5000, false)]
140- // [WithSolidFilledImages(10000, 10000, "Black", PixelTypes.Rgba32, 16, 5000, true)]
141- // [WithSolidFilledImages(10000, 10000, "Black", PixelTypes.Rgba32, 16, 9000, true)]
142- public void Mississippi_Lines ( TestImageProvider < Rgba32 > provider , int aa , int offset )
141+ [ WithSolidFilledImages ( 400 , 400 , "Black" , PixelTypes . Rgba32 , 0 ) ]
142+ [ WithSolidFilledImages ( 6000 , 6000 , "Black" , PixelTypes . Rgba32 , 5500 ) ]
143+ public void LargeGeoJson_Mississippi_Lines ( TestImageProvider < Rgba32 > provider , int pixelOffset )
143144 {
144145 string jsonContent = File . ReadAllText ( TestFile . GetInputFileFullPath ( TestImages . GeoJson . States ) ) ;
145146
@@ -149,29 +150,24 @@ public void Mississippi_Lines(TestImageProvider<Rgba32> provider, int aa, int of
149150
150151 var transform = Matrix3x2 . CreateTranslation ( - 87 , - 54 )
151152 * Matrix3x2 . CreateScale ( 60 , 60 )
152- * Matrix3x2 . CreateTranslation ( offset , offset ) ;
153+ * Matrix3x2 . CreateTranslation ( pixelOffset , pixelOffset ) ;
153154 var points = PolygonFactory . GetGeoJsonPoints ( missisipiGeom , transform ) ;
154155
155156 using Image < Rgba32 > image = provider . GetImage ( ) ;
156- var options = new ShapeGraphicsOptions ( )
157- {
158- GraphicsOptions = new GraphicsOptions ( ) { Antialias = aa > 0 , AntialiasSubpixelDepth = aa } ,
159- } ;
157+
160158 foreach ( PointF [ ] loop in points )
161159 {
162- image . Mutate ( c => c . DrawLines ( options , Color . White , 1.0f , loop ) ) ;
160+ image . Mutate ( c => c . DrawLines ( Color . White , 1.0f , loop ) ) ;
163161 }
164162
165- string details = $ "_aa{ aa } _t{ offset } ";
166-
167- image . DebugSave ( provider ,
168- details ,
169- appendPixelTypeToFileName : false ,
170- appendSourceFileOrDescription : false ) ;
171-
163+ // Very strict tolerance, since the image is sparse:
164+ ImageComparer comparer = ImageComparer . TolerantPercentage ( 1e-7f ) ;
165+ string details = $ "PixelOffset({ pixelOffset } )";
166+ image . DebugSave ( provider , details , appendPixelTypeToFileName : false , appendSourceFileOrDescription : false ) ;
167+ image . CompareToReferenceOutput ( comparer , provider , testOutputDetails : details , appendPixelTypeToFileName : false , appendSourceFileOrDescription : false ) ;
172168 }
173169
174- [ Theory ]
170+ [ Theory ( Skip = "For local experiments only" ) ]
175171 [ InlineData ( 0 ) ]
176172 [ InlineData ( 5000 ) ]
177173 [ InlineData ( 9000 ) ]
0 commit comments