Repository navigation
fix(png): mask unused grayscale transparency bits - #9644
Conversation
|
The reported PNG behavior and the correction are consistent with the specification: for 1/2/4-bit grayscale, only the sample-depth bits of the |
jotitadev
left a comment
There was a problem hiding this comment.
Linux run, since Tested covers Windows only.
Machine: Linux x86-64, Ubuntu 26.04, Intel Core i7-8700, GCC 15.2.
Head: e03bf1864, merged onto main 4777caca3 (clean merge). Full build, BUILD_TESTING=ON.
- Release,
ctest -R '^(decoder_png|guest_png_dec)$': 2/2 pass. - Red check:
core/Decoder/Png/src/Png.cppfrommainwith this PR'stests/Png.cpp:decoder_pngaborts;guest_png_decstill passes. ANYPS5_ENABLE_ASAN=ONbuild (-fsanitize=address,undefined, RelWithDebInfo): both pass with no ASan or UBSan reports; the red check aborts the same way.
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
|
Thanks for adding the independent Linux run; the decoder regression passes in Release and under ASan/UBSan, and the red check against main demonstrates the test catches the original behavior. I do not have a new code finding on this unchanged head. Separately, this PR still targets |
e03bf18 to
bf26afb
Compare
|
Rebased onto main b7d1d47. |
bf26afb to
ada8c0b
Compare
|
I’ve noticed that asking you to hold this PR was unnecessary. It’s fine to keep submitting PRs; maintainers will handle them in due course. |
What
Fix transparency in 1-, 2- and 4-bit grayscale PNGs when unused bits are set in the
tRNSkey. The bundled decoder masks the key to eight bits before scaling it. At lower bit depths, that can leave every pixel opaque instead of making the matching sample transparent.Mask the key to the image's sample depth and correct alpha after a successful decode. This follows PNG section 11.3.1.1 and the key masking in libpng 1.6.43's
png_do_expand. The correction runs only for the affected grayscale inputs. The existing decoder's last-key choice is preserved when it accepts duplicatetRNSchunks.Tested
Windows 11 26H2 (build 10.0.26300), WinLibs GCC 15.2.0 r7, full Release build, head ada8c0b on main d6e7ab4.
decoder_png,guest_png_decandguest_png_encpass, 3/3.0x0002, where the PNG specification requires transparent black and opaque white.decoder_pngaborts with main's decoder.tools/check_conventions.py --base origin/mainandtools/check_test_registration.pypass. Merge tests against every open pull request that touches the PNG decoder or libraries find no new conflict.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)