doc.odin 1.9 KB

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. Formats:
  3. PBM (P1, P4): Portable Bit Map, stores black and white images (1 channel)
  4. PGM (P2, P5): Portable Gray Map, stores greyscale images (1 channel, 1 or 2 bytes per value)
  5. PPM (P3, P6): Portable Pixel Map, stores colour images (3 channel, 1 or 2 bytes per value)
  6. PAM (P7 ): Portable Arbitrary Map, stores arbitrary channel images (1 or 2 bytes per value)
  7. PFM (Pf, PF): Portable Float Map, stores floating-point images (Pf: 1 channel, PF: 3 channel)
  8. Reading:
  9. All formats fill out header fields `format`, `width`, `height`, `channels`, `depth`
  10. Specific formats use more fields
  11. PGM, PPM, and PAM set `maxval` (maximum of 65535)
  12. PAM sets `tupltype` if there is one, and can set `channels` to any value (not just 1 or 3)
  13. PFM sets `scale` (float equivalent of `maxval`) and `little_endian` (endianness of stored floats)
  14. Currently doesn't support reading multiple images from one binary-format file
  15. Writing:
  16. You can use your own `Netpbm_Info` struct to control how images are written
  17. All formats require the header field `format` to be specified
  18. Additional header fields are required for specific formats
  19. PGM, PPM, and PAM require `maxval` (maximum of 65535)
  20. PAM also uses `tupltype`, though it may be left as default (empty or nil string)
  21. PFM requires `scale`, and optionally `little_endian`
  22. Some syntax differences from the specifications:
  23. `channels` stores the number of values per pixel, what the PAM specification calls `depth`
  24. `depth` instead is the number of bits for a single value (32 for PFM, 16 or 8 otherwise)
  25. `scale` and `little_endian` are separated, so the `header` will always store a positive `scale`
  26. `little_endian` will only be true for a negative `scale` PFM, every other format will be false
  27. `little_endian` only describes the netpbm data being read/written, the image buffer will be native
  28. */
  29. package netpbm