mirror of https://github.com/SixLabors/ImageSharp
Browse Source
Former-commit-id: a998b9d94d6da006ff1381e93e2acb27a14546a8 Former-commit-id: e5c6fd1bbbf94f02f2702a09dfd16fba18662352 Former-commit-id: bf339f877e151c783b9d462b133429e9dc28aeb3af/merge-core
1 changed files with 39 additions and 0 deletions
@ -0,0 +1,39 @@ |
|||||
|
// <copyright file="Pad.cs" company="James Jackson-South">
|
||||
|
// Copyright (c) James Jackson-South and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
// </copyright>-------------------------------------------------------------------------------------------------------------------
|
||||
|
|
||||
|
namespace ImageProcessorCore |
||||
|
{ |
||||
|
using Processors; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Extension methods for the <see cref="Image"/> type.
|
||||
|
/// </summary>
|
||||
|
public static partial class ImageExtensions |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Evenly pads an image to fit the new dimensions.
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="T">The pixel format.</typeparam>
|
||||
|
/// <typeparam name="TP">The packed format. <example>long, float.</example></typeparam>
|
||||
|
/// <param name="source">The source image to pad.</param>
|
||||
|
/// <param name="width">The new width.</param>
|
||||
|
/// <param name="height">The new height.</param>
|
||||
|
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
|
||||
|
/// <returns>The <see cref="Image"/>.</returns>
|
||||
|
public static Image<T, TP> Pad<T, TP>(this Image<T, TP> source, int width, int height, ProgressEventHandler progressHandler = null) |
||||
|
where T : IPackedVector<TP> |
||||
|
where TP : struct |
||||
|
{ |
||||
|
ResizeOptions options = new ResizeOptions |
||||
|
{ |
||||
|
Size = new Size(width, height), |
||||
|
Mode = ResizeMode.BoxPad, |
||||
|
Sampler = new NearestNeighborResampler() |
||||
|
}; |
||||
|
|
||||
|
return Resize(source, options, progressHandler); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue