- From: John Bowler <john.cunningham.bowler@gmail.com>
- Date: Mon, 7 Jul 2025 14:48:06 -0700
- To: "Chris Blume (ProgramMax)" <programmax@gmail.com>
- Cc: "Portable Network Graphics (PNG) Working Group" <public-png@w3.org>
- Message-ID: <CAP7U39-YniCe3sLmA88AUdQYo=h=L1JJMrU2VyKTpVfEXZE2Pg@mail.gmail.com>
>Integers must be updated to be more than 31-bit The definition has been in the spec from the start. Unfortunately it was removed from PNG v3 even though signed integers are used in the extensions. Here's the definition from PNG v2: Values are unsigned unless otherwise noted. Values explicitly noted as > signed are represented in two's complement notation. > PNG four-byte unsigned integers are limited to the range 0 to 231-1 to > accommodate languages that have difficulty with unsigned four-byte values. > Similarly PNG four-byte signed integers are limited to the range -(231-1) > to 231-1 to accommodate languages that have difficulty with the value -231 > . @CL: that text can be *massively *simplified: Values shall be represented in 1, 2 or 4 bytes with the most significant byte of the value first (MSB). 1 and 2 byte values encode 8 and 16 bit unsigned integral values. 4 byte values shall be encoded as 2's complement values limited to the range -(231-1) to 231-1; the encoded value 0x80000000 shall not be used. Unless explicitly stated in the description of a chunk value all 4 byte values shall be non-negative, i.e. in the range 0 to 231-1. That will lead to much better implementations because implementors won't make mistakes, like "ignoring" the top bit (which one PNG implementation apparently does.) In any case this should be an erratum to PNG v3; it was a mistake to remove the definition of signed integers because it breaks the extensions document: > https://ftp-osl.osuosl.org/pub/libpng/documents/pngext-1.5.0.html#DR.Integer-values Also I do think teaching about byte-stream marshalling in the PNG spec is out-of-place. This is such a fundamental bit of computer science and software engineering both. John Bowler <jbowler@acm.org> >
Received on Monday, 7 July 2025 21:48:21 UTC