//
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
//
namespace ImageProcessorCore
{
using Processors;
///
/// Extension methods for the type.
///
public static partial class ImageExtensions
{
///
/// Rotates an image by the given angle in degrees, expanding the image to fit the rotated result.
///
/// The image to rotate.
/// The angle in degrees to perform the rotation.
/// A delegate which is called as progress is made processing the image.
/// The
public static Image Rotate(this Image source, float degrees, ProgressEventHandler progressHandler = null)
{
return Rotate(source, degrees, true, progressHandler);
}
///
/// Rotates an image by the given angle in degrees.
///
/// The image to rotate.
/// The angle in degrees to perform the rotation.
/// Whether to expand the image to fit the rotated result.
/// A delegate which is called as progress is made processing the image.
/// The
public static Image Rotate(this Image source, float degrees, bool expand, ProgressEventHandler progressHandler = null)
{
RotateProcessor processor = new RotateProcessor { Angle = degrees, Expand = expand };
processor.OnProgress += progressHandler;
try
{
return source.Process(source.Width, source.Height, source.Bounds, source.Bounds, processor);
}
finally
{
processor.OnProgress -= progressHandler;
}
}
}
}