Repository navigation
Conversation
|
Note on the red macOS jobs: I think they ran a stale object for The log still shows With a clean |
5306b62 to
9fba0a5
Compare
The PNG encoder passed a bit depth of 10 for RGB30 surfaces. PNG
truecolor only allows 8 or 16 bits per sample, so libpng rejected the
header and toBuffer('image/png') returned just the 8-byte signature
without an error.
Widen each x2R10G10B10 row to big-endian 16-bit RGB (10-bit values
scaled to the full 16-bit range) and write the image with bit depth 16.
Fixes Automattic#2625
9fba0a5 to
0563189
Compare
Thanks for contributing!
Fixes #2625
Problem
canvas_write_png()set the bit depth to 10 forCAIRO_FORMAT_RGB30. PNG truecolor only allows 8 or 16 bits per sample, so libpng rejected the IHDR and longjmp'd out. Because the error path returns the (still successful) status,toBuffer('image/png')gave back only the 8-byte PNG signature with no error:(cairo's own
write_pngnever hits itsRGB30 → bpc = 10case, because it coerces RGB30 to RGB24 first. This copy of the code skips that step.)Fix
Write RGB30 as 16-bit RGB. Each row is converted from native-endian x2R10G10B10 to big-endian 16-bit samples (10-bit value scaled with
(v << 6) | (v >> 4), so 0x3ff maps to 0xffff), using a one-row buffer andpng_write_row(). Keeping 16 bits means no precision is lost. Other formats are unchanged.Tests
canvas.test.js: an RGB30 canvas exported to PNG has bit depth 16 / color type 2 and decodes back to the drawn colors. Fails on master ('IHDR' == ''), passes here.npm test: 308 passing.createPNGStream()works for RGB30.