Skip to content

Commit b30698c

Browse files
Cleanups (capitalization, tests)
1 parent fabfd5b commit b30698c

9 files changed

Lines changed: 38 additions & 28 deletions

File tree

src/ImageSharp/Formats/Png/PngDecoderCore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
using SixLabors.ImageSharp.IO;
1717
using SixLabors.ImageSharp.Memory;
1818
using SixLabors.ImageSharp.Metadata;
19-
using SixLabors.ImageSharp.Metadata.Profiles.CICP;
19+
using SixLabors.ImageSharp.Metadata.Profiles.Cicp;
2020
using SixLabors.ImageSharp.Metadata.Profiles.Exif;
2121
using SixLabors.ImageSharp.Metadata.Profiles.Icc;
2222
using SixLabors.ImageSharp.Metadata.Profiles.Xmp;

src/ImageSharp/Formats/Png/PngEncoderCore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ private void WriteCicpChunk(Stream stream, ImageMetadata metaData)
787787
}
788788

789789
// by spec, the matrix coefficients must be set to Identity
790-
if (metaData.CicpProfile.MatrixCoefficients != Metadata.Profiles.CICP.CicpMatrixCoefficients.Identity)
790+
if (metaData.CicpProfile.MatrixCoefficients != Metadata.Profiles.Cicp.CicpMatrixCoefficients.Identity)
791791
{
792792
throw new NotSupportedException("CICP matrix coefficients other than Identity are not supported in PNG");
793793
}

src/ImageSharp/Metadata/ImageFrameMetadata.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the Six Labors Split License.
33

44
using SixLabors.ImageSharp.Formats;
5-
using SixLabors.ImageSharp.Metadata.Profiles.CICP;
5+
using SixLabors.ImageSharp.Metadata.Profiles.Cicp;
66
using SixLabors.ImageSharp.Metadata.Profiles.Exif;
77
using SixLabors.ImageSharp.Metadata.Profiles.Icc;
88
using SixLabors.ImageSharp.Metadata.Profiles.Iptc;

src/ImageSharp/Metadata/ImageMetadata.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the Six Labors Split License.
33

44
using SixLabors.ImageSharp.Formats;
5-
using SixLabors.ImageSharp.Metadata.Profiles.CICP;
5+
using SixLabors.ImageSharp.Metadata.Profiles.Cicp;
66
using SixLabors.ImageSharp.Metadata.Profiles.Exif;
77
using SixLabors.ImageSharp.Metadata.Profiles.Icc;
88
using SixLabors.ImageSharp.Metadata.Profiles.Iptc;

src/ImageSharp/Metadata/Profiles/CICP/CicpProfile.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Copyright (c) Six Labors.
22
// Licensed under the Six Labors Split License.
33

4-
namespace SixLabors.ImageSharp.Metadata.Profiles.CICP;
4+
namespace SixLabors.ImageSharp.Metadata.Profiles.Cicp;
55

66
/// <summary>
7-
/// Represents a CICP profile as per ITU-T H.273 / ISO/IEC 23091-2_2019 providing access to color space information
7+
/// Represents a Cicp profile as per ITU-T H.273 / ISO/IEC 23091-2_2019 providing access to color space information
88
/// </summary>
99
public sealed class CicpProfile : IDeepCloneable<CicpProfile>
1010
{

src/ImageSharp/Metadata/Profiles/CICP/Enums/CicpColorPrimaries.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Six Labors.
22
// Licensed under the Six Labors Split License.
33

4-
namespace SixLabors.ImageSharp.Metadata.Profiles.CICP;
4+
namespace SixLabors.ImageSharp.Metadata.Profiles.Cicp;
55

66
#pragma warning disable CA1707 // Underscores in enum members
77

src/ImageSharp/Metadata/Profiles/CICP/Enums/CicpMatrixCoefficients.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Six Labors.
22
// Licensed under the Six Labors Split License.
33

4-
namespace SixLabors.ImageSharp.Metadata.Profiles.CICP;
4+
namespace SixLabors.ImageSharp.Metadata.Profiles.Cicp;
55

66
#pragma warning disable CA1707 // Underscores in enum members
77

src/ImageSharp/Metadata/Profiles/CICP/Enums/CicpTransferCharacteristics.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// Copyright (c) Six Labors.
22
// Licensed under the Six Labors Split License.
33

4-
namespace SixLabors.ImageSharp.Metadata.Profiles.CICP;
4+
namespace SixLabors.ImageSharp.Metadata.Profiles.Cicp;
55

6-
#pragma warning disable CA1707 // Underscores in enum members
6+
#pragma warning disable CA1707 // Underscores in enum values
77

88
/// <summary>
99
/// Transfer characteristics according to ITU-T H.273 / ISO/IEC 23091-2_2019 subclause 8.2

tests/ImageSharp.Tests/Metadata/Profiles/CICP/CicpProfileTests.cs

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
using SixLabors.ImageSharp.Formats;
55
using SixLabors.ImageSharp.Formats.Png;
6-
using SixLabors.ImageSharp.Metadata.Profiles.CICP;
6+
using SixLabors.ImageSharp.Metadata.Profiles.Cicp;
77
using SixLabors.ImageSharp.PixelFormats;
88

99
namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.Cicp;
@@ -15,25 +15,18 @@ public class CicpProfileTests
1515
public async Task ReadCicpMetadata_FromPng_Works<TPixel>(TestImageProvider<TPixel> provider)
1616
where TPixel : unmanaged, IPixel<TPixel>
1717
{
18-
using (Image<TPixel> image = await provider.GetImageAsync(PngDecoder.Instance))
19-
{
20-
CicpProfile actual = image.Metadata.CicpProfile ?? image.Frames.RootFrame.Metadata.CicpProfile;
21-
CicpProfileContainsExpectedValues(actual);
22-
}
18+
using Image<TPixel> image = await provider.GetImageAsync(PngDecoder.Instance);
19+
20+
CicpProfile actual = image.Metadata.CicpProfile ?? image.Frames.RootFrame.Metadata.CicpProfile;
21+
CicpProfileContainsExpectedValues(actual);
2322
}
2423

2524
[Fact]
2625
public void WritingPng_PreservesCicpProfile()
2726
{
2827
// arrange
2928
using var image = new Image<Rgba32>(1, 1);
30-
var original = new CicpProfile()
31-
{
32-
ColorPrimaries = CicpColorPrimaries.ItuRBt2020_2,
33-
TransferCharacteristics = CicpTransferCharacteristics.SmpteSt2084,
34-
MatrixCoefficients = CicpMatrixCoefficients.Identity,
35-
FullRange = true,
36-
};
29+
var original = CreateCicpProfile();
3730
image.Metadata.CicpProfile = original;
3831
var encoder = new PngEncoder();
3932

@@ -42,11 +35,7 @@ public void WritingPng_PreservesCicpProfile()
4235

4336
// assert
4437
CicpProfile actual = reloadedImage.Metadata.CicpProfile ?? reloadedImage.Frames.RootFrame.Metadata.CicpProfile;
45-
Assert.NotNull(actual);
46-
Assert.Equal(actual.ColorPrimaries, original.ColorPrimaries);
47-
Assert.Equal(actual.TransferCharacteristics, original.TransferCharacteristics);
48-
Assert.Equal(actual.MatrixCoefficients, original.MatrixCoefficients);
49-
Assert.Equal(actual.FullRange, original.FullRange);
38+
CicpProfileIsValidAndEqual(actual, original);
5039
}
5140

5241
private static void CicpProfileContainsExpectedValues(CicpProfile cicp)
@@ -58,6 +47,27 @@ private static void CicpProfileContainsExpectedValues(CicpProfile cicp)
5847
Assert.True(cicp.FullRange);
5948
}
6049

50+
private static CicpProfile CreateCicpProfile()
51+
{
52+
var profile = new CicpProfile()
53+
{
54+
ColorPrimaries = CicpColorPrimaries.ItuRBt2020_2,
55+
TransferCharacteristics = CicpTransferCharacteristics.SmpteSt2084,
56+
MatrixCoefficients = CicpMatrixCoefficients.Identity,
57+
FullRange = true,
58+
};
59+
return profile;
60+
}
61+
62+
private static void CicpProfileIsValidAndEqual(CicpProfile actual, CicpProfile original)
63+
{
64+
Assert.NotNull(actual);
65+
Assert.Equal(actual.ColorPrimaries, original.ColorPrimaries);
66+
Assert.Equal(actual.TransferCharacteristics, original.TransferCharacteristics);
67+
Assert.Equal(actual.MatrixCoefficients, original.MatrixCoefficients);
68+
Assert.Equal(actual.FullRange, original.FullRange);
69+
}
70+
6171
private static Image<Rgba32> WriteAndRead(Image<Rgba32> image, IImageEncoder encoder)
6272
{
6373
using (var memStream = new MemoryStream())

0 commit comments

Comments
 (0)