Skip to content

Commit

Permalink
Use new using code style.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemstra committed May 9, 2023
1 parent 9fecc99 commit 930e3bd
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 25 deletions.
9 changes: 4 additions & 5 deletions docs/CombiningImages.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 7 additions & 8 deletions docs/ConvertImage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down
9 changes: 4 additions & 5 deletions samples/Magick.NET.Samples/CombiningImages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
13 changes: 6 additions & 7 deletions samples/Magick.NET.Samples/ConvertImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 930e3bd

Please sign in to comment.