Conversation
# Conflicts: # src/ImageSharp/Configuration.cs
# Conflicts: # src/ImageSharp/Formats/Bmp/BmpConstants.cs # src/ImageSharp/Formats/Bmp/BmpDecoder.cs # src/ImageSharp/Formats/Bmp/BmpFormat.cs
# Conflicts: # src/ImageSharp/Configuration.cs # src/ImageSharp/Formats/Bmp/BmpArrayFileHeader.cs # src/ImageSharp/Formats/Bmp/BmpConstants.cs # src/ImageSharp/Formats/Bmp/BmpFormat.cs # src/ImageSharp/Formats/Bmp/BmpImageFormatDetector.cs # src/ImageSharp/Formats/ImageExtensions.Save.cs # src/ImageSharp/Formats/Pbm/BufferedReadStreamExtensions.cs # tests/ImageSharp.Tests/ConfigurationTests.cs # tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs
# Conflicts: # src/ImageSharp/Configuration.cs # src/ImageSharp/Formats/Bmp/BmpArrayFileHeader.cs # src/ImageSharp/Formats/Bmp/BmpConstants.cs # src/ImageSharp/Formats/Bmp/BmpDecoder.cs # src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs # src/ImageSharp/Formats/Bmp/BmpFileHeader.cs # src/ImageSharp/Formats/Bmp/BmpFormat.cs # src/ImageSharp/Formats/Bmp/BmpImageFormatDetector.cs # src/ImageSharp/Formats/Bmp/BmpInfoHeader.cs # src/ImageSharp/Formats/ImageDecoderUtilities.cs # src/ImageSharp/Formats/ImageExtensions.Save.cs # src/ImageSharp/Formats/Pbm/BufferedReadStreamExtensions.cs # src/ImageSharp/Image.Decode.cs # tests/ImageSharp.Tests/ConfigurationTests.cs # tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs
# Conflicts: # src/ImageSharp/Formats/Bmp/BmpFormat.cs # src/ImageSharp/Formats/ImageDecoderUtilities.cs # src/ImageSharp/Formats/ImageExtensions.Save.cs # src/ImageSharp/Formats/OpenExr/ExrDecoderCore.cs
# Conflicts: # src/ImageSharp/Configuration.cs # src/ImageSharp/Formats/ImageDecoderUtilities.cs # tests/ImageSharp.Tests/TestUtilities/TestEnvironment.Formats.cs
src/ImageSharp/Formats/Exr/Compression/Decompressors/B44ExrCompression.cs
Fixed
Show fixed
Hide fixed
|
@brianpopow I'll review this asap. |
| /// <param name="component">The 32 bit component value.</param> | ||
| /// <returns>The <see cref="byte"/> value.</returns> | ||
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| public static byte From32BitTo8Bit(uint component) => (byte)(component * Scale32Bit); |
There was a problem hiding this comment.
Perf is maybe not a primary concern at this point but I wonder if there is a cheaper way to correctly calculate this that avoids FP conversion? How does the reference implementation calculate this (if they care about decoding into lower res format)?
There was a problem hiding this comment.
@brianpopow actually, I don't understand this. From32BitTo8Bit(uint.MaxValue) == 1. Are you sure this logic is correct? If it's incorrect, I wonder why tests didn't catch it? Wouldn't (byte)(component >> 16) do the job?
There was a problem hiding this comment.
@antonfirsov Yes I think you are right, this does not look right.
I wonder why tests didn't catch it?
There are no pixel conversion tests yet for the new pixel types. I will try to add tests for the new pixlel types Rgb96 and Rgba128 next.
Wouldn't (byte)(component >> 16) do the job?
Yeah that's more like it, but I think it should be (byte)(component >> 24)? Lets say we have for example Int.Max / 2, e.g. 2147483647. Converting this to 8 bit should be 127.
Prerequisites
Description
This PR adds support for decoding and encoding of images in the OpenEXR format. OpenEXR is a HDR image format, therefore I have added two new pixel formats
Rgb96andRgba128which store each color channel asUInt32.The specification can be found here: https://openexr.com/en/latest/index.html#openexr
A reference implementation can be found here: https://github.com/AcademySoftwareFoundation/openexr.git