33
44using SixLabors . ImageSharp . Formats ;
55using SixLabors . ImageSharp . Formats . Png ;
6- using SixLabors . ImageSharp . Metadata . Profiles . CICP ;
6+ using SixLabors . ImageSharp . Metadata . Profiles . Cicp ;
77using SixLabors . ImageSharp . PixelFormats ;
88
99namespace 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