diff --git a/samples/ComputeSharp.ImageProcessing/Program.cs b/samples/ComputeSharp.ImageProcessing/Program.cs index 0886c24b..9d862a93 100644 --- a/samples/ComputeSharp.ImageProcessing/Program.cs +++ b/samples/ComputeSharp.ImageProcessing/Program.cs @@ -7,40 +7,34 @@ using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Processors; using ImageSharpRgba32 = SixLabors.ImageSharp.PixelFormats.Rgba32; -namespace ComputeSharp.ImageProcessing; +Configuration.Default.PreferContiguousImageBuffers = true; -class Program +Console.WriteLine(">> Loading image"); + +string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "city.jpg"); +using Image image = Image.Load(path); + +// Apply a series of processors and save the results +foreach (var effect in new (string Name, IImageProcessor Processor)[] { - static void Main() + ("bokeh", new HlslBokehBlurProcessor(80, 2)), + ("gaussian", new HlslGaussianBlurProcessor(80)) +}) +{ + Console.WriteLine($">> Applying {effect.Name}"); + + using Image copy = image.Clone(c => c.ApplyProcessor(effect.Processor)); + + Console.WriteLine($">> Saving {effect.Name} to disk"); + + string targetPath = Path.GetDirectoryName(path)!; + + while (Path.GetFileName(targetPath) != "ComputeSharp.ImageProcessing") { - Configuration.Default.PreferContiguousImageBuffers = true; - - Console.WriteLine(">> Loading image"); - string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "city.jpg"); - using Image image = Image.Load(path); - - // Apply a series of processors and save the results - foreach (var effect in new (string Name, IImageProcessor Processor)[] - { - ("bokeh", new HlslBokehBlurProcessor(80, 2)), - ("gaussian", new HlslGaussianBlurProcessor(80)) - }) - { - Console.WriteLine($">> Applying {effect.Name}"); - using Image copy = image.Clone(c => c.ApplyProcessor(effect.Processor)); - - Console.WriteLine($">> Saving {effect.Name} to disk"); - - string targetPath = Path.GetDirectoryName(path)!; - - while (Path.GetFileName(targetPath) != "ComputeSharp.ImageProcessing") - { - targetPath = Path.GetDirectoryName(targetPath)!; - } - - targetPath = Path.Combine(targetPath, $"{Path.GetFileNameWithoutExtension(path)}_{effect.Name}{Path.GetExtension(path)}"); - - copy.Save(targetPath); - } + targetPath = Path.GetDirectoryName(targetPath)!; } + + targetPath = Path.Combine(targetPath, $"{Path.GetFileNameWithoutExtension(path)}_{effect.Name}{Path.GetExtension(path)}"); + + copy.Save(targetPath); }