Browse Source

Cleanup

Former-commit-id: 11abc62aa78af1d7377948b757e8dac5dab49aaf
Former-commit-id: ad449d9635135872d0b2a15dc6eb29c771665c2f
Former-commit-id: c4672260a9f7f6aa066fe8c73568c00603260be8
af/merge-core
James Jackson-South 11 years ago
parent
commit
2e50785e39
  1. 4
      src/ImageProcessor/ImageExtensions.cs
  2. 34
      src/ImageProcessor/Samplers/ImageSampleExtensions.cs
  3. 9
      tests/ImageProcessor.Tests/Processors/ProcessorTestBase.cs
  4. 2
      tests/ImageProcessor.Tests/Processors/Samplers/SamplerTests.cs
  5. 1
      tests/ImageProcessor.Tests/TestImages/Formats/Jpg/Calliphora.jpg.REMOVED.git-id

4
src/ImageProcessor/ImageExtensions.cs

@ -85,7 +85,7 @@ namespace ImageProcessor
/// </summary> /// </summary>
/// <param name="source">The source image. Cannot be null.</param> /// <param name="source">The source image. Cannot be null.</param>
/// <param name="width">The target image width.</param> /// <param name="width">The target image width.</param>
/// <param name="height">The target image width.</param> /// <param name="height">The target image height.</param>
/// <param name="processors">Any processors to apply to the image.</param> /// <param name="processors">Any processors to apply to the image.</param>
/// <returns>The <see cref="Image"/>.</returns> /// <returns>The <see cref="Image"/>.</returns>
public static Image Process(this Image source, int width, int height, params IImageProcessor[] processors) public static Image Process(this Image source, int width, int height, params IImageProcessor[] processors)
@ -98,7 +98,7 @@ namespace ImageProcessor
/// </summary> /// </summary>
/// <param name="source">The source image. Cannot be null.</param> /// <param name="source">The source image. Cannot be null.</param>
/// <param name="width">The target image width.</param> /// <param name="width">The target image width.</param>
/// <param name="height">The target image width.</param> /// <param name="height">The target image height.</param>
/// <param name="sourceRectangle"> /// <param name="sourceRectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to draw. /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to draw.
/// </param> /// </param>

34
src/ImageProcessor/Samplers/ImageSampleExtensions.cs

@ -1,4 +1,4 @@
// <copyright file="ImageFilterExtensions.cs" company="James South"> // <copyright file="ImageSampleExtensions.cs" company="James South">
// Copyright © James South and contributors. // Copyright © James South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright> // </copyright>
@ -6,20 +6,50 @@
namespace ImageProcessor.Samplers namespace ImageProcessor.Samplers
{ {
/// <summary> /// <summary>
/// Exstensions methods for <see cref="Image"/> to apply samplers to the image. /// Extensions methods for <see cref="Image"/> to apply samplers to the image.
/// </summary> /// </summary>
public static class ImageSampleExtensions public static class ImageSampleExtensions
{ {
/// <summary>
/// Resizes an image to the given width and height.
/// </summary>
/// <param name="source">The image to resize.</param>
/// <param name="width">The target image width.</param>
/// <param name="height">The target image height.</param>
/// <returns>The <see cref="Image"/></returns>
public static Image Resize(this Image source, int width, int height) public static Image Resize(this Image source, int width, int height)
{ {
return source.Process(width, height, default(Rectangle), default(Rectangle), new Resize(new BicubicResampler())); return source.Process(width, height, default(Rectangle), default(Rectangle), new Resize(new BicubicResampler()));
} }
/// <summary>
/// Resizes an image to the given width and height with the given sampler.
/// </summary>
/// <param name="source">The image to resize.</param>
/// <param name="width">The target image width.</param>
/// <param name="height">The target image height.</param>
/// <param name="sampler">The <see cref="IResampler"/> to perform the resampling.</param>
/// <returns>The <see cref="Image"/></returns>
public static Image Resize(this Image source, int width, int height, IResampler sampler) public static Image Resize(this Image source, int width, int height, IResampler sampler)
{ {
return source.Process(width, height, default(Rectangle), default(Rectangle), new Resize(sampler)); return source.Process(width, height, default(Rectangle), default(Rectangle), new Resize(sampler));
} }
/// <summary>
/// Resizes an image to the given width and height with the given sampler.
/// </summary>
/// <param name="source">The image to resize.</param>
/// <param name="width">The target image width.</param>
/// <param name="height">The target image height.</param>
/// <param name="sampler">The <see cref="IResampler"/> to perform the resampling.</param>
/// <param name="sourceRectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to draw.
/// </param>
/// <param name="targetRectangle">
/// The <see cref="Rectangle"/> structure that specifies the location and size of the drawn image.
/// The image is scaled to fit the rectangle.
/// </param>
/// <returns>The <see cref="Image"/></returns>
public static Image Resize(this Image source, int width, int height, IResampler sampler, Rectangle sourceRectangle, Rectangle targetRectangle) public static Image Resize(this Image source, int width, int height, IResampler sampler, Rectangle sourceRectangle, Rectangle targetRectangle)
{ {
return source.Process(width, height, sourceRectangle, targetRectangle, new Resize(sampler)); return source.Process(width, height, sourceRectangle, targetRectangle, new Resize(sampler));

9
tests/ImageProcessor.Tests/Processors/ProcessorTestBase.cs

@ -19,10 +19,11 @@ namespace ImageProcessor.Tests
/// </summary> /// </summary>
public static readonly List<string> Files = new List<string> public static readonly List<string> Files = new List<string>
{ {
"../../TestImages/Formats/Jpg/Backdrop.jpg", //"../../TestImages/Formats/Jpg/Backdrop.jpg",
"../../TestImages/Formats/Bmp/Car.bmp", "../../TestImages/Formats/Jpg/Calliphora.jpg",
"../../TestImages/Formats/Png/cmyk.png", //"../../TestImages/Formats/Bmp/Car.bmp",
"../../TestImages/Formats/Gif/leaf.gif" //"../../TestImages/Formats/Png/cmyk.png",
//"../../TestImages/Formats/Gif/leaf.gif"
// { "../../TestImages/Formats/Gif/ani.gif" }, // { "../../TestImages/Formats/Gif/ani.gif" },
// { "../../TestImages/Formats/Gif/ani2.gif" }, // { "../../TestImages/Formats/Gif/ani2.gif" },

2
tests/ImageProcessor.Tests/Processors/Samplers/SamplerTests.cs

@ -44,7 +44,7 @@ namespace ImageProcessor.Tests
string filename = Path.GetFileNameWithoutExtension(file) + "-" + name + Path.GetExtension(file); string filename = Path.GetFileNameWithoutExtension(file) + "-" + name + Path.GetExtension(file);
using (FileStream output = File.OpenWrite($"Resized/{filename}")) using (FileStream output = File.OpenWrite($"Resized/{filename}"))
{ {
image.Resize(500, 500, sampler).Save(output); image.Resize(200, 298, sampler).Save(output);
} }
Trace.WriteLine($"{name}: {watch.ElapsedMilliseconds}ms"); Trace.WriteLine($"{name}: {watch.ElapsedMilliseconds}ms");

1
tests/ImageProcessor.Tests/TestImages/Formats/Jpg/Calliphora.jpg.REMOVED.git-id

@ -0,0 +1 @@
5d446f64d0636f6ad7e9f82625eeff89ef394fe2
Loading…
Cancel
Save