1
1
// Copyright (c) Six Labors.
2
2
// Licensed under the Six Labors Split License.
3
3
4
+ using SixLabors . ImageSharp . Formats . Qoi ;
4
5
using SixLabors . ImageSharp . PixelFormats ;
5
6
6
7
namespace SixLabors . ImageSharp . Tests . Formats . Qoi ;
@@ -10,40 +11,46 @@ namespace SixLabors.ImageSharp.Tests.Formats.Qoi;
10
11
public class QoiDecoderTests
11
12
{
12
13
[ Theory ]
13
- [ InlineData ( TestImages . Qoi . Dice ) ]
14
- [ InlineData ( TestImages . Qoi . EdgeCase ) ]
15
- [ InlineData ( TestImages . Qoi . Kodim10 ) ]
16
- [ InlineData ( TestImages . Qoi . Kodim23 ) ]
17
- [ InlineData ( TestImages . Qoi . QoiLogo ) ]
18
- [ InlineData ( TestImages . Qoi . TestCard ) ]
19
- [ InlineData ( TestImages . Qoi . TestCardRGBA ) ]
20
- [ InlineData ( TestImages . Qoi . Wikipedia008 ) ]
21
- public void Identify ( string imagePath )
14
+ [ InlineData ( TestImages . Qoi . Dice , QoiChannels . Rgba , QoiColorSpace . SrgbWithLinearAlpha ) ]
15
+ [ InlineData ( TestImages . Qoi . EdgeCase , QoiChannels . Rgba , QoiColorSpace . SrgbWithLinearAlpha ) ]
16
+ [ InlineData ( TestImages . Qoi . Kodim10 , QoiChannels . Rgb , QoiColorSpace . SrgbWithLinearAlpha ) ]
17
+ [ InlineData ( TestImages . Qoi . Kodim23 , QoiChannels . Rgb , QoiColorSpace . SrgbWithLinearAlpha ) ]
18
+ [ InlineData ( TestImages . Qoi . QoiLogo , QoiChannels . Rgba , QoiColorSpace . SrgbWithLinearAlpha ) ]
19
+ [ InlineData ( TestImages . Qoi . TestCard , QoiChannels . Rgba , QoiColorSpace . SrgbWithLinearAlpha ) ]
20
+ [ InlineData ( TestImages . Qoi . TestCardRGBA , QoiChannels . Rgba , QoiColorSpace . SrgbWithLinearAlpha ) ]
21
+ [ InlineData ( TestImages . Qoi . Wikipedia008 , QoiChannels . Rgb , QoiColorSpace . SrgbWithLinearAlpha ) ]
22
+ public void Identify ( string imagePath , QoiChannels channels , QoiColorSpace colorSpace )
22
23
{
23
24
TestFile testFile = TestFile . Create ( imagePath ) ;
24
25
using MemoryStream stream = new ( testFile . Bytes , false ) ;
25
26
26
27
ImageInfo imageInfo = Image . Identify ( stream ) ;
28
+ QoiMetadata qoiMetadata = imageInfo . Metadata . GetQoiMetadata ( ) ;
27
29
28
30
Assert . NotNull ( imageInfo ) ;
29
- Assert . Equal ( imageInfo . Metadata . DecodedImageFormat , ImageSharp . Formats . Qoi . QoiFormat . Instance ) ;
31
+ Assert . Equal ( imageInfo . Metadata . DecodedImageFormat , QoiFormat . Instance ) ;
32
+ Assert . Equal ( qoiMetadata . Channels , channels ) ;
33
+ Assert . Equal ( qoiMetadata . ColorSpace , colorSpace ) ;
30
34
}
31
35
32
36
[ Theory ]
33
- [ WithFile ( TestImages . Qoi . Dice , PixelTypes . Rgba32 ) ]
34
- [ WithFile ( TestImages . Qoi . EdgeCase , PixelTypes . Rgba32 ) ]
35
- [ WithFile ( TestImages . Qoi . Kodim10 , PixelTypes . Rgba32 ) ]
36
- [ WithFile ( TestImages . Qoi . Kodim23 , PixelTypes . Rgba32 ) ]
37
- [ WithFile ( TestImages . Qoi . QoiLogo , PixelTypes . Rgba32 ) ]
38
- [ WithFile ( TestImages . Qoi . TestCard , PixelTypes . Rgba32 ) ]
39
- [ WithFile ( TestImages . Qoi . TestCardRGBA , PixelTypes . Rgba32 ) ]
40
- [ WithFile ( TestImages . Qoi . Wikipedia008 , PixelTypes . Rgba32 ) ]
41
- public void Decode < TPixel > ( TestImageProvider < TPixel > provider )
37
+ [ WithFile ( TestImages . Qoi . Dice , PixelTypes . Rgba32 , QoiChannels . Rgba , QoiColorSpace . SrgbWithLinearAlpha ) ]
38
+ [ WithFile ( TestImages . Qoi . EdgeCase , PixelTypes . Rgba32 , QoiChannels . Rgba , QoiColorSpace . SrgbWithLinearAlpha ) ]
39
+ [ WithFile ( TestImages . Qoi . Kodim10 , PixelTypes . Rgba32 , QoiChannels . Rgb , QoiColorSpace . SrgbWithLinearAlpha ) ]
40
+ [ WithFile ( TestImages . Qoi . Kodim23 , PixelTypes . Rgba32 , QoiChannels . Rgb , QoiColorSpace . SrgbWithLinearAlpha ) ]
41
+ [ WithFile ( TestImages . Qoi . QoiLogo , PixelTypes . Rgba32 , QoiChannels . Rgba , QoiColorSpace . SrgbWithLinearAlpha ) ]
42
+ [ WithFile ( TestImages . Qoi . TestCard , PixelTypes . Rgba32 , QoiChannels . Rgba , QoiColorSpace . SrgbWithLinearAlpha ) ]
43
+ [ WithFile ( TestImages . Qoi . TestCardRGBA , PixelTypes . Rgba32 , QoiChannels . Rgba , QoiColorSpace . SrgbWithLinearAlpha ) ]
44
+ [ WithFile ( TestImages . Qoi . Wikipedia008 , PixelTypes . Rgba32 , QoiChannels . Rgb , QoiColorSpace . SrgbWithLinearAlpha ) ]
45
+ public void Decode < TPixel > ( TestImageProvider < TPixel > provider , QoiChannels channels , QoiColorSpace colorSpace )
42
46
where TPixel : unmanaged, IPixel < TPixel >
43
47
{
44
48
using Image < TPixel > image = provider . GetImage ( ) ;
49
+ QoiMetadata qoiMetadata = image . Metadata . GetQoiMetadata ( ) ;
45
50
image . DebugSave ( provider ) ;
46
51
47
52
image . CompareToReferenceOutput ( provider ) ;
53
+ Assert . Equal ( qoiMetadata . Channels , channels ) ;
54
+ Assert . Equal ( qoiMetadata . ColorSpace , colorSpace ) ;
48
55
}
49
56
}
0 commit comments