66 * PROGRAMER: Peter Geinitz (Wayfarer)
77 */
88
9+ // ReSharper disable UnusedMember.Global
10+ // ReSharper disable UnusedType.Global
11+
912using System ;
1013using System . Collections . Generic ;
1114using System . Drawing ;
1215using System . Drawing . Imaging ;
16+ using System . Linq ;
1317using System . Threading . Tasks ;
1418using System . Windows . Media . Imaging ;
1519using Imaging . Enums ;
1620
1721namespace Imaging
1822{
1923 /// <summary>
20- /// Unified facade for the Imaging engine.
24+ /// Unified façade for the Imaging engine.
2125 /// This class provides a stable public API for common image processing tasks,
2226 /// including loading, saving, conversion, resizing, filtering, pixel manipulation,
2327 /// GIF handling, blending, and texture generation.
@@ -26,8 +30,8 @@ namespace Imaging
2630 /// </summary>
2731 public static class ImagingFacade
2832 {
29-
3033 #region Register
34+
3135 /// <summary>
3236 /// Gets the singleton instance of the <see cref="ImageRegister"/>.
3337 /// Allows querying and modifying filter and texture settings globally.
@@ -46,7 +50,8 @@ public static class ImagingFacade
4650 /// </summary>
4751 /// <param name="filter">The filter type.</param>
4852 /// <param name="config">The new filter configuration.</param>
49- public static void SetFilterSettings ( FiltersType filter , FiltersConfig config ) => Register . SetSettings ( filter , config ) ;
53+ public static void SetFilterSettings ( FiltersType filter , FiltersConfig config ) =>
54+ Register . SetSettings ( filter , config ) ;
5055
5156 /// <summary>
5257 /// Retrieves all available filters.
@@ -73,7 +78,8 @@ public static class ImagingFacade
7378 /// </summary>
7479 /// <param name="texture">The texture type.</param>
7580 /// <param name="config">The new texture configuration.</param>
76- public static void SetTextureSettings ( TextureType texture , TextureConfiguration config ) => Register . SetSettings ( texture , config ) ;
81+ public static void SetTextureSettings ( TextureType texture , TextureConfiguration config ) =>
82+ Register . SetSettings ( texture , config ) ;
7783
7884 /// <summary>
7985 /// Gets the property names used by a specific texture type.
@@ -104,6 +110,7 @@ public static class ImagingFacade
104110 /// Gets the last error message recorded by the Imaging engine.
105111 /// </summary>
106112 public static string ? LastError => Register . LastError ;
113+
107114 #endregion
108115
109116 #region Load / Save
@@ -191,7 +198,7 @@ public static Bitmap Crop(Bitmap image, int x, int y, int width, int height)
191198 /// <param name="image">The source bitmap.</param>
192199 /// <param name="filter">The filter type to apply.</param>
193200 /// <returns>The filtered <see cref="Bitmap"/>.</returns>
194- public static Bitmap ApplyFilter ( Bitmap image , FiltersType filter )
201+ public static Bitmap ? ApplyFilter ( Bitmap image , FiltersType filter )
195202 => new ImageRender ( ) . FilterImage ( image , filter ) ;
196203
197204 /// <summary>
@@ -203,7 +210,8 @@ public static Bitmap ApplyFilter(Bitmap image, FiltersType filter)
203210 /// <param name="shapeParams">Optional parameters for the mask shape.</param>
204211 /// <param name="startPoint">Optional start point for the filter.</param>
205212 /// <returns>The filtered <see cref="Bitmap"/>.</returns>
206- public static Bitmap ApplyFilterArea ( Bitmap image , FiltersType filter , MaskShape shape , object shapeParams , System . Drawing . Point ? startPoint = null )
213+ public static Bitmap ApplyFilterArea ( Bitmap image , FiltersType filter , MaskShape shape , object shapeParams ,
214+ Point ? startPoint = null )
207215 => new ImageRender ( ) . FilterImageArea ( image , null , null , filter , shape , shapeParams , startPoint ) ;
208216
209217 #endregion
@@ -216,7 +224,7 @@ public static Bitmap ApplyFilterArea(Bitmap image, FiltersType filter, MaskShape
216224 /// <param name="image">The bitmap.</param>
217225 /// <param name="p">The pixel location.</param>
218226 /// <returns>The <see cref="Color"/> of the pixel.</returns>
219- public static Color GetPixel ( Bitmap image , System . Drawing . Point p )
227+ public static Color GetPixel ( Bitmap image , Point p )
220228 => new ImageRender ( ) . GetPixel ( image , p ) ;
221229
222230 /// <summary>
@@ -225,7 +233,7 @@ public static Color GetPixel(Bitmap image, System.Drawing.Point p)
225233 /// <param name="image">The bitmap.</param>
226234 /// <param name="p">The pixel location.</param>
227235 /// <param name="color">The color to set.</param>
228- public static void SetPixel ( Bitmap image , System . Drawing . Point p , Color color )
236+ public static void SetPixel ( Bitmap image , Point p , Color color )
229237 => new ImageRender ( ) . SetPixel ( image , p , color ) ;
230238
231239 /// <summary>
@@ -250,7 +258,7 @@ public static void FloodFill(Bitmap image, int x, int y, Color newColor)
250258 /// <param name="x">X-coordinate for overlay placement.</param>
251259 /// <param name="y">Y-coordinate for overlay placement.</param>
252260 /// <returns>The combined <see cref="Bitmap"/>.</returns>
253- public static Bitmap Combine ( Bitmap baseImage , Bitmap overlay , int x , int y )
261+ public static Bitmap ? Combine ( Bitmap baseImage , Bitmap overlay , int x , int y )
254262 => new ImageRender ( ) . CombineBitmap ( baseImage , overlay , x , y ) ;
255263
256264 /// <summary>
@@ -316,8 +324,7 @@ public static async Task<IReadOnlyList<Bitmap>> LoadGifAsync(string path)
316324 var sources = await new ImageRender ( ) . LoadGifAsync ( path ) ;
317325
318326 var frames = new List < Bitmap > ( sources . Count ) ;
319- foreach ( var src in sources )
320- frames . Add ( ImageExtension . ToBitmap ( ( BitmapImage ) src ) ) ;
327+ frames . AddRange ( sources . Select ( src => ( ( BitmapImage ) src ) . ToBitmap ( ) ) ) ;
321328
322329 return frames ;
323330 }
@@ -344,7 +351,8 @@ public static void CreateGif(IEnumerable<FrameInfo> frames, string target)
344351 /// <param name="shapeParams">Optional parameters for the shape.</param>
345352 /// <param name="startPoint">Optional starting point.</param>
346353 /// <returns>The generated texture as a <see cref="Bitmap"/>.</returns>
347- public static Bitmap GenerateTexture ( int width , int height , TextureType type , MaskShape shape , object shapeParams , System . Drawing . Point ? startPoint = null )
354+ public static Bitmap ? GenerateTexture ( int width , int height , TextureType type , MaskShape shape ,
355+ object shapeParams , Point ? startPoint = null )
348356 => new TextureGenerator ( ) . GenerateTexture ( width , height , type , shape , startPoint , shapeParams ) ;
349357
350358 #endregion
0 commit comments