Browse Source
Merge pull request #1001 from SixLabors/issue/997
Fix RGB to HSL conversion
pull/1003/head
James Jackson-South
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
4 additions and
3 deletions
-
src/ImageSharp/ColorSpaces/Conversion/Implementation/Converters/HslAndRgbConverter.cs
-
tests/ImageSharp.Tests/Colorspaces/Conversion/RgbAndHslConversionTest.cs
|
|
|
@ -96,7 +96,7 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
s = chroma / (2F - chroma); |
|
|
|
s = chroma / (2F - max - min); |
|
|
|
} |
|
|
|
|
|
|
|
return new Hsl(h, s, l); |
|
|
|
@ -157,4 +157,4 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation |
|
|
|
return value; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -1,4 +1,4 @@ |
|
|
|
// Copyright (c) Six Labors and contributors.
|
|
|
|
// Copyright (c) Six Labors and contributors.
|
|
|
|
// Licensed under the Apache License, Version 2.0.
|
|
|
|
|
|
|
|
using System; |
|
|
|
@ -65,6 +65,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion |
|
|
|
[InlineData(1, 0, 0, 0, 1, .5F)] |
|
|
|
[InlineData(0, 1, 0, 120, 1, .5F)] |
|
|
|
[InlineData(0, 0, 1, 240, 1, .5F)] |
|
|
|
[InlineData(0.7, 0.8, 0.6, 90, 0.3333, 0.7F)] |
|
|
|
public void Convert_Rgb_To_Hsl(float r, float g, float b, float h, float s, float l) |
|
|
|
{ |
|
|
|
// Arrange
|
|
|
|
|