On Tue Apr 7 17:33:31 2026 +0000, Matteo Bruni wrote:
I seem to recall that you tried with the "accurate" piecewise sRGB definition previously (i.e. the one that's linear in the very low end and then uses a 2.4 exponent for the rest) but that didn't quite match as nicely? Maybe it makes sense to leave a small comment to that point, here or elsewhere. Separately, a bit of a nitpick. `apply_gamma_2_2()` might be slightly confusing: does it mean that gamma is applied to an sRGB color value to return the corresponding linear value or does it transform a linear color value into the corresponding sRGB value? In this case it's the latter, but you see the problem :slight_smile: Personally I'd just go with something like `srgb_from_linear()` and `linear_from_srgb()`, respectively. I've changed the conversion function names to be as you've suggested in the current revision, it definitely is clearer. I've done the same renaming to the premultiplied alpha conversion functions as well, I think it helps there too.
I've added some more tests around sRGB, as well as a comment above the conversion functions that hopefully explains things... the definition of "sRGB" is hard to track down, it seems some interpret it as just plain gamma 2.2, and others claim it only means the piece-wise sRGB definition. The MSDN docs refer to it as gamma 2.2 in some places, but then there are things like `D3DX_FLOAT_to_SRGB` in the DirectX SDK that treat it as the piece-wise version. Hopefully my code comment clarifies things :) -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10513#note_136513