|
1 | 1 | // Copyright (c) Six Labors. |
2 | 2 | // Licensed under the Six Labors Split License. |
3 | 3 |
|
| 4 | +using SixLabors.ImageSharp.Formats; |
4 | 5 | using SixLabors.ImageSharp.Formats.Exr; |
5 | 6 | using SixLabors.ImageSharp.Formats.Exr.Constants; |
| 7 | +using SixLabors.ImageSharp.PixelFormats; |
6 | 8 |
|
7 | 9 | namespace SixLabors.ImageSharp.Tests.Formats.Exr; |
8 | 10 |
|
@@ -85,4 +87,32 @@ public void Identify_DetectsCorrectCompression(string imagePath, ExrCompression |
85 | 87 | Assert.NotNull(metadata); |
86 | 88 | Assert.Equal(expectedCompression, metadata.Compression); |
87 | 89 | } |
| 90 | + |
| 91 | + [Theory] |
| 92 | + [InlineData(PixelColorType.Binary, 1, ExrImageDataType.Unknown, ExrPixelType.Half)] |
| 93 | + [InlineData(PixelColorType.Indexed, 8, ExrImageDataType.Unknown, ExrPixelType.Half)] |
| 94 | + [InlineData(PixelColorType.Luminance, 16, ExrImageDataType.Gray, ExrPixelType.Half)] |
| 95 | + [InlineData(PixelColorType.RGB, 48, ExrImageDataType.Rgb, ExrPixelType.Float)] |
| 96 | + [InlineData(PixelColorType.BGR, 48, ExrImageDataType.Rgb, ExrPixelType.Float)] |
| 97 | + [InlineData(PixelColorType.RGB | PixelColorType.Alpha, 64, ExrImageDataType.Rgba, ExrPixelType.Float)] |
| 98 | + [InlineData(PixelColorType.BGR | PixelColorType.Alpha, 64, ExrImageDataType.Rgba, ExrPixelType.Float)] |
| 99 | + [InlineData(PixelColorType.Luminance | PixelColorType.Alpha, 32, ExrImageDataType.Rgba, ExrPixelType.Float)] |
| 100 | + [InlineData(PixelColorType.YCbCr, 48, ExrImageDataType.Unknown, ExrPixelType.Float)] |
| 101 | + [InlineData(PixelColorType.CMYK, 64, ExrImageDataType.Unknown, ExrPixelType.Float)] |
| 102 | + [InlineData(PixelColorType.YCCK, 64, ExrImageDataType.Unknown, ExrPixelType.Float)] |
| 103 | + public void FromFormatConnectingMetadata_ConvertColorTypeAsExpected(PixelColorType pixelColorType, int bitsPerPixel, ExrImageDataType expectedImageDataType, ExrPixelType expectedPixelType) |
| 104 | + { |
| 105 | + FormatConnectingMetadata formatConnectingMetadata = new() |
| 106 | + { |
| 107 | + PixelTypeInfo = new PixelTypeInfo(bitsPerPixel) |
| 108 | + { |
| 109 | + ColorType = pixelColorType, |
| 110 | + }, |
| 111 | + }; |
| 112 | + |
| 113 | + ExrMetadata actual = ExrMetadata.FromFormatConnectingMetadata(formatConnectingMetadata); |
| 114 | + |
| 115 | + Assert.Equal(expectedImageDataType, actual.ImageDataType); |
| 116 | + Assert.Equal(expectedPixelType, actual.PixelType); |
| 117 | + } |
88 | 118 | } |
0 commit comments