treeform / pixie

Full-featured 2d graphics library for Nim.
MIT License
742 stars 28 forks source link

QOI decoding does not convert between sRGB and Linear #545

Open de-odex opened 1 year ago

de-odex commented 1 year ago

Hello, this is less a bug than an observation, but when I was reading the code for QOI decoding I noticed that the colourspace is never checked in conversion to an Image. I was wondering if there was a mistake here as that would mean Image could either have gamma-encoded sRGB values or linear sRGB values, whilst not also storing which it would be. Furthermore, perhaps more clarification as to what ColorRGBX (and friends RGB RGBA) stores in terms of colourspace is needed.

treeform commented 12 months ago

@ehmry could you look into this? You wrote the entire encoding/decoding stack. It looks like there is a flag in the spec for linear and sRGB, pixie should support reading sRGB and should always write linear.

Pixie does not support sRGB. ColorRGBX is just premultiplied alpha RGBA (its not a color space).

ehmry commented 12 months ago

I'll see what I­ can do.

ehmry commented 12 months ago

All of the QOI images I can find are in sRGB (https://qoiformat.org/qoi_test_images.zip) and when decoding a QOI and encoding to PNG the grays come out the same. I'm not sure what is going on here.

de-odex commented 12 months ago

I only noticed this from reading the specification; I do not know if it is used in practice but it is nonetheless in the spec... I don't know why it is in the spec but if it doesn't matter then it's probably fine to drop this for now