Question About RGB and sRGB with PNG #1661
-
I am not an expert in gamma correction, it seems like a topic with a lot of history. I am using STBI to write PNG files. I generate RGB values in linear space, perform gamma correction using my own code, then write the 3 u8 components into the buffer. So the STBI image data buffer holds sRGB values, NOT linear values. I then write the image using stbi_write_png. Is this the correct way to handle gamma correction when writing PNGs? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
It's the appropriate solution when using stb_image_write. However, be advised that the PNG spec does support metadata that explicitly indicates a PNG is sRGB, but stb_image_write does |
Beta Was this translation helpful? Give feedback.
It's the appropriate solution when using stb_image_write.
However, be advised that the PNG spec does support metadata that explicitly indicates a PNG is sRGB, but stb_image_write does
notsupport writing that metadata. Nevertheless, with most PNG readers this should be fine as they'll default to assuming the PNG is sRGB.