//
// 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 pixel format.
/// The packed format. uint, long, float.
/// The image to rotate.
/// The angle in degrees to perform the rotation.
/// The
public static Image Rotate(this Image source, float degrees)
where TColor : IPackedVector
where TPacked : struct
{
return Rotate(source, degrees, true);
}
///
/// Rotates and flips an image by the given instructions.
///
/// The pixel format.
/// The packed format. uint, long, float.
/// The image to rotate.
/// The to perform the rotation.
/// The
public static Image Rotate(this Image source, RotateType rotateType)
where TColor : IPackedVector
where TPacked : struct
{
return Rotate(source, (float)rotateType, false);
}
///
/// Rotates an image by the given angle in degrees.
///
/// The pixel format.
/// The packed format. uint, long, float.
/// The image to rotate.
/// The angle in degrees to perform the rotation.
/// Whether to expand the image to fit the rotated result.
/// The
public static Image Rotate(this Image source, float degrees, bool expand)
where TColor : IPackedVector
where TPacked : struct
{
RotateProcessor processor = new RotateProcessor { Angle = degrees, Expand = expand };
return source.Process(source.Width, source.Height, source.Bounds, source.Bounds, processor);
}
}
}