Skip to content

Commit ea56484

Browse files
Rename type
1 parent 62da42d commit ea56484

File tree

7 files changed

+28
-28
lines changed

7 files changed

+28
-28
lines changed

src/ImageSharp/ColorProfiles/ColorConversionOptions.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ namespace SixLabors.ImageSharp.ColorProfiles;
1414
public class ColorConversionOptions
1515
{
1616
private Matrix4x4 adaptationMatrix;
17-
private YCbCrMatrix yCbCrMatrix;
17+
private YCbCrTransform yCbCrTransform;
1818

1919
/// <summary>
2020
/// Initializes a new instance of the <see cref="ColorConversionOptions"/> class.
2121
/// </summary>
2222
public ColorConversionOptions()
2323
{
2424
this.AdaptationMatrix = KnownChromaticAdaptationMatrices.Bradford;
25-
this.YCbCrMatrix = KnownYCbCrMatrices.BT601;
25+
this.YCbCrTransform = KnownYCbCrMatrices.BT601;
2626
}
2727

2828
/// <summary>
@@ -53,13 +53,13 @@ public ColorConversionOptions()
5353
/// <summary>
5454
/// Gets the YCbCr matrix to used to perform conversions from/to RGB.
5555
/// </summary>
56-
public YCbCrMatrix YCbCrMatrix
56+
public YCbCrTransform YCbCrTransform
5757
{
58-
get => this.yCbCrMatrix;
58+
get => this.yCbCrTransform;
5959
init
6060
{
61-
this.yCbCrMatrix = value;
62-
this.TransposedYCbCrMatrix = value.Transpose();
61+
this.yCbCrTransform = value;
62+
this.TransposedYCbCrTransform = value.Transpose();
6363
}
6464
}
6565

@@ -88,7 +88,7 @@ public Matrix4x4 AdaptationMatrix
8888
}
8989
}
9090

91-
internal YCbCrMatrix TransposedYCbCrMatrix { get; private set; }
91+
internal YCbCrTransform TransposedYCbCrTransform { get; private set; }
9292

9393
internal Matrix4x4 InverseAdaptationMatrix { get; private set; }
9494
}

src/ImageSharp/ColorProfiles/KnownYCbCrMatrices.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static class KnownYCbCrMatrices
1515
/// <summary>
1616
/// ITU-R BT.601 (SD video standard).
1717
/// </summary>
18-
public static readonly YCbCrMatrix BT601 = new(
18+
public static readonly YCbCrTransform BT601 = new(
1919
new Matrix4x4(
2020
0.299000F, 0.587000F, 0.114000F, 0F,
2121
-0.168736F, -0.331264F, 0.500000F, 0F,
@@ -31,7 +31,7 @@ public static class KnownYCbCrMatrices
3131
/// <summary>
3232
/// ITU-R BT.709 (HD video, sRGB standard).
3333
/// </summary>
34-
public static readonly YCbCrMatrix BT709 = new(
34+
public static readonly YCbCrTransform BT709 = new(
3535
new Matrix4x4(
3636
0.212600F, 0.715200F, 0.072200F, 0F,
3737
-0.114572F, -0.385428F, 0.500000F, 0F,
@@ -47,7 +47,7 @@ public static class KnownYCbCrMatrices
4747
/// <summary>
4848
/// ITU-R BT.2020 (UHD/4K video standard).
4949
/// </summary>
50-
public static readonly YCbCrMatrix BT2020 = new(
50+
public static readonly YCbCrTransform BT2020 = new(
5151
new Matrix4x4(
5252
0.262700F, 0.678000F, 0.059300F, 0F,
5353
-0.139630F, -0.360370F, 0.500000F, 0F,

src/ImageSharp/ColorProfiles/Y.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ public Rgb ToProfileConnectingSpace(ColorConversionOptions options)
9090
/// <inheritdoc/>
9191
public static Y FromProfileConnectingSpace(ColorConversionOptions options, in Rgb source)
9292
{
93-
Matrix4x4 m = options.YCbCrMatrix.Forward;
94-
float offset = options.YCbCrMatrix.Offset.X;
93+
Matrix4x4 m = options.YCbCrTransform.Forward;
94+
float offset = options.YCbCrTransform.Offset.X;
9595
return new(Vector3.Dot(source.AsVector3Unsafe(), new Vector3(m.M11, m.M12, m.M13)) + offset);
9696
}
9797

src/ImageSharp/ColorProfiles/YCbCr.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ public static void FromScaledVector4(ReadOnlySpan<Vector4> source, Span<YCbCr> d
130130
public static YCbCr FromProfileConnectingSpace(ColorConversionOptions options, in Rgb source)
131131
{
132132
Vector3 rgb = source.AsVector3Unsafe();
133-
Matrix4x4 m = options.TransposedYCbCrMatrix.Forward;
134-
Vector3 offset = options.TransposedYCbCrMatrix.Offset;
133+
Matrix4x4 m = options.TransposedYCbCrTransform.Forward;
134+
Vector3 offset = options.TransposedYCbCrTransform.Offset;
135135

136136
return new YCbCr(Vector3.Transform(rgb, m) + offset, true);
137137
}
@@ -152,8 +152,8 @@ public static void FromProfileConnectionSpace(ColorConversionOptions options, Re
152152
/// <inheritdoc/>
153153
public Rgb ToProfileConnectingSpace(ColorConversionOptions options)
154154
{
155-
Matrix4x4 m = options.TransposedYCbCrMatrix.Inverse;
156-
Vector3 offset = options.TransposedYCbCrMatrix.Offset;
155+
Matrix4x4 m = options.TransposedYCbCrTransform.Inverse;
156+
Vector3 offset = options.TransposedYCbCrTransform.Offset;
157157
Vector3 normalized = this.AsVector3Unsafe() - offset;
158158

159159
return Rgb.FromScaledVector3(Vector3.Transform(normalized, m));

src/ImageSharp/ColorProfiles/YcbCrMatrix.cs renamed to src/ImageSharp/ColorProfiles/YCbCrTransform.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace SixLabors.ImageSharp.ColorProfiles;
88

99
/// <summary>
1010
/// <para>
11-
/// Represents a YCbCr color matrix containing forward and inverse transformation matrices,
11+
/// Represents a YCbCr color transform containing forward and inverse transformation matrices,
1212
/// and the chrominance offsets to apply for full-range encoding
1313
/// </para>
1414
/// <para>
@@ -17,10 +17,10 @@ namespace SixLabors.ImageSharp.ColorProfiles;
1717
/// working spaces will produce incorrect conversions.
1818
/// </para>
1919
/// </summary>
20-
public readonly struct YCbCrMatrix
20+
public readonly struct YCbCrTransform
2121
{
2222
/// <summary>
23-
/// Initializes a new instance of the <see cref="YCbCrMatrix"/> struct.
23+
/// Initializes a new instance of the <see cref="YCbCrTransform"/> struct.
2424
/// </summary>
2525
/// <param name="forward">
2626
/// The forward transformation matrix from RGB to YCbCr. The matrix must include the
@@ -34,7 +34,7 @@ public readonly struct YCbCrMatrix
3434
/// The chrominance offsets to be added after the forward conversion,
3535
/// and subtracted before the inverse conversion. Usually <c>(0, 0.5, 0.5)</c>.
3636
/// </param>
37-
public YCbCrMatrix(Matrix4x4 forward, Matrix4x4 inverse, Vector3 offset)
37+
public YCbCrTransform(Matrix4x4 forward, Matrix4x4 inverse, Vector3 offset)
3838
{
3939
this.Forward = forward;
4040
this.Inverse = inverse;
@@ -56,6 +56,6 @@ public YCbCrMatrix(Matrix4x4 forward, Matrix4x4 inverse, Vector3 offset)
5656
/// </summary>
5757
public Vector3 Offset { get; }
5858

59-
internal YCbCrMatrix Transpose()
59+
internal YCbCrTransform Transpose()
6060
=> new(Matrix4x4.Transpose(this.Forward), Matrix4x4.Transpose(this.Inverse), this.Offset);
6161
}

src/ImageSharp/ColorProfiles/YccK.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ public static void FromScaledVector4(ReadOnlySpan<Vector4> source, Span<YccK> de
131131
/// <inheritdoc/>
132132
public Rgb ToProfileConnectingSpace(ColorConversionOptions options)
133133
{
134-
Matrix4x4 m = options.TransposedYCbCrMatrix.Inverse;
135-
Vector3 offset = options.TransposedYCbCrMatrix.Offset;
134+
Matrix4x4 m = options.TransposedYCbCrTransform.Inverse;
135+
Vector3 offset = options.TransposedYCbCrTransform.Offset;
136136
Vector3 normalized = this.AsVector3Unsafe() - offset;
137137

138138
return Rgb.FromScaledVector3(Vector3.Transform(normalized, m) * (1F - this.K));
@@ -141,8 +141,8 @@ public Rgb ToProfileConnectingSpace(ColorConversionOptions options)
141141
/// <inheritdoc/>
142142
public static YccK FromProfileConnectingSpace(ColorConversionOptions options, in Rgb source)
143143
{
144-
Matrix4x4 m = options.TransposedYCbCrMatrix.Forward;
145-
Vector3 offset = options.TransposedYCbCrMatrix.Offset;
144+
Matrix4x4 m = options.TransposedYCbCrTransform.Forward;
145+
Vector3 offset = options.TransposedYCbCrTransform.Offset;
146146

147147
Vector3 rgb = source.AsVector3Unsafe();
148148
float k = 1F - MathF.Max(rgb.X, MathF.Max(rgb.Y, rgb.Z));

tests/ImageSharp.Tests/ColorProfiles/RbgAndYConversionTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public void Convert_Rgb_To_Y_BT601(float r, float g, float b, float y)
2323
{
2424
ColorConversionOptions options = new()
2525
{
26-
YCbCrMatrix = KnownYCbCrMatrices.BT601
26+
YCbCrTransform = KnownYCbCrMatrices.BT601
2727
};
2828

2929
Convert_Rgb_To_Y_Core(r, g, b, y, options);
@@ -37,7 +37,7 @@ public void Convert_Rgb_To_Y_BT709(float r, float g, float b, float y)
3737
{
3838
ColorConversionOptions options = new()
3939
{
40-
YCbCrMatrix = KnownYCbCrMatrices.BT709
40+
YCbCrTransform = KnownYCbCrMatrices.BT709
4141
};
4242

4343
Convert_Rgb_To_Y_Core(r, g, b, y, options);
@@ -51,7 +51,7 @@ public void Convert_Rgb_To_Y_BT2020(float r, float g, float b, float y)
5151
{
5252
ColorConversionOptions options = new()
5353
{
54-
YCbCrMatrix = KnownYCbCrMatrices.BT2020
54+
YCbCrTransform = KnownYCbCrMatrices.BT2020
5555
};
5656

5757
Convert_Rgb_To_Y_Core(r, g, b, y, options);

0 commit comments

Comments
 (0)