OpenEXR color data is incorrect when using HalfVector4
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- csharp
- Domain
- computer-graphics
Research direction
Start in ExrDecoderCore.cs around the pixel assignment using FromAssociatedScaledVector4, then inspect FromVector4 for the related floating-point formats. Reproduce with an OpenEXR file loaded as HalfVector4 or HalfVector4P and inspect ToVector4(); done means HDR channel values are preserved instead of being clamped and scaled.
Written by the indexing model from the issue text.
Description
Prerequisites
- I have written a descriptive issue title
- I have verified that I am running the latest version of ImageSharp
- I have verified if the problem exist in both
DEBUGandRELEASEmode - I have searched open and closed issues to ensure it has not already been reported
ImageSharp version
4.1.2
Other ImageSharp packages and versions
4.1.2
Environment (Operating system, version and so on)
windows11
.NET Framework version
10
Description
I encountered an issue where OpenEXR image data is being incorrectly altered during loading when using the HalfVector4 floating-point pixel formats
OpenEXR frequently stores High Dynamic Range (HDR) color data in floating-point formats, which means values often exceed the [0, 1] range. However, the current loading logic clamps and scales these values, destroying the original raw data.
I traced the issue to two specific areas in the codebase:
In ExrDecoderCore.cs (around line 225):
pixelRow[x] = TPixel.FromAssociatedScaledVector4(pixelValue);
If TPixel is HalfVector4 and the EXR pixel type is half or float, the RGB channels are clamped to [0, 1] and then scaled/biased to [FiniteMinimum, FiniteMaximum]. This breaks the original floating-point data. I believe the clamp and scale operations should be avoided here.
As a side note for other floating point pixel format like RgbaHalf and RgbaVector.The FromAssociatedScaledVector4 method calls FromVector4(Vector4 source). Inside FromVector4, the original values are explicitly clamped to [0, 1]. This also breaks the raw EXR data.
Steps to Reproduce
load a openEXR file in HalfVector4 or HalfVector4P format,then check the pixel value of ToVector4();
Images
No response
- Dominant language
- C#
- Stars
- 8k
- Forks
- 899
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 7
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from SixLabors/ImageSharp
-
needs triage
Difficulty 4/5 3-5 days Newbie friendliness 48/100
SixLabors/ImageSharp#3198 ·
-
needs triage
Difficulty 4/5 3-5 days Newbie friendliness 52/100
SixLabors/ImageSharp#3197 ·
-
formats:exr
Difficulty 5/5 Over a week Newbie friendliness 35/100
SixLabors/ImageSharp#3116 · 2 comments · 1 reaction ·
-
needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 52/100
SixLabors/ImageSharp#2805 · 1 comment ·
-
CR2: System.NotSupportedException: Missing SOI marker offset for tiff with old jpeg compression Openneeds triage
Difficulty 4/5 3-5 days Newbie friendliness 35/100
SixLabors/ImageSharp#2665 · 2 comments ·
All issues in SixLabors/ImageSharp
Similar issues
-
bug documentation frontend
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
azurenoops/spin_agent#975 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SubtitleEdit/subtitleedit#15108 · 1 comment ·
-
area/docs-content Bug pulumi/docs
Difficulty 1/5 1-3 hours Newbie friendliness 94/100