Skip to content

Commit 29f558a

Browse files
committed
Add test case for uint pixel type with alpha
1 parent 0ceeba4 commit 29f558a

File tree

5 files changed

+22
-1
lines changed

5 files changed

+22
-1
lines changed

src/ImageSharp/Formats/Exr/ExrDecoderCore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ private void DecodeUnsignedIntPixelData<TPixel>(BufferedReadStream stream, Buffe
223223

224224
for (int x = 0; x < width; x++)
225225
{
226-
Rgb96 pixelValue = new(redPixelData[x], greenPixelData[x], bluePixelData[x]);
226+
Rgba128 pixelValue = new(redPixelData[x], greenPixelData[x], bluePixelData[x], hasAlpha ? alphaPixelData[x] : uint.MaxValue);
227227
pixelRow[x] = TPixel.FromVector4(pixelValue.ToVector4());
228228
}
229229

tests/ImageSharp.Tests/Formats/Exr/ExrDecoderTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,20 @@ public void ExrDecoder_CanDecode_Uncompressed_Rgb_ExrPixelType_Uint<TPixel>(Test
5555
Assert.Equal(ExrPixelType.UnsignedInt, exrMetaData.PixelType);
5656
}
5757

58+
[Theory]
59+
[WithFile(TestImages.Exr.UintRgba, PixelTypes.Rgba32)]
60+
public void ExrDecoder_CanDecode_Uncompressed_Rgba_ExrPixelType_Uint<TPixel>(TestImageProvider<TPixel> provider)
61+
where TPixel : unmanaged, IPixel<TPixel>
62+
{
63+
using Image<TPixel> image = provider.GetImage(ExrDecoder.Instance);
64+
ExrMetadata exrMetaData = image.Metadata.GetExrMetadata();
65+
image.DebugSave(provider);
66+
67+
// Compare to referene output, since the reference decoder does not support this pixel type.
68+
image.CompareToReferenceOutput(provider);
69+
Assert.Equal(ExrPixelType.UnsignedInt, exrMetaData.PixelType);
70+
}
71+
5872
[Theory]
5973
[WithFile(TestImages.Exr.Rgb, PixelTypes.Rgba32)]
6074
public void ExrDecoder_CanDecode_Rgb<TPixel>(TestImageProvider<TPixel> provider)

tests/ImageSharp.Tests/TestImages.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,6 +1389,7 @@ public static class Exr
13891389
public const string UncompressedRgba = "Exr/Calliphora_uncompressed_rgba.exr";
13901390
public const string UncompressedFloatRgb = "Exr/rgb_float32_uncompressed.exr";
13911391
public const string UncompressedUintRgb = "Exr/Calliphora_uint32_uncompressed.exr";
1392+
public const string UintRgba = "Exr/rgba_uint_zip_compressed.exr";
13921393
public const string Zip = "Exr/Calliphora_zip.exr";
13931394
public const string Zips = "Exr/Calliphora_zips.exr";
13941395
public const string Rle = "Exr/Calliphora_rle.exr";
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:ff2ff1cdcfd219415430ba30a18962b54860d88bfc3adf337e97574c33c5e214
3+
size 119614

0 commit comments

Comments
 (0)