Browse Source

Fixing tests to work on Windows.

Former-commit-id: 2bd1a1ae79e1fe865195d47dc9f0cc5da24660b3
pull/17/head
James South 12 years ago
parent
commit
bd59d26d8c
  1. 2
      build/Build.bat
  2. 248
      src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs
  3. 6
      src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj
  4. 4
      src/ImageProcessor/ImageFactory.cs
  5. 2
      src/ImageProcessor/Imaging/Formats/FormatUtilities.cs

2
build/Build.bat

@ -20,7 +20,7 @@ ECHO Packing the NuGet release files
..\src\.nuget\NuGet.exe pack NuSpecs\ImageProcessor.nuspec -Version %version% ..\src\.nuget\NuGet.exe pack NuSpecs\ImageProcessor.nuspec -Version %version%
..\src\.nuget\NuGet.exe pack NuSpecs\ImageProcessor.Web.nuspec -Version %webversion% ..\src\.nuget\NuGet.exe pack NuSpecs\ImageProcessor.Web.nuspec -Version %webversion%
..\src\.nuget\NuGet.exe pack NuSpecs\ImageProcessor.Web.Config.nuspec -Version %webconfigversion% ..\src\.nuget\NuGet.exe pack NuSpecs\ImageProcessor.Web.Config.nuspec -Version %webconfigversion%
PAUSE
IF ERRORLEVEL 1 GOTO :showerror IF ERRORLEVEL 1 GOTO :showerror

248
src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs

@ -12,7 +12,9 @@ namespace ImageProcessor.UnitTests
{ {
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.IO; using System.IO;
using System.Linq;
using NUnit.Framework; using NUnit.Framework;
/// <summary> /// <summary>
@ -21,18 +23,23 @@ namespace ImageProcessor.UnitTests
[TestFixture] [TestFixture]
public class ImageFactoryUnitTests public class ImageFactoryUnitTests
{ {
/// <summary>
/// The list of images. Designed to speed up the tests a little.
/// </summary>
private IEnumerable<FileInfo> images;
/// <summary> /// <summary>
/// Tests the loading of image from a file /// Tests the loading of image from a file
/// </summary> /// </summary>
[Test] [Test]
public void TestLoadImageFromFile() public void TestLoadImageFromFile()
{ {
foreach (var fileName in ListInputFiles()) foreach (FileInfo file in this.ListInputFiles())
{ {
using (var imageFactory = new ImageFactory()) using (ImageFactory imageFactory = new ImageFactory())
{ {
imageFactory.Load(fileName); imageFactory.Load(file.FullName);
Assert.AreEqual(fileName, imageFactory.ImagePath); Assert.AreEqual(file.FullName, imageFactory.ImagePath);
Assert.IsNotNull(imageFactory.Image); Assert.IsNotNull(imageFactory.Image);
} }
} }
@ -44,13 +51,13 @@ namespace ImageProcessor.UnitTests
[Test] [Test]
public void TestLoadImageFromMemory() public void TestLoadImageFromMemory()
{ {
foreach (var fileName in ListInputFiles()) foreach (FileInfo file in this.ListInputFiles())
{ {
byte[] photoBytes = File.ReadAllBytes(fileName); byte[] photoBytes = File.ReadAllBytes(file.FullName);
using (var inStream = new MemoryStream(photoBytes)) using (MemoryStream inStream = new MemoryStream(photoBytes))
{ {
using (var imageFactory = new ImageFactory()) using (ImageFactory imageFactory = new ImageFactory())
{ {
imageFactory.Load(inStream); imageFactory.Load(inStream);
Assert.AreEqual(null, imageFactory.ImagePath); Assert.AreEqual(null, imageFactory.ImagePath);
@ -66,12 +73,12 @@ namespace ImageProcessor.UnitTests
[Test] [Test]
public void TestSaveToDisk() public void TestSaveToDisk()
{ {
foreach (var fileName in ListInputFiles()) foreach (FileInfo file in this.ListInputFiles())
{ {
var outputFileName = string.Format("./output/{0}", Path.GetFileName(fileName)); string outputFileName = string.Format("./output/{0}", file.Name);
using (var imageFactory = new ImageFactory()) using (ImageFactory imageFactory = new ImageFactory())
{ {
imageFactory.Load(fileName); imageFactory.Load(file.FullName);
imageFactory.Save(outputFileName); imageFactory.Save(outputFileName);
Assert.AreEqual(true, File.Exists(outputFileName)); Assert.AreEqual(true, File.Exists(outputFileName));
} }
@ -84,12 +91,12 @@ namespace ImageProcessor.UnitTests
[Test] [Test]
public void TestSaveToMemory() public void TestSaveToMemory()
{ {
foreach (var fileName in ListInputFiles()) foreach (FileInfo file in this.ListInputFiles())
{ {
using (var imageFactory = new ImageFactory()) using (ImageFactory imageFactory = new ImageFactory())
{ {
imageFactory.Load(fileName); imageFactory.Load(file.FullName);
using (var s = new MemoryStream()) using (MemoryStream s = new MemoryStream())
{ {
imageFactory.Save(s); imageFactory.Save(s);
s.Seek(0, SeekOrigin.Begin); s.Seek(0, SeekOrigin.Begin);
@ -105,12 +112,12 @@ namespace ImageProcessor.UnitTests
[Test] [Test]
public void TestApplyEffectAlpha() public void TestApplyEffectAlpha()
{ {
foreach (var fileName in ListInputFiles()) foreach (FileInfo file in this.ListInputFiles())
{ {
using (var imageFactory = new ImageFactory()) using (ImageFactory imageFactory = new ImageFactory())
{ {
imageFactory.Load(fileName); imageFactory.Load(file.FullName);
var original = imageFactory.Image.Clone(); Image original = (Image)imageFactory.Image.Clone();
imageFactory.Alpha(50); imageFactory.Alpha(50);
Assert.AreNotEqual(original, imageFactory.Image); Assert.AreNotEqual(original, imageFactory.Image);
} }
@ -123,12 +130,12 @@ namespace ImageProcessor.UnitTests
[Test] [Test]
public void TestApplyEffectBrightness() public void TestApplyEffectBrightness()
{ {
foreach (var fileName in ListInputFiles()) foreach (FileInfo file in this.ListInputFiles())
{ {
using (var imageFactory = new ImageFactory()) using (ImageFactory imageFactory = new ImageFactory())
{ {
imageFactory.Load(fileName); imageFactory.Load(file.FullName);
var original = imageFactory.Image.Clone(); Image original = (Image)imageFactory.Image.Clone();
imageFactory.Brightness(50); imageFactory.Brightness(50);
Assert.AreNotEqual(original, imageFactory.Image); Assert.AreNotEqual(original, imageFactory.Image);
} }
@ -141,12 +148,12 @@ namespace ImageProcessor.UnitTests
[Test] [Test]
public void TestApplyEffectContrast() public void TestApplyEffectContrast()
{ {
foreach (var fileName in ListInputFiles()) foreach (FileInfo file in this.ListInputFiles())
{ {
using (var imageFactory = new ImageFactory()) using (ImageFactory imageFactory = new ImageFactory())
{ {
imageFactory.Load(fileName); imageFactory.Load(file.FullName);
var original = imageFactory.Image.Clone(); Image original = (Image)imageFactory.Image.Clone();
imageFactory.Contrast(50); imageFactory.Contrast(50);
Assert.AreNotEqual(original, imageFactory.Image); Assert.AreNotEqual(original, imageFactory.Image);
} }
@ -159,12 +166,12 @@ namespace ImageProcessor.UnitTests
[Test] [Test]
public void TestApplyEffectSaturation() public void TestApplyEffectSaturation()
{ {
foreach (var fileName in ListInputFiles()) foreach (FileInfo file in this.ListInputFiles())
{ {
using (var imageFactory = new ImageFactory()) using (ImageFactory imageFactory = new ImageFactory())
{ {
imageFactory.Load(fileName); imageFactory.Load(file.FullName);
var original = imageFactory.Image.Clone(); Image original = (Image)imageFactory.Image.Clone();
imageFactory.Saturation(50); imageFactory.Saturation(50);
Assert.AreNotEqual(original, imageFactory.Image); Assert.AreNotEqual(original, imageFactory.Image);
} }
@ -177,13 +184,13 @@ namespace ImageProcessor.UnitTests
[Test] [Test]
public void TestApplyEffectTint() public void TestApplyEffectTint()
{ {
foreach (var fileName in ListInputFiles()) foreach (FileInfo file in this.ListInputFiles())
{ {
using (var imageFactory = new ImageFactory()) using (ImageFactory imageFactory = new ImageFactory())
{ {
imageFactory.Load(fileName); imageFactory.Load(file.FullName);
var original = imageFactory.Image.Clone(); Image original = (Image)imageFactory.Image.Clone();
imageFactory.Tint(System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.AliceBlue)); imageFactory.Tint(Color.FromKnownColor(KnownColor.AliceBlue));
Assert.AreNotEqual(original, imageFactory.Image); Assert.AreNotEqual(original, imageFactory.Image);
} }
} }
@ -195,13 +202,13 @@ namespace ImageProcessor.UnitTests
[Test] [Test]
public void TestApplyEffectVignette() public void TestApplyEffectVignette()
{ {
foreach (var fileName in ListInputFiles()) foreach (FileInfo file in this.ListInputFiles())
{ {
using (var imageFactory = new ImageFactory()) using (ImageFactory imageFactory = new ImageFactory())
{ {
imageFactory.Load(fileName); imageFactory.Load(file.FullName);
var original = imageFactory.Image.Clone(); Image original = (Image)imageFactory.Image.Clone();
imageFactory.Vignette(System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.AliceBlue)); imageFactory.Vignette(Color.FromKnownColor(KnownColor.AliceBlue));
Assert.AreNotEqual(original, imageFactory.Image); Assert.AreNotEqual(original, imageFactory.Image);
} }
} }
@ -213,19 +220,19 @@ namespace ImageProcessor.UnitTests
[Test] [Test]
public void TestApplyEffectWatermark() public void TestApplyEffectWatermark()
{ {
foreach (var fileName in ListInputFiles()) foreach (FileInfo file in this.ListInputFiles())
{ {
using (var imageFactory = new ImageFactory()) using (ImageFactory imageFactory = new ImageFactory())
{ {
imageFactory.Load(fileName); imageFactory.Load(file.FullName);
var original = imageFactory.Image.Clone(); Image original = (Image)imageFactory.Image.Clone();
imageFactory.Watermark(new Imaging.TextLayer imageFactory.Watermark(new Imaging.TextLayer
{ {
Font = "Arial", Font = "Arial",
FontSize = 10, FontSize = 10,
Position = new System.Drawing.Point(10, 10), Position = new Point(10, 10),
Text = "Lorem ipsum dolor" Text = "Lorem ipsum dolor"
}); });
Assert.AreNotEqual(original, imageFactory.Image); Assert.AreNotEqual(original, imageFactory.Image);
} }
} }
@ -237,12 +244,12 @@ namespace ImageProcessor.UnitTests
[Test] [Test]
public void TestApplyEffectBlur() public void TestApplyEffectBlur()
{ {
foreach (var fileName in ListInputFiles()) foreach (FileInfo file in this.ListInputFiles())
{ {
using (var imageFactory = new ImageFactory()) using (ImageFactory imageFactory = new ImageFactory())
{ {
imageFactory.Load(fileName); imageFactory.Load(file.FullName);
var original = imageFactory.Image.Clone(); Image original = (Image)imageFactory.Image.Clone();
imageFactory.GaussianBlur(5); imageFactory.GaussianBlur(5);
Assert.AreNotEqual(original, imageFactory.Image); Assert.AreNotEqual(original, imageFactory.Image);
} }
@ -255,12 +262,12 @@ namespace ImageProcessor.UnitTests
[Test] [Test]
public void TestApplyEffectBlurWithLayer() public void TestApplyEffectBlurWithLayer()
{ {
foreach (var fileName in ListInputFiles()) foreach (FileInfo file in this.ListInputFiles())
{ {
using (var imageFactory = new ImageFactory()) using (ImageFactory imageFactory = new ImageFactory())
{ {
imageFactory.Load(fileName); imageFactory.Load(file.FullName);
var original = imageFactory.Image.Clone(); Image original = (Image)imageFactory.Image.Clone();
imageFactory.GaussianBlur(new Imaging.GaussianLayer { Sigma = 10, Size = 5, Threshold = 2 }); imageFactory.GaussianBlur(new Imaging.GaussianLayer { Sigma = 10, Size = 5, Threshold = 2 });
Assert.AreNotEqual(original, imageFactory.Image); Assert.AreNotEqual(original, imageFactory.Image);
} }
@ -273,12 +280,12 @@ namespace ImageProcessor.UnitTests
[Test] [Test]
public void TestApplyEffectSharpen() public void TestApplyEffectSharpen()
{ {
foreach (var fileName in ListInputFiles()) foreach (FileInfo file in this.ListInputFiles())
{ {
using (var imageFactory = new ImageFactory()) using (ImageFactory imageFactory = new ImageFactory())
{ {
imageFactory.Load(fileName); imageFactory.Load(file.FullName);
var original = imageFactory.Image.Clone(); Image original = (Image)imageFactory.Image.Clone();
imageFactory.GaussianSharpen(5); imageFactory.GaussianSharpen(5);
Assert.AreNotEqual(original, imageFactory.Image); Assert.AreNotEqual(original, imageFactory.Image);
} }
@ -291,12 +298,12 @@ namespace ImageProcessor.UnitTests
[Test] [Test]
public void TestApplyEffectSharpenWithLayer() public void TestApplyEffectSharpenWithLayer()
{ {
foreach (var fileName in ListInputFiles()) foreach (FileInfo file in this.ListInputFiles())
{ {
using (var imageFactory = new ImageFactory()) using (ImageFactory imageFactory = new ImageFactory())
{ {
imageFactory.Load(fileName); imageFactory.Load(file.FullName);
var original = imageFactory.Image.Clone(); Image original = (Image)imageFactory.Image.Clone();
imageFactory.GaussianSharpen(new Imaging.GaussianLayer { Sigma = 10, Size = 5, Threshold = 2 }); imageFactory.GaussianSharpen(new Imaging.GaussianLayer { Sigma = 10, Size = 5, Threshold = 2 });
Assert.AreNotEqual(original, imageFactory.Image); Assert.AreNotEqual(original, imageFactory.Image);
} }
@ -309,12 +316,12 @@ namespace ImageProcessor.UnitTests
[Test] [Test]
public void TestApplyEffectFilter() public void TestApplyEffectFilter()
{ {
foreach (var fileName in ListInputFiles()) foreach (FileInfo file in this.ListInputFiles())
{ {
using (var imageFactory = new ImageFactory()) using (ImageFactory imageFactory = new ImageFactory())
{ {
imageFactory.Load(fileName); imageFactory.Load(file.FullName);
var original = imageFactory.Image.Clone(); Image original = (Image)imageFactory.Image.Clone();
imageFactory.Filter(Imaging.Filters.MatrixFilters.BlackWhite); imageFactory.Filter(Imaging.Filters.MatrixFilters.BlackWhite);
Assert.AreNotEqual(original, imageFactory.Image); Assert.AreNotEqual(original, imageFactory.Image);
@ -365,12 +372,12 @@ namespace ImageProcessor.UnitTests
[Test] [Test]
public void TestRoundedCorners() public void TestRoundedCorners()
{ {
foreach (var fileName in ListInputFiles()) foreach (FileInfo file in this.ListInputFiles())
{ {
using (var imageFactory = new ImageFactory()) using (ImageFactory imageFactory = new ImageFactory())
{ {
imageFactory.Load(fileName); imageFactory.Load(file.FullName);
var original = imageFactory.Image.Clone(); Image original = (Image)imageFactory.Image.Clone();
imageFactory.RoundedCorners(new Imaging.RoundedCornerLayer(5, true, true, true, true)); imageFactory.RoundedCorners(new Imaging.RoundedCornerLayer(5, true, true, true, true));
Assert.AreNotEqual(original, imageFactory.Image); Assert.AreNotEqual(original, imageFactory.Image);
} }
@ -384,12 +391,12 @@ namespace ImageProcessor.UnitTests
public void TestResizeConstraints() public void TestResizeConstraints()
{ {
const int MaxSize = 200; const int MaxSize = 200;
foreach (var fileName in ListInputFiles()) foreach (FileInfo file in this.ListInputFiles())
{ {
using (var imageFactory = new ImageFactory()) using (ImageFactory imageFactory = new ImageFactory())
{ {
imageFactory.Load(fileName); imageFactory.Load(file.FullName);
imageFactory.Constrain(new System.Drawing.Size(MaxSize, MaxSize)); imageFactory.Constrain(new Size(MaxSize, MaxSize));
Assert.LessOrEqual(imageFactory.Image.Width, MaxSize); Assert.LessOrEqual(imageFactory.Image.Width, MaxSize);
Assert.LessOrEqual(imageFactory.Image.Height, MaxSize); Assert.LessOrEqual(imageFactory.Image.Height, MaxSize);
} }
@ -403,13 +410,13 @@ namespace ImageProcessor.UnitTests
public void TestCrop() public void TestCrop()
{ {
const int MaxSize = 20; const int MaxSize = 20;
foreach (var fileName in ListInputFiles()) foreach (FileInfo file in this.ListInputFiles())
{ {
using (var imageFactory = new ImageFactory()) using (ImageFactory imageFactory = new ImageFactory())
{ {
imageFactory.Load(fileName); imageFactory.Load(file.FullName);
var original = imageFactory.Image.Clone(); Image original = (Image)imageFactory.Image.Clone();
imageFactory.Crop(new System.Drawing.Rectangle(0, 0, MaxSize, MaxSize)); imageFactory.Crop(new Rectangle(0, 0, MaxSize, MaxSize));
Assert.AreNotEqual(original, imageFactory.Image); Assert.AreNotEqual(original, imageFactory.Image);
Assert.AreEqual(MaxSize, imageFactory.Image.Width); Assert.AreEqual(MaxSize, imageFactory.Image.Width);
Assert.LessOrEqual(MaxSize, imageFactory.Image.Height); Assert.LessOrEqual(MaxSize, imageFactory.Image.Height);
@ -424,12 +431,12 @@ namespace ImageProcessor.UnitTests
public void TestCropWithCropLayer() public void TestCropWithCropLayer()
{ {
const int MaxSize = 20; const int MaxSize = 20;
foreach (var fileName in ListInputFiles()) foreach (FileInfo file in this.ListInputFiles())
{ {
using (var imageFactory = new ImageFactory()) using (ImageFactory imageFactory = new ImageFactory())
{ {
imageFactory.Load(fileName); imageFactory.Load(file.FullName);
var original = imageFactory.Image.Clone(); Image original = (Image)imageFactory.Image.Clone();
imageFactory.Crop(new Imaging.CropLayer(0, 0, MaxSize, MaxSize, Imaging.CropMode.Pixels)); imageFactory.Crop(new Imaging.CropLayer(0, 0, MaxSize, MaxSize, Imaging.CropMode.Pixels));
Assert.AreNotEqual(original, imageFactory.Image); Assert.AreNotEqual(original, imageFactory.Image);
Assert.AreEqual(MaxSize, imageFactory.Image.Width); Assert.AreEqual(MaxSize, imageFactory.Image.Width);
@ -444,12 +451,12 @@ namespace ImageProcessor.UnitTests
[Test] [Test]
public void TestFlip() public void TestFlip()
{ {
foreach (var fileName in ListInputFiles()) foreach (FileInfo file in this.ListInputFiles())
{ {
using (var imageFactory = new ImageFactory()) using (ImageFactory imageFactory = new ImageFactory())
{ {
imageFactory.Load(fileName); imageFactory.Load(file.FullName);
var original = (System.Drawing.Image)imageFactory.Image.Clone(); Image original = (Image)imageFactory.Image.Clone();
imageFactory.Flip(true); imageFactory.Flip(true);
Assert.AreNotEqual(original, imageFactory.Image); Assert.AreNotEqual(original, imageFactory.Image);
Assert.AreEqual(original.Width, imageFactory.Image.Width); Assert.AreEqual(original.Width, imageFactory.Image.Width);
@ -471,12 +478,12 @@ namespace ImageProcessor.UnitTests
public void TestResize() public void TestResize()
{ {
const int NewSize = 150; const int NewSize = 150;
foreach (var fileName in ListInputFiles()) foreach (FileInfo file in this.ListInputFiles())
{ {
using (var imageFactory = new ImageFactory()) using (ImageFactory imageFactory = new ImageFactory())
{ {
imageFactory.Load(fileName); imageFactory.Load(file.FullName);
imageFactory.Resize(new System.Drawing.Size(NewSize, NewSize)); imageFactory.Resize(new Size(NewSize, NewSize));
Assert.AreEqual(NewSize, imageFactory.Image.Width); Assert.AreEqual(NewSize, imageFactory.Image.Width);
Assert.AreEqual(NewSize, imageFactory.Image.Height); Assert.AreEqual(NewSize, imageFactory.Image.Height);
} }
@ -490,12 +497,12 @@ namespace ImageProcessor.UnitTests
public void TestResizeWithLayer() public void TestResizeWithLayer()
{ {
const int NewSize = 150; const int NewSize = 150;
foreach (var fileName in ListInputFiles()) foreach (FileInfo file in this.ListInputFiles())
{ {
using (var imageFactory = new ImageFactory()) using (ImageFactory imageFactory = new ImageFactory())
{ {
imageFactory.Load(fileName); imageFactory.Load(file.FullName);
imageFactory.Resize(new Imaging.ResizeLayer(new System.Drawing.Size(NewSize, NewSize), Imaging.ResizeMode.Stretch, Imaging.AnchorPosition.Left)); imageFactory.Resize(new Imaging.ResizeLayer(new Size(NewSize, NewSize), Imaging.ResizeMode.Stretch, Imaging.AnchorPosition.Left));
Assert.AreEqual(NewSize, imageFactory.Image.Width); Assert.AreEqual(NewSize, imageFactory.Image.Width);
Assert.AreEqual(NewSize, imageFactory.Image.Height); Assert.AreEqual(NewSize, imageFactory.Image.Height);
} }
@ -508,12 +515,12 @@ namespace ImageProcessor.UnitTests
[Test] [Test]
public void TestRotate() public void TestRotate()
{ {
foreach (var fileName in ListInputFiles()) foreach (FileInfo file in this.ListInputFiles())
{ {
using (var imageFactory = new ImageFactory()) using (ImageFactory imageFactory = new ImageFactory())
{ {
imageFactory.Load(fileName); imageFactory.Load(file.FullName);
var original = (System.Drawing.Image)imageFactory.Image.Clone(); Image original = (Image)imageFactory.Image.Clone();
imageFactory.Rotate(90); imageFactory.Rotate(90);
Assert.AreEqual(original.Height, imageFactory.Image.Width); Assert.AreEqual(original.Height, imageFactory.Image.Width);
Assert.AreEqual(original.Width, imageFactory.Image.Height); Assert.AreEqual(original.Width, imageFactory.Image.Height);
@ -521,13 +528,40 @@ namespace ImageProcessor.UnitTests
} }
} }
/// <summary>
/// Gets the files matching the given extensions.
/// </summary>
/// <param name="dir">The <see cref="System.IO.DirectoryInfo"/>.</param>
/// <param name="extensions">The extensions.</param>
/// <returns>A collection of <see cref="System.IO.FileInfo"/></returns>
/// <exception cref="System.ArgumentNullException">The extensions variable is null.</exception>
private static IEnumerable<FileInfo> GetFilesByExtensions(DirectoryInfo dir, params string[] extensions)
{
if (extensions == null)
{
throw new ArgumentNullException("extensions");
}
IEnumerable<FileInfo> files = dir.EnumerateFiles();
return files.Where(f => extensions.Contains(f.Extension, StringComparer.OrdinalIgnoreCase));
}
/// <summary> /// <summary>
/// Lists the input files in the Images folder /// Lists the input files in the Images folder
/// </summary> /// </summary>
/// <returns>The list of files.</returns> /// <returns>The list of files.</returns>
private static IEnumerable<string> ListInputFiles() private IEnumerable<FileInfo> ListInputFiles()
{ {
return Directory.GetFiles("./Images"); if (this.images != null)
{
return this.images;
}
DirectoryInfo directoryInfo = new DirectoryInfo("./Images");
this.images = GetFilesByExtensions(directoryInfo, new[] { ".jpg", ".jpeg", ".png", ".gif", ".tiff", ".bmp", ".webp" });
return this.images;
} }
} }
} }

6
src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj

@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{03CA9055-F997-428C-BF28-F50F991777C6}</ProjectGuid> <ProjectGuid>{633B1C4C-4823-47BE-9A01-A665F3118C8C}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<RootNamespace>ImageProcessor.UnitTests</RootNamespace> <RootNamespace>ImageProcessor.UnitTests</RootNamespace>
<AssemblyName>ImageProcessor.UnitTests</AssemblyName> <AssemblyName>ImageProcessor.UnitTests</AssemblyName>
@ -338,7 +338,5 @@
</PropertyGroup> </PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" /> <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target> </Target>
<ItemGroup> <ItemGroup />
<Folder Include="Images\" />
</ItemGroup>
</Project> </Project>

4
src/ImageProcessor/ImageFactory.cs

@ -183,7 +183,7 @@ namespace ImageProcessor
this.ImagePath = imagePath; this.ImagePath = imagePath;
// Open a file stream to prevent the need for lock. // Open a file stream to prevent the need for lock.
using (var fileStream = new FileStream(imagePath, FileMode.Open, FileAccess.Read)) using (FileStream fileStream = new FileStream(imagePath, FileMode.Open, FileAccess.Read))
{ {
ISupportedImageFormat format = FormatUtilities.GetFormat(fileStream); ISupportedImageFormat format = FormatUtilities.GetFormat(fileStream);
@ -192,7 +192,7 @@ namespace ImageProcessor
throw new ImageFormatException("Input stream is not a supported format."); throw new ImageFormatException("Input stream is not a supported format.");
} }
var memoryStream = new MemoryStream(); MemoryStream memoryStream = new MemoryStream();
// Copy the stream. // Copy the stream.
fileStream.CopyTo(memoryStream); fileStream.CopyTo(memoryStream);

2
src/ImageProcessor/Imaging/Formats/FormatUtilities.cs

@ -142,7 +142,7 @@ namespace ImageProcessor.Imaging.Formats
// GDI returns a single array with all delays, while Mono returns a different array for each frame // GDI returns a single array with all delays, while Mono returns a different array for each frame
image.SelectActiveFrame(frameDimension, i); image.SelectActiveFrame(frameDimension, i);
var times = image.GetPropertyItem(20736).Value; var times = image.GetPropertyItem(20736).Value;
int thisDelay = BitConverter.ToInt32(times, 4*i % times.Length); int thisDelay = BitConverter.ToInt32(times, (4 * i) % times.Length);
int toAddDelay = thisDelay * 10 < 20 ? 20 : thisDelay * 10; // Minimum delay is 20 ms int toAddDelay = thisDelay * 10 < 20 ? 20 : thisDelay * 10; // Minimum delay is 20 ms
// Find the frame // Find the frame

Loading…
Cancel
Save