Menu

#282 Gamma correction corner case

libpng_code
open
None
5
2018-07-17
2018-06-28
Randy
No

libpng has a corner case with the last pixel of 16-bit grayscale images when they're decoded to 8-bit RGBA using gamma correction.

When basn0g16.png is decoded without gamma correction both pixels at 0,0 and 31,31 are decoded to RGBA 0 0 0 255. Using gamma correction it's 0 0 0 255 at 0,0 but it's 19 19 19 255 at 31,31.

The attached file reads basn0g16.png and decodes it without gamma correction and prints the first and last pixel's RGBA values. If "g" is passed as an argument it will decode using gamma correction.

This is reproducible with libpng 1.6.34

./gamma.o
no gamma correction
image size: 4096
first pixel: 0 0 0 255, last pixel: 0 0 0 255

./gamma.o g
doing gamma correction
image size: 4096
first pixel: 0 0 0 255, last pixel: 19 19 19 255

spng bug report

1 Attachments

Discussion

  • Randy

    Randy - 2018-07-16

    This is also reproducible with 1.6.35.

     
  • Cosmin Truta

    Cosmin Truta - 2018-07-17

    Indeed. Will plan for 1.6.36.
    Thanks for the follow-up.

     

Log in to post a comment.