mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-23 08:47:56 +01:00
Tighten the NIE spec to always be in BGRA order
This commit is contained in:
1 parent
6b69425247
commit
53ec09fa9e
2 files changed
+14
-17
No files matched your search
@@ -14,12 +14,11 @@ more suitable.
|
|||||||
Amongst uncompressed formats, [Farbfeld](https://tools.suckless.org/farbfeld/)
|
Amongst uncompressed formats, [Farbfeld](https://tools.suckless.org/farbfeld/)
|
||||||
is a very similar design. The main difference is that NIE is little-endian (the
|
is a very similar design. The main difference is that NIE is little-endian (the
|
||||||
same as the vast majority of CPUs) where Farbfeld is big-endian. NIE/NII/NIA
|
same as the vast majority of CPUs) where Farbfeld is big-endian. NIE/NII/NIA
|
||||||
also allows animated images, not just still images, and is also configurable
|
also allows animated images, not just still images, and is also configurable:
|
||||||
with respect to BGRA versus RGBA order, non-premultiplied versus premultiplied
|
non-premultiplied versus premultiplied alpha and 8- versus 16-bit channels.
|
||||||
alpha, and 8 versus 16 bit channels. Configurability is admittedly a trade-off:
|
Configurability is admittedly a trade-off. One person's configuration parameter
|
||||||
one person's configuration parameter is another person's unnecessary bloat.
|
is another person's unnecessary bloat. We're not saying that Farbfeld is a bad
|
||||||
We're not saying that Farbfeld is a bad design, just a different design that
|
design, just a different design that has chosen different trade-offs.
|
||||||
has chosen different trade-offs.
|
|
||||||
|
|
||||||
[PAM](http://netpbm.sourceforge.net/doc/pam.html) (Portable Arbitrary Map) and
|
[PAM](http://netpbm.sourceforge.net/doc/pam.html) (Portable Arbitrary Map) and
|
||||||
its related formats (PBM, PGM, PPM) are also very similar. The main difference
|
its related formats (PBM, PGM, PPM) are also very similar. The main difference
|
||||||
|
|||||||
+9
-11
@@ -1,6 +1,6 @@
|
|||||||
# Naïve Image Formats: NIE, NII, NIA
|
# Naïve Image Formats: NIE, NII, NIA
|
||||||
|
|
||||||
Status: Draft (as of May 2020). There is no compatibility guarantee yet.
|
Status: Draft (as of November 2020). There is no compatibility guarantee yet.
|
||||||
|
|
||||||
A companion document has further discussion of [NIE related
|
A companion document has further discussion of [NIE related
|
||||||
work](/doc/spec/nie-related-work.md).
|
work](/doc/spec/nie-related-work.md).
|
||||||
@@ -12,14 +12,13 @@ NIE is an easily parsed, uncompressed, lossless format for still (single frame)
|
|||||||
images. The 16 byte header:
|
images. The 16 byte header:
|
||||||
|
|
||||||
- 4 bytes of 'magic': \[0x6E, 0xC3, 0xAF, 0x45\], the UTF-8 encoding of "nïE".
|
- 4 bytes of 'magic': \[0x6E, 0xC3, 0xAF, 0x45\], the UTF-8 encoding of "nïE".
|
||||||
- 4 bytes of version-and-configuration: \[0xFF, 0x62 or 0x72, 0x6E or 0x70,
|
- 4 bytes of version-and-configuration: \[0xFF, 0x62, 0x6E or 0x70, 0x34 or
|
||||||
0x34 or 0x38\].
|
0x38\].
|
||||||
- The first byte denotes the overall NIE/NII/NIA format version. 0xFF (which
|
- The first byte denotes the overall NIE/NII/NIA format version. 0xFF (which
|
||||||
is not valid UTF-8) denotes version 1. There are no other valid versions at
|
is not valid UTF-8) denotes version 1. There are no other valid versions at
|
||||||
this time.
|
this time.
|
||||||
- The second byte, either an ASCII 'b' or an ASCII 'r', denotes whether the
|
- The second byte must be an ASCII 'b'. This denotes that the payload is in
|
||||||
pixel's data is in BGRA or RGBA order (in memory order, independent of CPU
|
BGRA order (in terms of the wire format, independent of CPU endianness).
|
||||||
endianness).
|
|
||||||
- The third byte, either an ASCII 'n' or an ASCII 'p', denotes whether the
|
- The third byte, either an ASCII 'n' or an ASCII 'p', denotes whether the
|
||||||
payload contains non-premultiplied or premultiplied alpha.
|
payload contains non-premultiplied or premultiplied alpha.
|
||||||
- The fourth byte, either an ASCII '4' or an ASCII '8', denotes whether there
|
- The fourth byte, either an ASCII '4' or an ASCII '8', denotes whether there
|
||||||
@@ -31,11 +30,10 @@ images. The 16 byte header:
|
|||||||
|
|
||||||
The payload:
|
The payload:
|
||||||
|
|
||||||
- 4 or 8 bytes per pixel. W×H pixels in row-major order. Row-major means that
|
- 4 or 8 bytes per pixel. W×H pixels in row-major order (horizontally adjacent
|
||||||
horizontally adjacent pixels are adjacent in memory. Values are
|
pixels are adjacent in memory). For example, with 8 bytes per pixel, those
|
||||||
little-endian. For example, with BGRA order and 8 bytes per pixel, those
|
|
||||||
bytes are \[B₀, B₁, G₀, G₁, R₀, R₁, A₀, A₁\]. The ₀ and ₁ subscripts denote
|
bytes are \[B₀, B₁, G₀, G₁, R₀, R₁, A₀, A₁\]. The ₀ and ₁ subscripts denote
|
||||||
the low and high bytes of the `uint16`.
|
the low and high bytes of each little-endian `uint16`.
|
||||||
|
|
||||||
That's it.
|
That's it.
|
||||||
|
|
||||||
@@ -371,4 +369,4 @@ in a long "E", "I" or "A" sound. It's definitely a hard "N", not a soft one.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
Updated on May 2020.
|
Updated on November 2020.
|
||||||
Reference in new issue
Block a user