mirror of https://github.com/SixLabors/ImageSharp
committed by
ip
3 changed files with 104 additions and 0 deletions
@ -0,0 +1,35 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
using SixLabors.ImageSharp.Processing.Processors.Filters; |
|||
using SixLabors.Primitives; |
|||
|
|||
namespace SixLabors.ImageSharp.Processing |
|||
{ |
|||
/// <summary>
|
|||
/// Defines extensions that allow the alteration of the hue component of an <see cref="Image"/>
|
|||
/// using Mutate/Clone.
|
|||
/// </summary>
|
|||
public static class LightnessExtension |
|||
{ |
|||
/// <summary>
|
|||
/// Alters the hue component of the image.
|
|||
/// </summary>
|
|||
/// <param name="source">The image this method extends.</param>
|
|||
/// <param name="lightness">Lightness parameter of image in HSL color scheme.</param>
|
|||
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
|
|||
public static IImageProcessingContext Lightness(this IImageProcessingContext source, float lightness) |
|||
=> source.ApplyProcessor(new LightnessProcessor(lightness)); |
|||
|
|||
/// <summary>
|
|||
/// Alters the hue component of the image.
|
|||
/// </summary>
|
|||
/// <param name="source">The image this method extends.</param>
|
|||
/// <param name="lightness">Lightness parameter of image in HSL color scheme.</param>
|
|||
/// <param name="rectangle">
|
|||
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
|
|||
/// </param>
|
|||
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
|
|||
public static IImageProcessingContext Lightness(this IImageProcessingContext source, float lightness, Rectangle rectangle) |
|||
=> source.ApplyProcessor(new LightnessProcessor(lightness), rectangle); |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
namespace SixLabors.ImageSharp.Processing.Processors.Filters |
|||
{ |
|||
/// <summary>
|
|||
/// Applies a lightness filter matrix using
|
|||
/// </summary>
|
|||
public sealed class LightnessProcessor : FilterProcessor |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="LightnessProcessor"/> class.
|
|||
/// </summary>
|
|||
/// <param name="lightness">Lightness of image in HSL color scheme</param>
|
|||
public LightnessProcessor(float lightness) |
|||
: base(KnownFilterMatrices.CreateLightnessFilter(lightness)) |
|||
{ |
|||
this.Lightness = lightness; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets Lightness of image in HSL color scheme.
|
|||
/// The "brightness relative to the brightness of a similarly illuminated white" https://en.wikipedia.org/wiki/HSL_and_HSV#Lightness
|
|||
/// </summary>
|
|||
public float Lightness { get; } |
|||
} |
|||
} |
|||
Loading…
Reference in new issue