Browse Source

Cleanups (capitalization, tests)

pull/2592/head
Tammo Hinrichs 2 years ago
parent
commit
b30698c53c
  1. 2
      src/ImageSharp/Formats/Png/PngDecoderCore.cs
  2. 2
      src/ImageSharp/Formats/Png/PngEncoderCore.cs
  3. 2
      src/ImageSharp/Metadata/ImageFrameMetadata.cs
  4. 2
      src/ImageSharp/Metadata/ImageMetadata.cs
  5. 4
      src/ImageSharp/Metadata/Profiles/CICP/CicpProfile.cs
  6. 2
      src/ImageSharp/Metadata/Profiles/CICP/Enums/CicpColorPrimaries.cs
  7. 2
      src/ImageSharp/Metadata/Profiles/CICP/Enums/CicpMatrixCoefficients.cs
  8. 4
      src/ImageSharp/Metadata/Profiles/CICP/Enums/CicpTransferCharacteristics.cs
  9. 46
      tests/ImageSharp.Tests/Metadata/Profiles/CICP/CicpProfileTests.cs

2
src/ImageSharp/Formats/Png/PngDecoderCore.cs

@ -16,7 +16,7 @@ using SixLabors.ImageSharp.Formats.Png.Filters;
using SixLabors.ImageSharp.IO; using SixLabors.ImageSharp.IO;
using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.Metadata; using SixLabors.ImageSharp.Metadata;
using SixLabors.ImageSharp.Metadata.Profiles.CICP; using SixLabors.ImageSharp.Metadata.Profiles.Cicp;
using SixLabors.ImageSharp.Metadata.Profiles.Exif; using SixLabors.ImageSharp.Metadata.Profiles.Exif;
using SixLabors.ImageSharp.Metadata.Profiles.Icc; using SixLabors.ImageSharp.Metadata.Profiles.Icc;
using SixLabors.ImageSharp.Metadata.Profiles.Xmp; using SixLabors.ImageSharp.Metadata.Profiles.Xmp;

2
src/ImageSharp/Formats/Png/PngEncoderCore.cs

@ -787,7 +787,7 @@ internal sealed class PngEncoderCore : IImageEncoderInternals, IDisposable
} }
// by spec, the matrix coefficients must be set to Identity // by spec, the matrix coefficients must be set to Identity
if (metaData.CicpProfile.MatrixCoefficients != Metadata.Profiles.CICP.CicpMatrixCoefficients.Identity) if (metaData.CicpProfile.MatrixCoefficients != Metadata.Profiles.Cicp.CicpMatrixCoefficients.Identity)
{ {
throw new NotSupportedException("CICP matrix coefficients other than Identity are not supported in PNG"); throw new NotSupportedException("CICP matrix coefficients other than Identity are not supported in PNG");
} }

2
src/ImageSharp/Metadata/ImageFrameMetadata.cs

@ -2,7 +2,7 @@
// Licensed under the Six Labors Split License. // Licensed under the Six Labors Split License.
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Metadata.Profiles.CICP; using SixLabors.ImageSharp.Metadata.Profiles.Cicp;
using SixLabors.ImageSharp.Metadata.Profiles.Exif; using SixLabors.ImageSharp.Metadata.Profiles.Exif;
using SixLabors.ImageSharp.Metadata.Profiles.Icc; using SixLabors.ImageSharp.Metadata.Profiles.Icc;
using SixLabors.ImageSharp.Metadata.Profiles.Iptc; using SixLabors.ImageSharp.Metadata.Profiles.Iptc;

2
src/ImageSharp/Metadata/ImageMetadata.cs

@ -2,7 +2,7 @@
// Licensed under the Six Labors Split License. // Licensed under the Six Labors Split License.
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Metadata.Profiles.CICP; using SixLabors.ImageSharp.Metadata.Profiles.Cicp;
using SixLabors.ImageSharp.Metadata.Profiles.Exif; using SixLabors.ImageSharp.Metadata.Profiles.Exif;
using SixLabors.ImageSharp.Metadata.Profiles.Icc; using SixLabors.ImageSharp.Metadata.Profiles.Icc;
using SixLabors.ImageSharp.Metadata.Profiles.Iptc; using SixLabors.ImageSharp.Metadata.Profiles.Iptc;

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

@ -1,10 +1,10 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Six Labors Split License. // Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Metadata.Profiles.CICP; namespace SixLabors.ImageSharp.Metadata.Profiles.Cicp;
/// <summary> /// <summary>
/// Represents a CICP profile as per ITU-T H.273 / ISO/IEC 23091-2_2019 providing access to color space information /// Represents a Cicp profile as per ITU-T H.273 / ISO/IEC 23091-2_2019 providing access to color space information
/// </summary> /// </summary>
public sealed class CicpProfile : IDeepCloneable<CicpProfile> public sealed class CicpProfile : IDeepCloneable<CicpProfile>
{ {

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

@ -1,7 +1,7 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Six Labors Split License. // Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Metadata.Profiles.CICP; namespace SixLabors.ImageSharp.Metadata.Profiles.Cicp;
#pragma warning disable CA1707 // Underscores in enum members #pragma warning disable CA1707 // Underscores in enum members

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

@ -1,7 +1,7 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Six Labors Split License. // Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Metadata.Profiles.CICP; namespace SixLabors.ImageSharp.Metadata.Profiles.Cicp;
#pragma warning disable CA1707 // Underscores in enum members #pragma warning disable CA1707 // Underscores in enum members

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

@ -1,9 +1,9 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Six Labors Split License. // Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Metadata.Profiles.CICP; namespace SixLabors.ImageSharp.Metadata.Profiles.Cicp;
#pragma warning disable CA1707 // Underscores in enum members #pragma warning disable CA1707 // Underscores in enum values
/// <summary> /// <summary>
/// Transfer characteristics according to ITU-T H.273 / ISO/IEC 23091-2_2019 subclause 8.2 /// Transfer characteristics according to ITU-T H.273 / ISO/IEC 23091-2_2019 subclause 8.2

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

@ -3,7 +3,7 @@
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Formats.Png; using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.Metadata.Profiles.CICP; using SixLabors.ImageSharp.Metadata.Profiles.Cicp;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.Cicp; namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.Cicp;
@ -15,11 +15,10 @@ public class CicpProfileTests
public async Task ReadCicpMetadata_FromPng_Works<TPixel>(TestImageProvider<TPixel> provider) public async Task ReadCicpMetadata_FromPng_Works<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
using (Image<TPixel> image = await provider.GetImageAsync(PngDecoder.Instance)) using Image<TPixel> image = await provider.GetImageAsync(PngDecoder.Instance);
{
CicpProfile actual = image.Metadata.CicpProfile ?? image.Frames.RootFrame.Metadata.CicpProfile; CicpProfile actual = image.Metadata.CicpProfile ?? image.Frames.RootFrame.Metadata.CicpProfile;
CicpProfileContainsExpectedValues(actual); CicpProfileContainsExpectedValues(actual);
}
} }
[Fact] [Fact]
@ -27,13 +26,7 @@ public class CicpProfileTests
{ {
// arrange // arrange
using var image = new Image<Rgba32>(1, 1); using var image = new Image<Rgba32>(1, 1);
var original = new CicpProfile() var original = CreateCicpProfile();
{
ColorPrimaries = CicpColorPrimaries.ItuRBt2020_2,
TransferCharacteristics = CicpTransferCharacteristics.SmpteSt2084,
MatrixCoefficients = CicpMatrixCoefficients.Identity,
FullRange = true,
};
image.Metadata.CicpProfile = original; image.Metadata.CicpProfile = original;
var encoder = new PngEncoder(); var encoder = new PngEncoder();
@ -42,11 +35,7 @@ public class CicpProfileTests
// assert // assert
CicpProfile actual = reloadedImage.Metadata.CicpProfile ?? reloadedImage.Frames.RootFrame.Metadata.CicpProfile; CicpProfile actual = reloadedImage.Metadata.CicpProfile ?? reloadedImage.Frames.RootFrame.Metadata.CicpProfile;
Assert.NotNull(actual); CicpProfileIsValidAndEqual(actual, original);
Assert.Equal(actual.ColorPrimaries, original.ColorPrimaries);
Assert.Equal(actual.TransferCharacteristics, original.TransferCharacteristics);
Assert.Equal(actual.MatrixCoefficients, original.MatrixCoefficients);
Assert.Equal(actual.FullRange, original.FullRange);
} }
private static void CicpProfileContainsExpectedValues(CicpProfile cicp) private static void CicpProfileContainsExpectedValues(CicpProfile cicp)
@ -58,6 +47,27 @@ public class CicpProfileTests
Assert.True(cicp.FullRange); Assert.True(cicp.FullRange);
} }
private static CicpProfile CreateCicpProfile()
{
var profile = new CicpProfile()
{
ColorPrimaries = CicpColorPrimaries.ItuRBt2020_2,
TransferCharacteristics = CicpTransferCharacteristics.SmpteSt2084,
MatrixCoefficients = CicpMatrixCoefficients.Identity,
FullRange = true,
};
return profile;
}
private static void CicpProfileIsValidAndEqual(CicpProfile actual, CicpProfile original)
{
Assert.NotNull(actual);
Assert.Equal(actual.ColorPrimaries, original.ColorPrimaries);
Assert.Equal(actual.TransferCharacteristics, original.TransferCharacteristics);
Assert.Equal(actual.MatrixCoefficients, original.MatrixCoefficients);
Assert.Equal(actual.FullRange, original.FullRange);
}
private static Image<Rgba32> WriteAndRead(Image<Rgba32> image, IImageEncoder encoder) private static Image<Rgba32> WriteAndRead(Image<Rgba32> image, IImageEncoder encoder)
{ {
using (var memStream = new MemoryStream()) using (var memStream = new MemoryStream())

Loading…
Cancel
Save