Browse Source

Fix memory leak in sampler tests

Former-commit-id: 4b9ffafdd826522b192bfeb8411faefee7621a16
Former-commit-id: 560f124d694ee156b4a1e7e6a0c2d92ee87edc0e
Former-commit-id: 672cf548c6014bfbd4ec4453d1b029e11091f533
pull/1/head
James South 10 years ago
parent
commit
b313504553
  1. 25
      tests/ImageProcessorCore.Tests/Processors/Samplers/SamplerTests.cs

25
tests/ImageProcessorCore.Tests/Processors/Samplers/SamplerTests.cs

@ -61,6 +61,7 @@
Stopwatch watch = Stopwatch.StartNew();
Image image = new Image(stream);
string filename = Path.GetFileNameWithoutExtension(file) + "-" + name + Path.GetExtension(file);
using (FileStream output = File.OpenWrite($"TestOutput/Sample/{ Path.GetFileName(filename) }"))
{
processor.OnProgress += this.ProgressUpdate;
@ -69,6 +70,7 @@
processor.OnProgress -= this.ProgressUpdate;
}
image.Dispose();
Trace.WriteLine($"{ name }: { watch.ElapsedMilliseconds}ms");
}
}
@ -88,8 +90,9 @@
using (FileStream stream = File.OpenRead(file))
{
Stopwatch watch = Stopwatch.StartNew();
Image image = new Image(stream);
string filename = Path.GetFileNameWithoutExtension(file) + "-" + name + Path.GetExtension(file);
using (Image image = new Image(stream))
using (FileStream output = File.OpenWrite($"TestOutput/Resize/{filename}"))
{
image.Resize(image.Width / 2, image.Height / 2, sampler, false, this.ProgressUpdate)
@ -116,8 +119,9 @@
using (FileStream stream = File.OpenRead(file))
{
Stopwatch watch = Stopwatch.StartNew();
Image image = new Image(stream);
string filename = Path.GetFileNameWithoutExtension(file) + "-" + name + Path.GetExtension(file);
using (Image image = new Image(stream))
using (FileStream output = File.OpenWrite($"TestOutput/Resize/{filename}"))
{
image.Resize(image.Width / 3, 0, new TriangleResampler(), false, this.ProgressUpdate)
@ -144,8 +148,9 @@
using (FileStream stream = File.OpenRead(file))
{
Stopwatch watch = Stopwatch.StartNew();
Image image = new Image(stream);
string filename = Path.GetFileNameWithoutExtension(file) + "-" + name + Path.GetExtension(file);
using (Image image = new Image(stream))
using (FileStream output = File.OpenWrite($"TestOutput/Resize/{filename}"))
{
image.Resize(0, image.Height / 3, new TriangleResampler(), false, this.ProgressUpdate)
@ -171,8 +176,9 @@
using (FileStream stream = File.OpenRead(file))
{
Stopwatch watch = Stopwatch.StartNew();
Image image = new Image(stream);
string filename = Path.GetFileNameWithoutExtension(file) + "-" + rotateType + flipType + Path.GetExtension(file);
using (Image image = new Image(stream))
using (FileStream output = File.OpenWrite($"TestOutput/RotateFlip/{filename}"))
{
image.RotateFlip(rotateType, flipType, this.ProgressUpdate)
@ -197,8 +203,10 @@
using (FileStream stream = File.OpenRead(file))
{
Stopwatch watch = Stopwatch.StartNew();
Image image = new Image(stream);
string filename = Path.GetFileName(file);
using (Image image = new Image(stream))
using (FileStream output = File.OpenWrite($"TestOutput/Rotate/{filename}"))
{
image.Rotate(45, this.ProgressUpdate)
@ -223,8 +231,10 @@
using (FileStream stream = File.OpenRead(file))
{
Stopwatch watch = Stopwatch.StartNew();
Image image = new Image(stream);
string filename = Path.GetFileName(file);
using (Image image = new Image(stream))
using (FileStream output = File.OpenWrite($"TestOutput/Skew/{filename}"))
{
image.Skew(45, 45, this.ProgressUpdate)
@ -248,8 +258,9 @@
{
using (FileStream stream = File.OpenRead(file))
{
Image image = new Image(stream);
string filename = Path.GetFileNameWithoutExtension(file) + "-EntropyCrop" + Path.GetExtension(file);
using (Image image = new Image(stream))
using (FileStream output = File.OpenWrite($"TestOutput/EntropyCrop/{filename}"))
{
image.EntropyCrop(.5f, this.ProgressUpdate).Save(output);

Loading…
Cancel
Save