mirror of https://github.com/SixLabors/ImageSharp
Browse Source
Also add overloads to Gaussian blur and sharpen. Former-commit-id: ff18410aefbdb605d7177dfcc0e98dadf9d85e47 Former-commit-id: 71993046259e4fbc6734345cab961c2741ccb9d6 Former-commit-id: 5a3f8b071b8e4948544db58aa1280c0df451efe2pull/17/head
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