mirror of https://github.com/SixLabors/ImageSharp
Browse Source
Former-commit-id: 13504b6bd87f681d061848d19c5f3cb607e96dc6 Former-commit-id: eff308eb2d06484cbe38ef3a808f29584233ac6e Former-commit-id: fc96b270e55c0ed1d7dd47e2769402c348bf298eaf/merge-core
110 changed files with 178 additions and 140 deletions
@ -0,0 +1,36 @@ |
|||
// <copyright file="Invert.cs" company="James South">
|
|||
// Copyright (c) James South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageProcessor.Filters |
|||
{ |
|||
/// <summary>
|
|||
/// An <see cref="IImageProcessor"/> to invert the colors of an <see cref="Image"/>.
|
|||
/// </summary>
|
|||
public class Invert : ParallelImageProcessor |
|||
{ |
|||
/// <inheritdoc/>
|
|||
protected override void Apply(ImageBase target, ImageBase source, Rectangle targetRectangle, Rectangle sourceRectangle, int startY, int endY) |
|||
{ |
|||
int sourceY = sourceRectangle.Y; |
|||
int sourceBottom = sourceRectangle.Bottom; |
|||
int startX = sourceRectangle.X; |
|||
int endX = sourceRectangle.Right; |
|||
|
|||
for (int y = startY; y < endY; y++) |
|||
{ |
|||
if (y >= sourceY && y < sourceBottom) |
|||
{ |
|||
for (int x = startX; x < endX; x++) |
|||
{ |
|||
// TODO: This doesn't work for gamma test images.
|
|||
Bgra color = source[x, y]; |
|||
Bgra targetColor = new Bgra((255 - color.B).ToByte(), (255 - color.G).ToByte(), (255 - color.R).ToByte(), color.A); |
|||
target[x, y] = targetColor; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue