Browse Source

Fix method overloads.

Former-commit-id: 90e4c4eaa2f81993d07def639b343c8cc664451a
Former-commit-id: 6038e00d8249dea8648385af59a1d3656b269300
Former-commit-id: 02e5a346ce23367c58c9b34f707a418246b9d1e7
pull/17/head
James Jackson-South 11 years ago
parent
commit
2a49aadbce
  1. 29
      src/ImageProcessor/Samplers/ImageSampleExtensions.cs

29
src/ImageProcessor/Samplers/ImageSampleExtensions.cs

@ -32,12 +32,12 @@ namespace ImageProcessor.Samplers
/// <returns>The <see cref="Image"/></returns> /// <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 Resize(source, width, height, sampler, source.Bounds, new Rectangle(0, 0, width, height)); return Resize(source, width, height, sampler, source.Bounds);
} }
/// <summary> /// <summary>
/// Resizes an image to the given width and height with the given sampler, /// Resizes an image to the given width and height with the given sampler and
/// source rectangle, and target rectangle. /// source rectangle.
/// </summary> /// </summary>
/// <param name="source">The image to resize.</param> /// <param name="source">The image to resize.</param>
/// <param name="width">The target image width.</param> /// <param name="width">The target image width.</param>
@ -46,14 +46,10 @@ namespace ImageProcessor.Samplers
/// <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>
/// <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> /// <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)
{ {
return source.Process(width, height, sourceRectangle, targetRectangle, new Resize(sampler)); return source.Process(width, height, sourceRectangle, new Rectangle(0, 0, width, height), new Resize(sampler));
} }
/// <summary> /// <summary>
@ -65,12 +61,11 @@ namespace ImageProcessor.Samplers
/// <returns>The <see cref="Image"/></returns> /// <returns>The <see cref="Image"/></returns>
public static Image Crop(this Image source, int width, int height) public static Image Crop(this Image source, int width, int height)
{ {
return Crop(source, width, height, source.Bounds, new Rectangle(0, 0, width, height)); return Crop(source, width, height, source.Bounds);
} }
/// <summary> /// <summary>
/// Crops an image to the given width and height with the given source rectangle, /// Crops an image to the given width and height with the given source rectangle.
/// and target rectangle.
/// <remarks> /// <remarks>
/// If the source rectangle is smaller than the target dimensions then the /// If the source rectangle is smaller than the target dimensions then the
/// area within the source is resized performing a zoomed crop. /// area within the source is resized performing a zoomed crop.
@ -82,21 +77,17 @@ namespace ImageProcessor.Samplers
/// <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>
/// <param name="targetRectangle">
/// The <see cref="Rectangle"/> structure that specifies the location and size of the drawn image.
/// The image is cropped to fit the rectangle.
/// </param>
/// <returns>The <see cref="Image"/></returns> /// <returns>The <see cref="Image"/></returns>
public static Image Crop(this Image source, int width, int height, Rectangle sourceRectangle, Rectangle targetRectangle) public static Image Crop(this Image source, int width, int height, Rectangle sourceRectangle)
{ {
if (sourceRectangle.Width < targetRectangle.Width || sourceRectangle.Height < targetRectangle.Height) if (sourceRectangle.Width < width || sourceRectangle.Height < height)
{ {
// If the source rectangle is smaller than the target perform a // If the source rectangle is smaller than the target perform a
// cropped zoom. // cropped zoom.
source = source.Resize(sourceRectangle.Width, sourceRectangle.Height); source = source.Resize(sourceRectangle.Width, sourceRectangle.Height);
} }
return source.Process(width, height, sourceRectangle, targetRectangle, new Crop()); return source.Process(width, height, sourceRectangle, new Rectangle(0, 0, width, height), new Crop());
} }
} }
} }

Loading…
Cancel
Save