From 930e3bd5849b3565c75a404ecda806f77b56e5d0 Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Tue, 9 May 2023 13:37:12 +0200 Subject: [PATCH] Use new using code style. --- docs/CombiningImages.md | 9 ++++----- docs/ConvertImage.md | 15 +++++++-------- samples/Magick.NET.Samples/CombiningImages.cs | 9 ++++----- samples/Magick.NET.Samples/ConvertImage.cs | 13 ++++++------- 4 files changed, 21 insertions(+), 25 deletions(-) diff --git a/docs/CombiningImages.md b/docs/CombiningImages.md index 3602b4abe6..580df9859f 100644 --- a/docs/CombiningImages.md +++ b/docs/CombiningImages.md @@ -14,11 +14,10 @@ var second = new MagickImage(SampleFiles.SnakewarePng); images.Add(second); // Create a mosaic from both images -using (var result = images.Mosaic()) -{ - // Save the result - result.Write("Mosaic.png"); -} +using var result = images.Mosaic(); + +// Save the result +result.Write("Mosaic.png"); ``` ## Create animated gif diff --git a/docs/ConvertImage.md b/docs/ConvertImage.md index d09d6dfa7c..5a206e57fd 100644 --- a/docs/ConvertImage.md +++ b/docs/ConvertImage.md @@ -7,7 +7,7 @@ using var image = new MagickImage(SampleFiles.SnakewareGif); // Save frame as jpg -image.Write("Snakeware.jpg"); +image.Write(SampleFiles.OutputDirectory + "Snakeware.jpg"); var settings = new MagickReadSettings(); // Tells the xc: reader the image to create should be 800x600 @@ -17,14 +17,13 @@ settings.Height = 600; using var memStream = new MemoryStream(); // Create image that is completely purple and 800x600 -using (var purple = new MagickImage("xc:purple", settings)) -{ - // Sets the output format to png - purple.Format = MagickFormat.Png; +using var purple = new MagickImage("xc:purple", settings); + +// Sets the output format to png +purple.Format = MagickFormat.Png; - // Write the image to the memorystream - purple.Write(memStream); -} +// Write the image to the memorystream +purple.Write(memStream); // Read image from file using var snakeware = new MagickImage(SampleFiles.SnakewarePng); diff --git a/samples/Magick.NET.Samples/CombiningImages.cs b/samples/Magick.NET.Samples/CombiningImages.cs index 1c527a6fea..69cfbb8af5 100644 --- a/samples/Magick.NET.Samples/CombiningImages.cs +++ b/samples/Magick.NET.Samples/CombiningImages.cs @@ -20,11 +20,10 @@ public static void MergeMultipleImages() images.Add(second); // Create a mosaic from both images - using (var result = images.Mosaic()) - { - // Save the result - result.Write(SampleFiles.OutputDirectory + "Mosaic.png"); - } + using var result = images.Mosaic(); + + // Save the result + result.Write(SampleFiles.OutputDirectory + "Mosaic.png"); } public static void CreateAnimatedGif() diff --git a/samples/Magick.NET.Samples/ConvertImage.cs b/samples/Magick.NET.Samples/ConvertImage.cs index 00d28fe6e3..bd2bb14bd6 100644 --- a/samples/Magick.NET.Samples/ConvertImage.cs +++ b/samples/Magick.NET.Samples/ConvertImage.cs @@ -24,14 +24,13 @@ public static void ConvertImageFromOneFormatToAnother() using var memStream = new MemoryStream(); // Create image that is completely purple and 800x600 - using (var purple = new MagickImage("xc:purple", settings)) - { - // Sets the output format to png - purple.Format = MagickFormat.Png; + using var purple = new MagickImage("xc:purple", settings); + + // Sets the output format to png + purple.Format = MagickFormat.Png; - // Write the image to the memorystream - purple.Write(memStream); - } + // Write the image to the memorystream + purple.Write(memStream); // Read image from file using var snakeware = new MagickImage(SampleFiles.SnakewarePng);