mirror of https://github.com/SixLabors/ImageSharp
Browse Source
Also add overloads to Gaussian blur and sharpen. Former-commit-id: 22acbbb813129bc07f7c433baaeee4f677eca785 Former-commit-id: a7c535f850892fb3c473180b088010d0a49c289f Former-commit-id: 253f560eb43283d9794c4fab342eb09f664375b8af/merge-core
7 changed files with 147 additions and 5 deletions
@ -0,0 +1,44 @@ |
|||||
|
// <copyright file="Crop.cs" company="James South">
|
||||
|
// Copyright (c) James South and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
// </copyright>
|
||||
|
|
||||
|
namespace ImageProcessor.Samplers |
||||
|
{ |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Provides methods to allow the cropping of an image.
|
||||
|
/// </summary>
|
||||
|
public class Crop : ParallelImageProcessor |
||||
|
{ |
||||
|
/// <inheritdoc/>
|
||||
|
protected override void Apply( |
||||
|
ImageBase target, |
||||
|
ImageBase source, |
||||
|
Rectangle targetRectangle, |
||||
|
Rectangle sourceRectangle, |
||||
|
int startY, |
||||
|
int endY) |
||||
|
{ |
||||
|
int targetY = targetRectangle.Y; |
||||
|
int targetBottom = targetRectangle.Bottom; |
||||
|
int startX = targetRectangle.X; |
||||
|
int endX = targetRectangle.Right; |
||||
|
|
||||
|
Parallel.For( |
||||
|
startY, |
||||
|
endY, |
||||
|
y => |
||||
|
{ |
||||
|
if (y >= targetY && y < targetBottom) |
||||
|
{ |
||||
|
for (int x = startX; x < endX; x++) |
||||
|
{ |
||||
|
target[x, y] = source[x, y]; |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue