//
// 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
{
///
/// Skews an image by the given angles in degrees, expanding the image to fit the skewed result.
///
/// The pixel format.
/// The packed format. uint, long, float.
/// The image to skew.
/// The angle in degrees to perform the rotation along the x-axis.
/// The angle in degrees to perform the rotation along the y-axis.
/// A delegate which is called as progress is made processing the image.
/// The
public static Image Skew(this Image source, float degreesX, float degreesY, ProgressEventHandler progressHandler = null)
where TColor : IPackedVector
where TPacked : struct
{
return Skew(source, degreesX, degreesY, true, progressHandler);
}
///
/// Skews an image by the given angles in degrees.
///
/// The pixel format.
/// The packed format. uint, long, float.
/// The image to skew.
/// The angle in degrees to perform the rotation along the x-axis.
/// The angle in degrees to perform the rotation along the y-axis.
/// Whether to expand the image to fit the skewed result.
/// A delegate which is called as progress is made processing the image.
/// The
public static Image Skew(this Image source, float degreesX, float degreesY, bool expand, ProgressEventHandler progressHandler = null)
where TColor : IPackedVector
where TPacked : struct
{
SkewProcessor processor = new SkewProcessor { AngleX = degreesX, AngleY = degreesY, Expand = expand };
processor.OnProgress += progressHandler;
try
{
return source.Process(source.Width, source.Height, source.Bounds, source.Bounds, processor);
}
finally
{
processor.OnProgress -= progressHandler;
}
}
}
}