Skip to content

Commit fd8331f

Browse files
Merge pull request #3008 from SixLabors/js/fix-2999
Fix detection of canonical sRGB profiles
2 parents f758fad + 399a43d commit fd8331f

21 files changed

+652
-50
lines changed

src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsCieLabCieLab.cs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,24 @@
66

77
namespace SixLabors.ImageSharp.ColorProfiles;
88

9-
internal static class ColorProfileConverterExtensionsCieLabCieLab
9+
/// <summary>
10+
/// Allows conversion between two color profiles based on the CIE Lab color space.
11+
/// </summary>
12+
public static class ColorProfileConverterExtensionsCieLabCieLab
1013
{
14+
/// <summary>
15+
/// Converts a color value from one color profile to another using the specified color profile converter.
16+
/// </summary>
17+
/// <remarks>
18+
/// The conversion process may use ICC profiles if available; otherwise, it performs a manual
19+
/// conversion through the profile connection space (PCS) with chromatic adaptation as needed. The method requires
20+
/// both source and target types to be value types implementing the appropriate color profile interface.
21+
/// </remarks>
22+
/// <typeparam name="TFrom">The source color profile type. Must implement <see cref="IColorProfile{TFrom, CieLab}"/>.</typeparam>
23+
/// <typeparam name="TTo">The target color profile type. Must implement <see cref="IColorProfile{TTo, CieLab}"/>.</typeparam>
24+
/// <param name="converter">The color profile converter to use for the conversion.</param>
25+
/// <param name="source">The source color value to convert.</param>
26+
/// <returns>A value of type <typeparamref name="TTo"/> representing the converted color in the target color profile.</returns>
1127
public static TTo Convert<TFrom, TTo>(this ColorProfileConverter converter, in TFrom source)
1228
where TFrom : struct, IColorProfile<TFrom, CieLab>
1329
where TTo : struct, IColorProfile<TTo, CieLab>
@@ -34,6 +50,20 @@ public static TTo Convert<TFrom, TTo>(this ColorProfileConverter converter, in T
3450
return TTo.FromProfileConnectingSpace(options, in pcsTo);
3551
}
3652

53+
/// <summary>
54+
/// Converts a span of color values from one color profile to another using the specified color profile converter.
55+
/// </summary>
56+
/// <remarks>
57+
/// This method performs color conversion between two color profiles, handling necessary
58+
/// transformations such as profile connection space conversion and chromatic adaptation. If ICC profiles are
59+
/// available and applicable, the conversion uses them for improved accuracy. The method does not allocate memory
60+
/// for the destination; the caller is responsible for providing a suitably sized span.
61+
/// </remarks>
62+
/// <typeparam name="TFrom">The type representing the source color profile. Must implement <see cref="IColorProfile{TFrom, CieLab}"/>.</typeparam>
63+
/// <typeparam name="TTo">The type representing the destination color profile. Must implement <see cref="IColorProfile{TTo, CieLab}"/>.</typeparam>
64+
/// <param name="converter">The color profile converter to use for the conversion operation.</param>
65+
/// <param name="source">A read-only span containing the source color values to convert.</param>
66+
/// <param name="destination">A span that receives the converted color values. Must be at least as long as the source span.</param>
3767
public static void Convert<TFrom, TTo>(this ColorProfileConverter converter, ReadOnlySpan<TFrom> source, Span<TTo> destination)
3868
where TFrom : struct, IColorProfile<TFrom, CieLab>
3969
where TTo : struct, IColorProfile<TTo, CieLab>

src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsCieLabCieXyz.cs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,24 @@
66

77
namespace SixLabors.ImageSharp.ColorProfiles;
88

9-
internal static class ColorProfileConverterExtensionsCieLabCieXyz
9+
/// <summary>
10+
/// Allows conversion between two color profiles based on the CIE Lab and CIE XYZ color spaces.
11+
/// </summary>
12+
public static class ColorProfileConverterExtensionsCieLabCieXyz
1013
{
14+
/// <summary>
15+
/// Converts a color value from one color profile to another using the specified color profile converter.
16+
/// </summary>
17+
/// <remarks>
18+
/// The conversion process may use ICC profiles if available; otherwise, it performs a manual
19+
/// conversion through the profile connection space (PCS) with chromatic adaptation as needed. The method requires
20+
/// both source and target types to be value types implementing the appropriate color profile interface.
21+
/// </remarks>
22+
/// <typeparam name="TFrom">The source color profile type. Must implement <see cref="IColorProfile{TFrom, CieLab}"/>.</typeparam>
23+
/// <typeparam name="TTo">The target color profile type. Must implement <see cref="IColorProfile{TTo, CieXyz}"/>.</typeparam>
24+
/// <param name="converter">The color profile converter to use for the conversion.</param>
25+
/// <param name="source">The source color value to convert.</param>
26+
/// <returns>A value of type <typeparamref name="TTo"/> representing the converted color in the target color profile.</returns>
1127
public static TTo Convert<TFrom, TTo>(this ColorProfileConverter converter, in TFrom source)
1228
where TFrom : struct, IColorProfile<TFrom, CieLab>
1329
where TTo : struct, IColorProfile<TTo, CieXyz>
@@ -33,6 +49,20 @@ public static TTo Convert<TFrom, TTo>(this ColorProfileConverter converter, in T
3349
return TTo.FromProfileConnectingSpace(options, in pcsTo);
3450
}
3551

52+
/// <summary>
53+
/// Converts a span of color values from one color profile to another using the specified color profile converter.
54+
/// </summary>
55+
/// <remarks>
56+
/// This method performs color conversion between two color profiles, handling necessary
57+
/// transformations such as profile connection space conversion and chromatic adaptation. If ICC profiles are
58+
/// available and applicable, the conversion uses them for improved accuracy. The method does not allocate memory
59+
/// for the destination; the caller is responsible for providing a suitably sized span.
60+
/// </remarks>
61+
/// <typeparam name="TFrom">The type representing the source color profile. Must implement <see cref="IColorProfile{TFrom, CieLab}"/>.</typeparam>
62+
/// <typeparam name="TTo">The type representing the destination color profile. Must implement <see cref="IColorProfile{TTo, CieXyz}"/>.</typeparam>
63+
/// <param name="converter">The color profile converter to use for the conversion operation.</param>
64+
/// <param name="source">A read-only span containing the source color values to convert.</param>
65+
/// <param name="destination">A span that receives the converted color values. Must be at least as long as the source span.</param>
3666
public static void Convert<TFrom, TTo>(this ColorProfileConverter converter, ReadOnlySpan<TFrom> source, Span<TTo> destination)
3767
where TFrom : struct, IColorProfile<TFrom, CieLab>
3868
where TTo : struct, IColorProfile<TTo, CieXyz>

src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsCieLabRgb.cs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,24 @@
66

77
namespace SixLabors.ImageSharp.ColorProfiles;
88

9-
internal static class ColorProfileConverterExtensionsCieLabRgb
9+
/// <summary>
10+
/// Allows conversion between two color profiles based on the CIE Lab and RGB color spaces.
11+
/// </summary>
12+
public static class ColorProfileConverterExtensionsCieLabRgb
1013
{
14+
/// <summary>
15+
/// Converts a color value from one color profile to another using the specified color profile converter.
16+
/// </summary>
17+
/// <remarks>
18+
/// The conversion process may use ICC profiles if available; otherwise, it performs a manual
19+
/// conversion through the profile connection space (PCS) with chromatic adaptation as needed. The method requires
20+
/// both source and target types to be value types implementing the appropriate color profile interface.
21+
/// </remarks>
22+
/// <typeparam name="TFrom">The source color profile type. Must implement <see cref="IColorProfile{TFrom, CieLab}"/>.</typeparam>
23+
/// <typeparam name="TTo">The target color profile type. Must implement <see cref="IColorProfile{TTo, Rgb}"/>.</typeparam>
24+
/// <param name="converter">The color profile converter to use for the conversion.</param>
25+
/// <param name="source">The source color value to convert.</param>
26+
/// <returns>A value of type <typeparamref name="TTo"/> representing the converted color in the target color profile.</returns>
1127
public static TTo Convert<TFrom, TTo>(this ColorProfileConverter converter, in TFrom source)
1228
where TFrom : struct, IColorProfile<TFrom, CieLab>
1329
where TTo : struct, IColorProfile<TTo, Rgb>
@@ -34,6 +50,20 @@ public static TTo Convert<TFrom, TTo>(this ColorProfileConverter converter, in T
3450
return TTo.FromProfileConnectingSpace(options, in pcsTo);
3551
}
3652

53+
/// <summary>
54+
/// Converts a span of color values from one color profile to another using the specified color profile converter.
55+
/// </summary>
56+
/// <remarks>
57+
/// This method performs color conversion between two color profiles, handling necessary
58+
/// transformations such as profile connection space conversion and chromatic adaptation. If ICC profiles are
59+
/// available and applicable, the conversion uses them for improved accuracy. The method does not allocate memory
60+
/// for the destination; the caller is responsible for providing a suitably sized span.
61+
/// </remarks>
62+
/// <typeparam name="TFrom">The type representing the source color profile. Must implement <see cref="IColorProfile{TFrom, CieLab}"/>.</typeparam>
63+
/// <typeparam name="TTo">The type representing the destination color profile. Must implement <see cref="IColorProfile{TTo, Rgb}"/>.</typeparam>
64+
/// <param name="converter">The color profile converter to use for the conversion operation.</param>
65+
/// <param name="source">A read-only span containing the source color values to convert.</param>
66+
/// <param name="destination">A span that receives the converted color values. Must be at least as long as the source span.</param>
3767
public static void Convert<TFrom, TTo>(this ColorProfileConverter converter, ReadOnlySpan<TFrom> source, Span<TTo> destination)
3868
where TFrom : struct, IColorProfile<TFrom, CieLab>
3969
where TTo : struct, IColorProfile<TTo, Rgb>

src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsCieXyzCieLab.cs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,24 @@
66

77
namespace SixLabors.ImageSharp.ColorProfiles;
88

9-
internal static class ColorProfileConverterExtensionsCieXyzCieLab
9+
/// <summary>
10+
/// Allows conversion between two color profiles based on the CIE XYZ and CIE Lab color spaces.
11+
/// </summary>
12+
public static class ColorProfileConverterExtensionsCieXyzCieLab
1013
{
14+
/// <summary>
15+
/// Converts a color value from one color profile to another using the specified color profile converter.
16+
/// </summary>
17+
/// <remarks>
18+
/// The conversion process may use ICC profiles if available; otherwise, it performs a manual
19+
/// conversion through the profile connection space (PCS) with chromatic adaptation as needed. The method requires
20+
/// both source and target types to be value types implementing the appropriate color profile interface.
21+
/// </remarks>
22+
/// <typeparam name="TFrom">The source color profile type. Must implement <see cref="IColorProfile{TFrom, CieXyz}"/>.</typeparam>
23+
/// <typeparam name="TTo">The target color profile type. Must implement <see cref="IColorProfile{TTo, CieLab}"/>.</typeparam>
24+
/// <param name="converter">The color profile converter to use for the conversion.</param>
25+
/// <param name="source">The source color value to convert.</param>
26+
/// <returns>A value of type <typeparamref name="TTo"/> representing the converted color in the target color profile.</returns>
1127
public static TTo Convert<TFrom, TTo>(this ColorProfileConverter converter, in TFrom source)
1228
where TFrom : struct, IColorProfile<TFrom, CieXyz>
1329
where TTo : struct, IColorProfile<TTo, CieLab>
@@ -33,6 +49,20 @@ public static TTo Convert<TFrom, TTo>(this ColorProfileConverter converter, in T
3349
return TTo.FromProfileConnectingSpace(options, in pcsTo);
3450
}
3551

52+
/// <summary>
53+
/// Converts a span of color values from one color profile to another using the specified color profile converter.
54+
/// </summary>
55+
/// <remarks>
56+
/// This method performs color conversion between two color profiles, handling necessary
57+
/// transformations such as profile connection space conversion and chromatic adaptation. If ICC profiles are
58+
/// available and applicable, the conversion uses them for improved accuracy. The method does not allocate memory
59+
/// for the destination; the caller is responsible for providing a suitably sized span.
60+
/// </remarks>
61+
/// <typeparam name="TFrom">The type representing the source color profile. Must implement <see cref="IColorProfile{TFrom, CieXyz}"/>.</typeparam>
62+
/// <typeparam name="TTo">The type representing the destination color profile. Must implement <see cref="IColorProfile{TTo, CieLab}"/>.</typeparam>
63+
/// <param name="converter">The color profile converter to use for the conversion operation.</param>
64+
/// <param name="source">A read-only span containing the source color values to convert.</param>
65+
/// <param name="destination">A span that receives the converted color values. Must be at least as long as the source span.</param>
3666
public static void Convert<TFrom, TTo>(this ColorProfileConverter converter, ReadOnlySpan<TFrom> source, Span<TTo> destination)
3767
where TFrom : struct, IColorProfile<TFrom, CieXyz>
3868
where TTo : struct, IColorProfile<TTo, CieLab>

src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsCieXyzCieXyz.cs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,24 @@
66

77
namespace SixLabors.ImageSharp.ColorProfiles;
88

9-
internal static class ColorProfileConverterExtensionsCieXyzCieXyz
9+
/// <summary>
10+
/// Allows conversion between two color profiles based on the CIE XYZ color space.
11+
/// </summary>
12+
public static class ColorProfileConverterExtensionsCieXyzCieXyz
1013
{
14+
/// <summary>
15+
/// Converts a color value from one color profile to another using the specified color profile converter.
16+
/// </summary>
17+
/// <remarks>
18+
/// The conversion process may use ICC profiles if available; otherwise, it performs a manual
19+
/// conversion through the profile connection space (PCS) with chromatic adaptation as needed. The method requires
20+
/// both source and target types to be value types implementing the appropriate color profile interface.
21+
/// </remarks>
22+
/// <typeparam name="TFrom">The source color profile type. Must implement <see cref="IColorProfile{TFrom, CieXyz}"/>.</typeparam>
23+
/// <typeparam name="TTo">The target color profile type. Must implement <see cref="IColorProfile{TTo, CieXyz}"/>.</typeparam>
24+
/// <param name="converter">The color profile converter to use for the conversion.</param>
25+
/// <param name="source">The source color value to convert.</param>
26+
/// <returns>A value of type <typeparamref name="TTo"/> representing the converted color in the target color profile.</returns>
1127
public static TTo Convert<TFrom, TTo>(this ColorProfileConverter converter, in TFrom source)
1228
where TFrom : struct, IColorProfile<TFrom, CieXyz>
1329
where TTo : struct, IColorProfile<TTo, CieXyz>
@@ -30,6 +46,20 @@ public static TTo Convert<TFrom, TTo>(this ColorProfileConverter converter, in T
3046
return TTo.FromProfileConnectingSpace(options, in pcsFrom);
3147
}
3248

49+
/// <summary>
50+
/// Converts a span of color values from one color profile to another using the specified color profile converter.
51+
/// </summary>
52+
/// <remarks>
53+
/// This method performs color conversion between two color profiles, handling necessary
54+
/// transformations such as profile connection space conversion and chromatic adaptation. If ICC profiles are
55+
/// available and applicable, the conversion uses them for improved accuracy. The method does not allocate memory
56+
/// for the destination; the caller is responsible for providing a suitably sized span.
57+
/// </remarks>
58+
/// <typeparam name="TFrom">The type representing the source color profile. Must implement <see cref="IColorProfile{TFrom, CieXyz}"/>.</typeparam>
59+
/// <typeparam name="TTo">The type representing the destination color profile. Must implement <see cref="IColorProfile{TTo, CieXyz}"/>.</typeparam>
60+
/// <param name="converter">The color profile converter to use for the conversion operation.</param>
61+
/// <param name="source">A read-only span containing the source color values to convert.</param>
62+
/// <param name="destination">A span that receives the converted color values. Must be at least as long as the source span.</param>
3363
public static void Convert<TFrom, TTo>(this ColorProfileConverter converter, ReadOnlySpan<TFrom> source, Span<TTo> destination)
3464
where TFrom : struct, IColorProfile<TFrom, CieXyz>
3565
where TTo : struct, IColorProfile<TTo, CieXyz>

src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsCieXyzRgb.cs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,24 @@
66

77
namespace SixLabors.ImageSharp.ColorProfiles;
88

9-
internal static class ColorProfileConverterExtensionsCieXyzRgb
9+
/// <summary>
10+
/// Allows conversion between two color profiles based on the CIE XYZ and RGB color spaces.
11+
/// </summary>
12+
public static class ColorProfileConverterExtensionsCieXyzRgb
1013
{
14+
/// <summary>
15+
/// Converts a color value from one color profile to another using the specified color profile converter.
16+
/// </summary>
17+
/// <remarks>
18+
/// The conversion process may use ICC profiles if available; otherwise, it performs a manual
19+
/// conversion through the profile connection space (PCS) with chromatic adaptation as needed. The method requires
20+
/// both source and target types to be value types implementing the appropriate color profile interface.
21+
/// </remarks>
22+
/// <typeparam name="TFrom">The source color profile type. Must implement <see cref="IColorProfile{TFrom, CieXyz}"/>.</typeparam>
23+
/// <typeparam name="TTo">The target color profile type. Must implement <see cref="IColorProfile{TTo, Rgb}"/>.</typeparam>
24+
/// <param name="converter">The color profile converter to use for the conversion.</param>
25+
/// <param name="source">The source color value to convert.</param>
26+
/// <returns>A value of type <typeparamref name="TTo"/> representing the converted color in the target color profile.</returns>
1127
public static TTo Convert<TFrom, TTo>(this ColorProfileConverter converter, in TFrom source)
1228
where TFrom : struct, IColorProfile<TFrom, CieXyz>
1329
where TTo : struct, IColorProfile<TTo, Rgb>
@@ -33,6 +49,20 @@ public static TTo Convert<TFrom, TTo>(this ColorProfileConverter converter, in T
3349
return TTo.FromProfileConnectingSpace(options, in pcsTo);
3450
}
3551

52+
/// <summary>
53+
/// Converts a span of color values from one color profile to another using the specified color profile converter.
54+
/// </summary>
55+
/// <remarks>
56+
/// This method performs color conversion between two color profiles, handling necessary
57+
/// transformations such as profile connection space conversion and chromatic adaptation. If ICC profiles are
58+
/// available and applicable, the conversion uses them for improved accuracy. The method does not allocate memory
59+
/// for the destination; the caller is responsible for providing a suitably sized span.
60+
/// </remarks>
61+
/// <typeparam name="TFrom">The type representing the source color profile. Must implement <see cref="IColorProfile{TFrom, CieXyz}"/>.</typeparam>
62+
/// <typeparam name="TTo">The type representing the destination color profile. Must implement <see cref="IColorProfile{TTo, Rgb}"/>.</typeparam>
63+
/// <param name="converter">The color profile converter to use for the conversion operation.</param>
64+
/// <param name="source">A read-only span containing the source color values to convert.</param>
65+
/// <param name="destination">A span that receives the converted color values. Must be at least as long as the source span.</param>
3666
public static void Convert<TFrom, TTo>(this ColorProfileConverter converter, ReadOnlySpan<TFrom> source, Span<TTo> destination)
3767
where TFrom : struct, IColorProfile<TFrom, CieXyz>
3868
where TTo : struct, IColorProfile<TTo, Rgb>

0 commit comments

Comments
 (0)